Plan: Worker Portal — Multi-Program Expansion (canopy-web)

Status

Step Description Status

1

Program enum, ServiceClients::program_client() dispatch, new client fields for tanf/medicaid/caps/wic

Done (2026-04-14)

2

?program= query param on case detail, per-program tab definitions, route plumbing

Done (2026-04-14)

3

TANF determination tab + work requirements / time limits sub-panels

Done (2026-04-14)

4

Medicaid determination tab + COA cascade + category breakdown sub-panel

Done (2026-04-14) — truncated person UUIDs pending persons lookup (Tier 5.5)

5

CAPS determination tab + authorization + copayment sub-panel

Done (2026-04-14) — authorization tab pending det-ID → authorization lookup (Tier 5.5)

6

WIC determination tab + participant + nutritional risk sub-panel

Done (2026-04-14) — nutritional risk tab pending GET /assessments endpoint (Tier 5.5)

7

Unit tests + Playwright E2E expansion + documentation updates

Done (2026-04-14) — unit tests + documentation landed with the multi-program rollout. Playwright multi-program E2E expansion is tracked separately under playwright-e2e (roadmap Tier 7) — not in this plan’s scope.

Branch: feature/worker-portal-expansion

Context

canopy-web currently operates as a SNAP-only worker portal. Every case detail page (GET /cases/{household_id}) hard-codes SNAP-specific behavior:

  • all_tabs() returns a fixed 7-tab list including SNAP-only tabs (e.g., certification, ABAWD column, IEVS discrepancies).

  • render_determination_tab() queries clients.snap directly for SNAP determinations.

  • render_household_tab() fetches SNAP certification periods from clients.renewals.

  • The ServiceClients struct has only a snap field — no tanf, medicaid, caps, or wic clients.

  • The case summary bar shows a hard-coded "SNAP" badge with no program selection.

All five program services are now implemented and have GET /v1/determinations?limit=50 or GET /v1/determinations/{id} endpoints that return JSON. The task is to make the worker portal program-aware so that a caseworker can select which program’s determination, rules, and program-specific data to view for a given household.

Related ADRs:

  • ADR-001 (program service isolation): each program has an independent service and database.

  • ADR-002 (black-box determination): all determination responses share id, status, benefit_amount, signature fields.

  • ADR-005 (modular deployment): services degrade gracefully when not deployed.

Scope

In scope:

  • Program enum with slug matching, display names, and per-program tab definitions.

  • ServiceClients expansion with tanf, medicaid, caps, wic client fields and a program_client(slug) → Option<&InternalClient> dispatcher.

  • Query-param-based program selection on case detail: GET /cases/{household_id}?program=snap.

  • Program-specific determination tab renderers for TANF, Medicaid, CAPS, and WIC.

  • Program-specific sub-panels: TANF work requirements/time limits, Medicaid COA cascade/categories, CAPS copayment/authorization, WIC participant/nutritional risk.

  • Graceful degradation: if a program service is unreachable, render _service_error.html partial instead of 500.

  • Program badge in case summary bar derived from selected program.

  • Docker compose environment variable additions for 4 new service URLs.

  • Unit tests for new dispatch logic + Playwright E2E tests for program switching.

Out of scope:

  • Multi-program simultaneous view (showing SNAP and TANF side by side). The query-param model selects one program at a time.

  • Program-specific action handlers (e.g., TANF work activity recording). Those will be a separate plan after the view layer is complete.

  • Applicant portal (canopy-portal) — post-UAT.

  • Changes to upstream program services' API contracts. This plan only adds canopy-web client-side logic.

Design

URL scheme

Case detail URL gains an optional program query parameter:

GET /cases/{household_id}                    → defaults to "snap"
GET /cases/{household_id}?program=tanf       → TANF view
GET /cases/{household_id}?program=medicaid   → Medicaid view
GET /cases/{household_id}?program=caps       → CAPS view
GET /cases/{household_id}?program=wic        → WIC view

Tab URLs gain the same parameter for htmx partial fetches:

GET /cases/{household_id}/tab/{tab_id}?program=snap
GET /cases/{household_id}/tab/{tab_id}?program=tanf

This ensures the program context is preserved when htmx fetches individual tabs. The tab navigation buttons in the template must include the ?program= query parameter in their hx-get attributes.

Program enum

A new file services/canopy-web/src/program.rs defines the central program abstraction:

// SPDX-License-Identifier: AGPL-3.0-or-later

use serde::Deserialize;

use crate::api::case_detail::TabDef;

/// Benefit program supported by the worker portal.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Program {
    Snap,
    Tanf,
    Medicaid,
    Caps,
    Wic,
}

impl Program {
    /// Parse from query parameter string. Returns `None` for unknown slugs.
    pub fn from_slug(s: &str) -> Option<Self> {
        match s {
            "snap" => Some(Self::Snap),
            "tanf" => Some(Self::Tanf),
            "medicaid" => Some(Self::Medicaid),
            "caps" => Some(Self::Caps),
            "wic" => Some(Self::Wic),
            _ => None,
        }
    }

    /// URL query parameter value.
    pub fn slug(&self) -> &'static str {
        match self {
            Self::Snap => "snap",
            Self::Tanf => "tanf",
            Self::Medicaid => "medicaid",
            Self::Caps => "caps",
            Self::Wic => "wic",
        }
    }

    /// Human-readable display name for badges and headings.
    pub fn display_name(&self) -> &'static str {
        match self {
            Self::Snap => "SNAP",
            Self::Tanf => "TANF",
            Self::Medicaid => "Medicaid",
            Self::Caps => "CAPS",
            Self::Wic => "WIC",
        }
    }

    /// CSS class suffix for program badge coloring.
    pub fn badge_class(&self) -> &'static str {
        match self {
            Self::Snap => "u-badge-program-snap",
            Self::Tanf => "u-badge-program-tanf",
            Self::Medicaid => "u-badge-program-medicaid",
            Self::Caps => "u-badge-program-caps",
            Self::Wic => "u-badge-program-wic",
        }
    }

    /// Per-program tab definitions. Shared tabs (household, notices, appeals,
    /// activity, guidance) are present for all programs. Program-specific tabs
    /// (e.g., "Work Requirements" for TANF, "COA Cascade" for Medicaid) are
    /// inserted in the appropriate position.
    pub fn tabs(&self) -> Vec<TabDef> {
        let mut tabs = vec![
            TabDef { id: "household".into(), label: "Household".into() },
            TabDef { id: "income".into(), label: "Income & Verify".into() },
            TabDef { id: "determination".into(), label: "Determination".into() },
        ];

        // Program-specific tabs after determination
        match self {
            Self::Snap => {
                // SNAP has no extra tabs beyond the shared set
            }
            Self::Tanf => {
                tabs.push(TabDef { id: "work_requirements".into(), label: "Work Requirements".into() });
                tabs.push(TabDef { id: "time_limits".into(), label: "Time Limits".into() });
            }
            Self::Medicaid => {
                tabs.push(TabDef { id: "categories".into(), label: "COA Cascade".into() });
            }
            Self::Caps => {
                tabs.push(TabDef { id: "authorization".into(), label: "Authorization".into() });
            }
            Self::Wic => {
                tabs.push(TabDef { id: "participant".into(), label: "Participant".into() });
            }
        }

        // Shared tail tabs
        tabs.push(TabDef { id: "notices".into(), label: "Notices".into() });
        tabs.push(TabDef { id: "appeals".into(), label: "Appeals".into() });
        tabs.push(TabDef { id: "activity".into(), label: "Activity".into() });
        tabs.push(TabDef { id: "guidance".into(), label: "Guidance".into() });
        tabs
    }
}

impl Default for Program {
    fn default() -> Self {
        Self::Snap
    }
}

ServiceClients expansion

The ServiceClients struct in services/canopy-web/src/clients.rs gains four new fields and a dispatch method:

pub struct ServiceClients {
    pub persons: InternalClient,
    pub applications: InternalClient,
    pub eligibility: InternalClient,
    pub snap: InternalClient,
    pub tanf: InternalClient,
    pub medicaid: InternalClient,
    pub caps: InternalClient,
    pub wic: InternalClient,
    pub renewals: InternalClient,
    pub notices: InternalClient,
    pub appeals: InternalClient,
    pub security: InternalClient,
}

impl ServiceClients {
    /// Return the program-specific InternalClient for a given program slug.
    /// Returns `None` if the slug is unknown (should not happen if Program
    /// enum was parsed first, but callers should handle gracefully).
    pub fn program_client(&self, program: &crate::program::Program) -> &InternalClient {
        match program {
            crate::program::Program::Snap => &self.snap,
            crate::program::Program::Tanf => &self.tanf,
            crate::program::Program::Medicaid => &self.medicaid,
            crate::program::Program::Caps => &self.caps,
            crate::program::Program::Wic => &self.wic,
        }
    }
}

New env vars in from_env():

tanf: InternalClient::new(
    &get("CANOPY_WEB__TANF_URL", "http://localhost:8014"),
    "canopy-tanf",
),
medicaid: InternalClient::new(
    &get("CANOPY_WEB__MEDICAID_URL", "http://localhost:8015"),
    "canopy-medicaid",
),
caps: InternalClient::new(
    &get("CANOPY_WEB__CAPS_URL", "http://localhost:8016"),
    "canopy-caps",
),
wic: InternalClient::new(
    &get("CANOPY_WEB__WIC_URL", "http://localhost:8017"),
    "canopy-wic",
),

with_token() must be updated to clone and set tokens on all 12 clients.

Query parameter extraction

A new Axum query struct in case_detail.rs:

#[derive(Debug, Deserialize)]
pub struct CaseDetailQuery {
    pub program: Option<String>,
}

The get_case_detail handler adds Query(query): Query<CaseDetailQuery> and resolves the program:

let program = query.program
    .as_deref()
    .and_then(Program::from_slug)
    .unwrap_or_default();

Determination dispatch pattern

The generic determination fetch pattern (used by all programs) follows:

/// Fetch the latest determination for a household from the given program client.
/// All program services expose `GET /v1/determinations?limit=50` returning a
/// `Vec<serde_json::Value>` with at minimum: `id`, `household_id`, `status`,
/// `benefit_amount`, `determined_at`, `signature` fields.
async fn fetch_program_determination(
    client: &InternalClient,
    household_id: &str,
) -> Option<serde_json::Value> {
    client
        .get::<Vec<serde_json::Value>>("/v1/determinations?limit=50")
        .await
        .ok()
        .and_then(|dets| {
            dets.into_iter()
                .find(|d| d["household_id"].as_str() == Some(household_id))
        })
}
NOTE
canopy-caps and canopy-wic do NOT expose GET /v1/determinations (list endpoint) — they only have GET /v1/determinations/{id}. For these programs, the determination tab will render "No determination on file" until a determination ID is known from the orchestrator or a future list endpoint is added. This is acceptable for the initial multi-program expansion; adding GET /v1/determinations?household_id=X list endpoints to canopy-caps and canopy-wic is a follow-up task documented in the plan.

Steps

Step 1: Program enum + ServiceClients expansion

Files: services/canopy-web/src/program.rs (new), services/canopy-web/src/clients.rs, services/canopy-web/src/main.rs, docker-compose.yml

Create services/canopy-web/src/program.rs with the Program enum exactly as shown in the Design section above.

Modify services/canopy-web/src/clients.rs:

  1. Add four new fields to ServiceClients: tanf, medicaid, caps, wic (all InternalClient).

  2. Add pub fn program_client(&self, program: &crate::program::Program) → &InternalClient as shown in the Design section.

  3. Update from_env() to initialize the four new clients with these defaults:

    Field Env var Default

    tanf

    CANOPY_WEB__TANF_URL

    http://localhost:8014

    medicaid

    CANOPY_WEB__MEDICAID_URL

    http://localhost:8015

    caps

    CANOPY_WEB__CAPS_URL

    http://localhost:8016

    wic

    CANOPY_WEB__WIC_URL

    http://localhost:8017

  4. Update with_token() to clone+token all 12 clients (add tanf, medicaid, caps, wic alongside existing 8).

Modify services/canopy-web/src/main.rs:

  1. Add mod program; after the existing mod theme; line.

Modify docker-compose.yml:

  1. Add four new environment variables to the canopy-web service block (after the existing CANOPY_WEB__SECURITY_URL line):

    CANOPY_WEB__TANF_URL: "http://canopy-tanf:8014"
    CANOPY_WEB__MEDICAID_URL: "http://canopy-medicaid:8015"
    CANOPY_WEB__CAPS_URL: "http://canopy-caps:8016"
    CANOPY_WEB__WIC_URL: "http://canopy-wic:8017"

Update existing tests in clients.rs:

  • service_clients_from_env_defaults — assert clients.tanf.base_url == "http://localhost:8014", clients.medicaid.base_url == "http://localhost:8015", etc.

  • service_clients_with_token — assert authed.tanf.auth_token.as_deref() == Some("jwt-token-123"), etc.

Add new tests in program.rs:

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn slug_round_trip() {
        for p in [Program::Snap, Program::Tanf, Program::Medicaid, Program::Caps, Program::Wic] {
            assert_eq!(Program::from_slug(p.slug()), Some(p));
        }
    }

    #[test]
    fn unknown_slug_returns_none() {
        assert_eq!(Program::from_slug("unknown"), None);
        assert_eq!(Program::from_slug(""), None);
    }

    #[test]
    fn default_is_snap() {
        assert_eq!(Program::default(), Program::Snap);
    }

    #[test]
    fn snap_tabs_count() {
        assert_eq!(Program::Snap.tabs().len(), 7); // household, income, determination, notices, appeals, activity, guidance
    }

    #[test]
    fn tanf_tabs_include_work_requirements_and_time_limits() {
        let tabs = Program::Tanf.tabs();
        assert!(tabs.iter().any(|t| t.id == "work_requirements"));
        assert!(tabs.iter().any(|t| t.id == "time_limits"));
        assert_eq!(tabs.len(), 9);
    }

    #[test]
    fn medicaid_tabs_include_categories() {
        let tabs = Program::Medicaid.tabs();
        assert!(tabs.iter().any(|t| t.id == "categories"));
        assert_eq!(tabs.len(), 8);
    }

    #[test]
    fn caps_tabs_include_authorization() {
        let tabs = Program::Caps.tabs();
        assert!(tabs.iter().any(|t| t.id == "authorization"));
        assert_eq!(tabs.len(), 8);
    }

    #[test]
    fn wic_tabs_include_participant() {
        let tabs = Program::Wic.tabs();
        assert!(tabs.iter().any(|t| t.id == "participant"));
        assert_eq!(tabs.len(), 8);
    }
}

Verification:

cargo nextest run -p canopy-web --lib
cargo clippy -p canopy-web -- -D warnings

Step 2: Query-param routing + program-aware case detail

Files: services/canopy-web/src/api/case_detail.rs, services/canopy-web/templates/cases/detail.html

Modify services/canopy-web/src/api/case_detail.rs:

  1. Add imports at the top:

    use axum::extract::Query;
    use serde::Deserialize;
    use crate::program::Program;
  2. Add query struct:

    #[derive(Debug, Deserialize)]
    pub struct CaseDetailQuery {
        pub program: Option<String>,
    }
  3. Remove the all_tabs() function entirely. Tabs are now provided by Program::tabs().

  4. Change get_case_detail signature to accept the query parameter:

    pub async fn get_case_detail(
        AuthenticatedWorker(worker): AuthenticatedWorker,
        Extension(theme): Extension<Arc<ThemeConfig>>,
        Extension(clients): Extension<Arc<ServiceClients>>,
        Path(household_id): Path<String>,
        Query(query): Query<CaseDetailQuery>,
    ) -> Html<String> {
  5. At the top of the handler body, resolve the program:

    let program = query.program
        .as_deref()
        .and_then(Program::from_slug)
        .unwrap_or_default();
  6. Replace the hard-coded SNAP benefit amount fetch with a dispatch to the selected program’s client:

    let program_client = clients.program_client(&program);
    let benefit_amount = program_client
        .get::<Vec<serde_json::Value>>("/v1/determinations?limit=50")
        .await
        .ok()
        .and_then(|dets| {
            dets.iter()
                .find(|d| d["household_id"].as_str() == Some(&household_id))
                .and_then(|d| {
                    let status = d["status"].as_str().or(d["determination_status"].as_str());
                    if status == Some("approved") || status == Some("eligible") {
                        d["benefit_amount"]
                            .as_str()
                            .map(|a| format!("${a}/mo"))
                            .or_else(|| d["benefit_amount"].as_f64().map(|a| format!("${a:.2}/mo")))
                    } else {
                        None
                    }
                })
        })
        .unwrap_or_else(|| "N/A".into());
    NOTE
    canopy-caps and canopy-wic use determination_status instead of status. The .or() chain handles both.
  7. For certification period, only fetch from renewals when program == Program::Snap (other programs do not use canopy-renewals):

    let cert_period = if program == Program::Snap {
        clients.renewals
            .get::<serde_json::Value>(&format!(
                "/v1/renewals/snap/certifications?household_id={household_id}"
            ))
            .await
            .ok()
            .and_then(|cert| {
                let start = cert["certification_start_date"].as_str()?;
                let end = cert["certification_end_date"].as_str()?;
                Some(format!("{start} \u{2192} {end}"))
            })
            .unwrap_or_else(|| "No active certification".into())
    } else {
        "N/A".into()
    };
  8. Add program_slug and program_name and program_badge_class fields to CaseDetailTemplate:

    struct CaseDetailTemplate {
        // ... existing fields ...
        program_slug: String,
        program_name: String,
        program_badge_class: String,
        // tabs field stays Vec<TabDef>
    }
  9. Populate with:

    program_slug: program.slug().to_owned(),
    program_name: program.display_name().to_owned(),
    program_badge_class: program.badge_class().to_owned(),
    tabs: program.tabs(),
  10. Change get_tab signature to also accept Query(query): Query<CaseDetailQuery>:

    pub async fn get_tab(
        AuthenticatedWorker(worker): AuthenticatedWorker,
        Extension(clients): Extension<Arc<ServiceClients>>,
        Extension(workflows): Extension<Arc<Vec<canopy_policy::workflow::WorkflowTemplate>>>,
        Path((household_id, tab_id)): Path<(String, String)>,
        Query(query): Query<CaseDetailQuery>,
    ) -> Html<String> {
  11. Inside get_tab, resolve the program and dispatch determination tab to the appropriate renderer:

    let program = query.program
        .as_deref()
        .and_then(Program::from_slug)
        .unwrap_or_default();
    let clients = clients.with_token(&worker.access_token);
    let html = match tab_id.as_str() {
        "household" => render_household_tab(&clients, &household_id, &program).await,
        "income" => render_income_tab(&clients, &household_id).await,
        "determination" => render_determination_tab(&clients, &household_id, &program).await,
        "notices" => render_notices_tab(&clients, &household_id).await,
        "appeals" => render_appeals_tab(&clients, &household_id).await,
        "activity" => render_activity_tab(&clients, &household_id).await,
        "guidance" => render_guidance_tab(&workflows),
        // Program-specific tabs
        "work_requirements" => render_tanf_work_requirements_tab(&clients, &household_id).await,
        "time_limits" => render_tanf_time_limits_tab(&clients, &household_id).await,
        "categories" => render_medicaid_categories_tab(&clients, &household_id).await,
        "authorization" => render_caps_authorization_tab(&clients, &household_id).await,
        "participant" => render_wic_participant_tab(&clients, &household_id).await,
        _ => "<div class='service-error'>Unknown tab</div>".into(),
    };
    Html(html)
  12. Update render_household_tab to accept program: &Program and conditionally skip SNAP-specific certification fetch when program is not SNAP:

    async fn render_household_tab(clients: &ServiceClients, household_id: &str, program: &Program) -> String {
        // ... existing household member + address fetch (unchanged) ...
    
        // Certification info: only for SNAP
        let (cert_type, interim_status) = if *program == Program::Snap {
            // existing renewals fetch logic
        } else {
            ("N/A".into(), "N/A".into())
        };
    
        // ... rest unchanged ...
    }
  13. Update render_determination_tab to accept program: &Program and dispatch to the correct client:

    async fn render_determination_tab(clients: &ServiceClients, household_id: &str, program: &Program) -> String {
        let program_client = clients.program_client(program);
        let determination = program_client
            .get::<Vec<serde_json::Value>>("/v1/determinations?limit=50")
            .await
            .ok()
            .and_then(|dets| {
                dets.into_iter()
                    .find(|d| d["household_id"].as_str() == Some(household_id))
            })
            .map(|d| {
                let id = d["id"].as_str().unwrap_or("").to_owned();
                let status = d["status"].as_str()
                    .or(d["determination_status"].as_str())
                    .unwrap_or("unknown").to_owned();
                let benefit_amount = d["benefit_amount"]
                    .as_str().map(|a| format!("${a}"))
                    .or_else(|| d["benefit_amount"].as_f64().map(|a| format!("${a:.2}")))
                    .or_else(|| {
                        // CAPS copayment
                        d["copayment_weekly_cents"].as_i64()
                            .map(|c| format!("${:.2}/wk copay", c as f64 / 100.0))
                    });
                let determined_at = d["determined_at"].as_str()
                    .or(d["created_at"].as_str())
                    .unwrap_or("").to_owned();
                let ruleset_version = d["program_service_version"].as_str()
                    .or(d["ruleset_version"].as_str())
                    .unwrap_or("").to_owned();
                let signature = d["signature"].as_str()
                    .or(d["jws_token"].as_str())
                    .unwrap_or("");
                let signature_verified = !signature.is_empty();
                let denial_reason = d["denial_reason_codes"].as_array()
                    .map(|codes| codes.iter().filter_map(|c| c.as_str()).collect::<Vec<_>>().join(", "))
                    .or_else(|| d["denial_reasons"].as_array()
                        .map(|codes| codes.iter().filter_map(|c| c.as_str()).collect::<Vec<_>>().join(", ")))
                    .or_else(|| d["denial_reason"].as_str().map(|s| s.to_owned()))
                    .unwrap_or_default();
    
                DeterminationData {
                    id,
                    status,
                    benefit_amount,
                    determined_at,
                    ruleset_version,
                    signature_verified,
                    denial_reason,
                }
            });
    
        let tmpl = TabDeterminationTemplate {
            determination,
            deductions: Vec::new(),
        };
        tmpl.render()
            .unwrap_or_else(|e| format!("<div class='service-error'>{e}</div>"))
    }

Modify services/canopy-web/templates/cases/detail.html:

  1. Replace the hard-coded <span class="badge u-badge-program">SNAP</span> with:

    <span class="badge {{ program_badge_class }}">{{ program_name }}</span>
  2. Update the tab button hx-get to include the program slug:

    hx-get="/cases/{{ household_id }}/tab/{{ tab.id }}?program={{ program_slug }}"
  3. Add a program selector row above or within the summary bar. Use simple anchor links (not htmx) since switching program reloads the full page:

    {# Program selector #}
    <div class="u-flex u-gap-2 u-mb-2">
      <a href="/cases/{{ household_id }}?program=snap"
         class="btn btn-sm {% if program_slug == "snap" %}btn-primary{% else %}btn-ghost{% endif %}">SNAP</a>
      <a href="/cases/{{ household_id }}?program=tanf"
         class="btn btn-sm {% if program_slug == "tanf" %}btn-primary{% else %}btn-ghost{% endif %}">TANF</a>
      <a href="/cases/{{ household_id }}?program=medicaid"
         class="btn btn-sm {% if program_slug == "medicaid" %}btn-primary{% else %}btn-ghost{% endif %}">Medicaid</a>
      <a href="/cases/{{ household_id }}?program=caps"
         class="btn btn-sm {% if program_slug == "caps" %}btn-primary{% else %}btn-ghost{% endif %}">CAPS</a>
      <a href="/cases/{{ household_id }}?program=wic"
         class="btn btn-sm {% if program_slug == "wic" %}btn-primary{% else %}btn-ghost{% endif %}">WIC</a>
    </div>
  4. Conditionally hide the "Cert Period" summary field when program is not SNAP:

    {% if program_slug == "snap" %}
    <div>
      <div class="u-label-wide">Cert Period</div>
      <span class="u-text-base">{{ cert_period }}</span>
    </div>
    {% endif %}

Verification:

cargo nextest run -p canopy-web --lib
cargo clippy -p canopy-web -- -D warnings
cargo xtask dev reload
# Manual: visit /cases/{id}?program=tanf — should show TANF badge, no crash

Step 3: TANF determination tab + work requirements / time limits

Files: services/canopy-web/src/api/case_detail.rs, services/canopy-web/templates/cases/tab_tanf_work_requirements.html (new), services/canopy-web/templates/cases/tab_tanf_time_limits.html (new)

Add data types to case_detail.rs:

pub struct TanfWorkRequirementRow {
    pub person_name: String,
    pub required: bool,
    pub exempt: bool,
    pub exemption_reason: String,
    pub status: String,
    pub sanction_level: Option<i32>,
}

pub struct TanfTimeLimitRow {
    pub person_name: String,
    pub months_used: i32,
    pub federal_limit: i32,
    pub state_limit: Option<i32>,
    pub exempt: bool,
    pub exemption_reason: String,
    pub last_counted_month: String,
}

Add Askama template structs:

#[derive(Template)]
#[template(path = "cases/tab_tanf_work_requirements.html")]
struct TabTanfWorkRequirementsTemplate {
    requirements: Vec<TanfWorkRequirementRow>,
}

#[derive(Template)]
#[template(path = "cases/tab_tanf_time_limits.html")]
struct TabTanfTimeLimitsTemplate {
    limits: Vec<TanfTimeLimitRow>,
}

Add renderer functions:

async fn render_tanf_work_requirements_tab(clients: &ServiceClients, household_id: &str) -> String {
    // Fetch household members to get person_ids
    let members = clients.persons
        .get::<serde_json::Value>(&format!("/v1/households/{household_id}"))
        .await
        .ok()
        .and_then(|h| h["members"].as_array().cloned())
        .unwrap_or_default();

    let mut requirements = Vec::new();
    for m in &members {
        let person_id = m["person_id"].as_str().unwrap_or_default();
        if person_id.is_empty() { continue; }

        let name = clients.persons
            .get::<serde_json::Value>(&format!("/v1/persons/{person_id}"))
            .await
            .ok()
            .map(|p| {
                let first = p["first_name"].as_str().unwrap_or("");
                let last = p["last_name"].as_str().unwrap_or("");
                format!("{first} {last}")
            })
            .unwrap_or_else(|| format!("Person {}", &person_id[..8.min(person_id.len())]));

        match clients.tanf
            .get::<serde_json::Value>(&format!("/v1/work-requirements/{person_id}"))
            .await
        {
            Ok(wr) => {
                requirements.push(TanfWorkRequirementRow {
                    person_name: name,
                    required: wr["required"].as_bool().unwrap_or(false),
                    exempt: wr["exempt"].as_bool().unwrap_or(false),
                    exemption_reason: wr["exemption_reason"].as_str().unwrap_or("").to_owned(),
                    status: wr["status"].as_str().unwrap_or("unknown").to_owned(),
                    sanction_level: wr["sanction_level"].as_i64().map(|v| v as i32),
                });
            }
            Err(e) => {
                warn!("Failed to fetch TANF work requirements for {person_id}: {e}");
            }
        }
    }

    let tmpl = TabTanfWorkRequirementsTemplate { requirements };
    tmpl.render()
        .unwrap_or_else(|e| format!("<div class='service-error'>{e}</div>"))
}

async fn render_tanf_time_limits_tab(clients: &ServiceClients, household_id: &str) -> String {
    let members = clients.persons
        .get::<serde_json::Value>(&format!("/v1/households/{household_id}"))
        .await
        .ok()
        .and_then(|h| h["members"].as_array().cloned())
        .unwrap_or_default();

    let mut limits = Vec::new();
    for m in &members {
        let person_id = m["person_id"].as_str().unwrap_or_default();
        if person_id.is_empty() { continue; }

        let name = clients.persons
            .get::<serde_json::Value>(&format!("/v1/persons/{person_id}"))
            .await
            .ok()
            .map(|p| {
                let first = p["first_name"].as_str().unwrap_or("");
                let last = p["last_name"].as_str().unwrap_or("");
                format!("{first} {last}")
            })
            .unwrap_or_else(|| format!("Person {}", &person_id[..8.min(person_id.len())]));

        match clients.tanf
            .get::<serde_json::Value>(&format!("/v1/time-limits/{person_id}"))
            .await
        {
            Ok(tl) => {
                limits.push(TanfTimeLimitRow {
                    person_name: name,
                    months_used: tl["months_used"].as_i64().unwrap_or(0) as i32,
                    federal_limit: tl["federal_limit_months"].as_i64().unwrap_or(60) as i32,
                    state_limit: tl["state_limit_months"].as_i64().map(|v| v as i32),
                    exempt: tl["exempt"].as_bool().unwrap_or(false),
                    exemption_reason: tl["exemption_reason"].as_str().unwrap_or("").to_owned(),
                    last_counted_month: tl["last_counted_month"].as_str().unwrap_or("").to_owned(),
                });
            }
            Err(e) => {
                warn!("Failed to fetch TANF time limits for {person_id}: {e}");
            }
        }
    }

    let tmpl = TabTanfTimeLimitsTemplate { limits };
    tmpl.render()
        .unwrap_or_else(|e| format!("<div class='service-error'>{e}</div>"))
}

Create services/canopy-web/templates/cases/tab_tanf_work_requirements.html:

{# Tab partial: TANF Work Requirements per 45 CFR Part 261 #}

{% if requirements.is_empty() %}
<div class="card u-empty-state">
  No TANF work requirement data on file for this household
</div>
{% else %}
<h3 class="u-heading-section">Work Requirements</h3>
<table class="data-table u-rounded-md u-overflow-hidden">
  <thead>
    <tr>
      <th>Member</th>
      <th>Required</th>
      <th>Exempt</th>
      <th>Exemption Reason</th>
      <th>Status</th>
      <th>Sanction Level</th>
    </tr>
  </thead>
  <tbody>
    {% for wr in requirements %}
    <tr>
      <td class="u-font-medium">{{ wr.person_name }}</td>
      <td>{% if wr.required %}Yes{% else %}No{% endif %}</td>
      <td>{% if wr.exempt %}✓ Exempt{% else %}Not exempt{% endif %}</td>
      <td class="u-text-muted">{{ wr.exemption_reason }}</td>
      <td>
        <span class="badge {% if wr.status == "compliant" %}u-status-approved{% elif wr.status == "sanctioned" %}u-status-denied{% else %}u-status-neutral{% endif %}">{{ wr.status }}</span>
      </td>
      <td>{% if let Some(level) = wr.sanction_level %}Level {{ level }}{% else %}N/A{% endif %}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>
{% endif %}

Create services/canopy-web/templates/cases/tab_tanf_time_limits.html:

{# Tab partial: TANF Time Limits (federal 60-month) #}

{% if limits.is_empty() %}
<div class="card u-empty-state">
  No TANF time limit data on file for this household
</div>
{% else %}
<h3 class="u-heading-section">Time Limits</h3>
<table class="data-table u-rounded-md u-overflow-hidden">
  <thead>
    <tr>
      <th>Member</th>
      <th>Months Used</th>
      <th>Federal Limit</th>
      <th>State Limit</th>
      <th>Exempt</th>
      <th>Last Counted</th>
    </tr>
  </thead>
  <tbody>
    {% for tl in limits %}
    <tr>
      <td class="u-font-medium">{{ tl.person_name }}</td>
      <td>
        <span class="u-font-bold {% if tl.months_used >= tl.federal_limit %}u-text-error{% endif %}">{{ tl.months_used }}</span>
        / {{ tl.federal_limit }}
      </td>
      <td>{{ tl.federal_limit }} months</td>
      <td>{% if let Some(sl) = tl.state_limit %}{{ sl }} months{% else %}N/A{% endif %}</td>
      <td>{% if tl.exempt %}✓ {{ tl.exemption_reason }}{% else %}No{% endif %}</td>
      <td class="u-text-muted">{{ tl.last_counted_month }}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>
{% endif %}

Verification:

cargo nextest run -p canopy-web --lib
cargo xtask dev reload
# Manual: visit /cases/{id}?program=tanf → click "Work Requirements" tab

Step 4: Medicaid determination tab + COA cascade

Files: services/canopy-web/src/api/case_detail.rs, services/canopy-web/templates/cases/tab_medicaid_categories.html (new)

Add data types to case_detail.rs:

pub struct MedicaidCategoryRow {
    pub coa_code: String,
    pub coa_track: String,
    pub eligible: bool,
    pub fpl_percentage: String,
    pub fpl_threshold: String,
    pub income_amount: String,
    pub denial_reason: String,
    pub evaluation_order: i32,
}

Add Askama template struct:

#[derive(Template)]
#[template(path = "cases/tab_medicaid_categories.html")]
struct TabMedicaidCategoriesTemplate {
    categories: Vec<MedicaidCategoryRow>,
    assigned_coa: String,
    assigned_track: String,
}

Add renderer:

async fn render_medicaid_categories_tab(clients: &ServiceClients, household_id: &str) -> String {
    // First find the determination ID for this household
    let det = clients.medicaid
        .get::<Vec<serde_json::Value>>("/v1/determinations?limit=50")
        .await
        .ok()
        .and_then(|dets| {
            dets.into_iter()
                .find(|d| d["household_id"].as_str() == Some(household_id))
        });

    let (categories, assigned_coa, assigned_track) = match det {
        Some(ref d) => {
            let det_id = d["id"].as_str().unwrap_or_default();
            let assigned_coa = d["assigned_coa"].as_str().unwrap_or("none").to_owned();
            let assigned_track = d["assigned_coa_track"].as_str().unwrap_or("").to_owned();

            let cats = clients.medicaid
                .get::<Vec<serde_json::Value>>(&format!("/v1/determinations/{det_id}/categories"))
                .await
                .ok()
                .unwrap_or_default()
                .into_iter()
                .map(|c| MedicaidCategoryRow {
                    coa_code: c["coa_code"].as_str().unwrap_or("").to_owned(),
                    coa_track: c["coa_track"].as_str().unwrap_or("").to_owned(),
                    eligible: c["eligible"].as_bool().unwrap_or(false),
                    fpl_percentage: c["fpl_percentage"].as_str()
                        .or_else(|| c["fpl_percentage"].as_f64().map(|v| format!("{v:.0}")).as_deref().map(|_| ""))
                        .unwrap_or("").to_owned(),
                    fpl_threshold: c["fpl_threshold"].as_str().unwrap_or("").to_owned(),
                    income_amount: c["income_amount"].as_str().unwrap_or("").to_owned(),
                    denial_reason: c["denial_reason"].as_str().unwrap_or("").to_owned(),
                    evaluation_order: c["evaluation_order"].as_i64().unwrap_or(0) as i32,
                })
                .collect();

            (cats, assigned_coa, assigned_track)
        }
        None => (Vec::new(), "N/A".into(), String::new()),
    };

    let tmpl = TabMedicaidCategoriesTemplate { categories, assigned_coa, assigned_track };
    tmpl.render()
        .unwrap_or_else(|e| format!("<div class='service-error'>{e}</div>"))
}
NOTE
The fpl_percentage field in MedicaidEligibleCategory is Option<Decimal>, which serializes as a JSON number or string. Handle both.

Create services/canopy-web/templates/cases/tab_medicaid_categories.html:

{# Tab partial: Medicaid COA Cascade — EE15 evaluation hierarchy #}

<div class="card u-mb-4">
  <div class="u-flex u-gap-4 u-items-center">
    <div>
      <div class="u-label">Assigned COA</div>
      <div class="u-text-lg u-font-bold">{{ assigned_coa }}</div>
    </div>
    <div>
      <div class="u-label">Track</div>
      <div class="u-font-medium">{{ assigned_track }}</div>
    </div>
  </div>
</div>

{% if categories.is_empty() %}
<div class="card u-empty-state">
  No Medicaid COA evaluation data on file for this household
</div>
{% else %}
<h3 class="u-heading-section">Category Evaluation Cascade</h3>
<table class="data-table u-rounded-md u-overflow-hidden">
  <thead>
    <tr>
      <th>#</th>
      <th>COA Code</th>
      <th>Track</th>
      <th>Eligible</th>
      <th>FPL %</th>
      <th>Threshold</th>
      <th>Income</th>
      <th>Denial Reason</th>
    </tr>
  </thead>
  <tbody>
    {% for cat in categories %}
    <tr{% if cat.eligible %} class="u-row-highlight"{% endif %}>
      <td class="u-text-muted">{{ cat.evaluation_order }}</td>
      <td class="u-font-medium">{{ cat.coa_code }}</td>
      <td>
        <span class="badge u-status-neutral u-text-xs">{{ cat.coa_track }}</span>
      </td>
      <td>
        {% if cat.eligible %}
        <span class="badge u-status-approved">✓ Eligible</span>
        {% else %}
        <span class="badge u-status-denied">✗</span>
        {% endif %}
      </td>
      <td>{{ cat.fpl_percentage }}</td>
      <td>{{ cat.fpl_threshold }}</td>
      <td>{{ cat.income_amount }}</td>
      <td class="u-text-muted u-text-sm">{{ cat.denial_reason }}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>
{% endif %}

Verification:

cargo nextest run -p canopy-web --lib
cargo xtask dev reload
# Manual: visit /cases/{id}?program=medicaid → click "COA Cascade" tab

Step 5: CAPS determination tab + authorization

Files: services/canopy-web/src/api/case_detail.rs, services/canopy-web/templates/cases/tab_caps_authorization.html (new)

Add data types to case_detail.rs:

pub struct CapsAuthorizationData {
    pub child_name: String,
    pub provider_id: String,
    pub status: String,
    pub weekly_hours: i32,
    pub rate_per_hour: String,
    pub copayment_weekly: String,
    pub effective_date: String,
    pub end_date: String,
}

Add Askama template struct:

#[derive(Template)]
#[template(path = "cases/tab_caps_authorization.html")]
struct TabCapsAuthorizationTemplate {
    authorization: Option<CapsAuthorizationData>,
    income_eligible: bool,
    activity_eligible: bool,
    age_eligible: bool,
}

Add renderer. Because canopy-caps does NOT have a GET /v1/determinations list endpoint, we fetch the determination ID from the orchestrator or use a fallback strategy. For now, the tab will show an empty state with an explanatory message unless the determination ID is available through query chaining from the determination tab:

async fn render_caps_authorization_tab(clients: &ServiceClients, household_id: &str) -> String {
    // canopy-caps only has GET /determinations/{id}, no list endpoint.
    // We attempt to find a CAPS determination via the eligibility orchestrator's
    // combined results, which include determination IDs per program.
    let orchestrator_result = clients.eligibility
        .get::<serde_json::Value>(&format!("/v1/eligibility/{household_id}"))
        .await
        .ok();

    let caps_det_id = orchestrator_result
        .as_ref()
        .and_then(|r| r["caps"]["determination_id"].as_str());

    let (authorization, income_eligible, activity_eligible, age_eligible) = match caps_det_id {
        Some(det_id) => {
            match clients.caps
                .get::<serde_json::Value>(&format!("/v1/determinations/{det_id}"))
                .await
            {
                Ok(det) => {
                    let ie = det["income_eligible"].as_bool().unwrap_or(false);
                    let ae = det["activity_eligible"].as_bool().unwrap_or(false);
                    let age = det["age_eligible"].as_bool().unwrap_or(false);

                    // Fetch authorization if present
                    // The authorization ID is not in the determination; we cannot
                    // list authorizations. Show determination-level data only.
                    (None, ie, ae, age)
                }
                Err(e) => {
                    warn!("Failed to fetch CAPS determination {det_id}: {e}");
                    (None, false, false, false)
                }
            }
        }
        None => (None, false, false, false),
    };

    let tmpl = TabCapsAuthorizationTemplate {
        authorization,
        income_eligible,
        activity_eligible,
        age_eligible,
    };
    tmpl.render()
        .unwrap_or_else(|e| format!("<div class='service-error'>{e}</div>"))
}

Create services/canopy-web/templates/cases/tab_caps_authorization.html:

{# Tab partial: CAPS Authorization — childcare eligibility & provider auth #}

<h3 class="u-heading-section">Eligibility Gates</h3>
<div class="card u-mb-4 u-grid-cols-3 u-gap-4">
  <div>
    <div class="u-label">Income Eligible</div>
    <div class="u-font-medium">{% if income_eligible %}✓ Yes{% else %}✗ No{% endif %}</div>
  </div>
  <div>
    <div class="u-label">Activity Eligible</div>
    <div class="u-font-medium">{% if activity_eligible %}✓ Yes{% else %}✗ No{% endif %}</div>
  </div>
  <div>
    <div class="u-label">Age Eligible</div>
    <div class="u-font-medium">{% if age_eligible %}✓ Yes{% else %}✗ No{% endif %}</div>
  </div>
</div>

{% if authorization.is_some() %}
{% let auth = authorization.as_ref().unwrap() %}
<h3 class="u-heading-section">Provider Authorization</h3>
<div class="card">
  <div class="u-grid-cols-2 u-gap-4">
    <div>
      <div class="u-label">Child</div>
      <div class="u-font-medium">{{ auth.child_name }}</div>
    </div>
    <div>
      <div class="u-label">Provider</div>
      <div class="u-font-medium">{{ auth.provider_id }}</div>
    </div>
    <div>
      <div class="u-label">Weekly Hours</div>
      <div class="u-font-medium">{{ auth.weekly_hours }}</div>
    </div>
    <div>
      <div class="u-label">Rate/Hour</div>
      <div class="u-font-medium">{{ auth.rate_per_hour }}</div>
    </div>
    <div>
      <div class="u-label">Copayment (Weekly)</div>
      <div class="u-font-bold">{{ auth.copayment_weekly }}</div>
    </div>
    <div>
      <div class="u-label">Status</div>
      <span class="badge u-status-neutral">{{ auth.status }}</span>
    </div>
    <div>
      <div class="u-label">Effective</div>
      <div class="u-text-muted">{{ auth.effective_date }}</div>
    </div>
    <div>
      <div class="u-label">End</div>
      <div class="u-text-muted">{{ auth.end_date }}</div>
    </div>
  </div>
</div>
{% else %}
<div class="card u-empty-state">
  No CAPS authorization data available. CAPS determinations are accessed by ID only;
  a list endpoint is planned for a future release.
</div>
{% endif %}

Verification:

cargo nextest run -p canopy-web --lib
cargo xtask dev reload
# Manual: visit /cases/{id}?program=caps → click "Authorization" tab

Step 6: WIC determination tab + participant

Files: services/canopy-web/src/api/case_detail.rs, services/canopy-web/templates/cases/tab_wic_participant.html (new)

Add data types to case_detail.rs:

pub struct WicParticipantData {
    pub person_name: String,
    pub category: String,
    pub food_package: String,
    pub certification_start: String,
    pub certification_end: String,
    pub status: String,
    pub categorical_eligible: bool,
    pub income_eligible: bool,
    pub adjunctive_eligible: bool,
    pub adjunctive_program: String,
    pub nutritional_risk_documented: bool,
}

Add Askama template struct:

#[derive(Template)]
#[template(path = "cases/tab_wic_participant.html")]
struct TabWicParticipantTemplate {
    participant: Option<WicParticipantData>,
}

Add renderer (same orchestrator pattern as CAPS):

async fn render_wic_participant_tab(clients: &ServiceClients, household_id: &str) -> String {
    // canopy-wic only has GET /determinations/{id}, no list endpoint.
    let orchestrator_result = clients.eligibility
        .get::<serde_json::Value>(&format!("/v1/eligibility/{household_id}"))
        .await
        .ok();

    let wic_det_id = orchestrator_result
        .as_ref()
        .and_then(|r| r["wic"]["determination_id"].as_str());

    let participant = match wic_det_id {
        Some(det_id) => {
            clients.wic
                .get::<serde_json::Value>(&format!("/v1/determinations/{det_id}"))
                .await
                .ok()
                .map(|d| {
                    let person_id = d["person_id"].as_str().unwrap_or("").to_owned();
                    // Attempt to resolve person name
                    // NOTE: this is sync JSON mapping; person name is fetched below
                    WicParticipantData {
                        person_name: format!("Person {}", &person_id[..8.min(person_id.len())]),
                        category: d["participant_category"].as_str().unwrap_or("").to_owned(),
                        food_package: d["food_package"].as_str().unwrap_or("").to_owned(),
                        certification_start: d["effective_date"].as_str().unwrap_or("").to_owned(),
                        certification_end: d["end_date"].as_str().unwrap_or("").to_owned(),
                        status: d["determination_status"].as_str().unwrap_or("unknown").to_owned(),
                        categorical_eligible: d["categorical_eligible"].as_bool().unwrap_or(false),
                        income_eligible: d["income_eligible"].as_bool().unwrap_or(false),
                        adjunctive_eligible: d["adjunctive_eligible"].as_bool().unwrap_or(false),
                        adjunctive_program: d["adjunctive_program"].as_str().unwrap_or("").to_owned(),
                        nutritional_risk_documented: d["nutritional_risk_documented"].as_bool().unwrap_or(false),
                    }
                })
        }
        None => None,
    };

    let tmpl = TabWicParticipantTemplate { participant };
    tmpl.render()
        .unwrap_or_else(|e| format!("<div class='service-error'>{e}</div>"))
}

Create services/canopy-web/templates/cases/tab_wic_participant.html:

{# Tab partial: WIC Participant — certification, food package, risk assessment #}

{% if participant.is_some() %}
{% let p = participant.as_ref().unwrap() %}

<h3 class="u-heading-section">Eligibility Gates</h3>
<div class="card u-mb-4 u-grid-cols-4 u-gap-4">
  <div>
    <div class="u-label">Categorical</div>
    <div>{% if p.categorical_eligible %}✓ Yes{% else %}✗ No{% endif %}</div>
  </div>
  <div>
    <div class="u-label">Income</div>
    <div>{% if p.income_eligible %}✓ Yes{% else %}✗ No{% endif %}</div>
  </div>
  <div>
    <div class="u-label">Adjunctive</div>
    <div>{% if p.adjunctive_eligible %}✓ {{ p.adjunctive_program }}{% else %}✗ No{% endif %}</div>
  </div>
  <div>
    <div class="u-label">Nutritional Risk</div>
    <div>{% if p.nutritional_risk_documented %}✓ Documented{% else %}⚠ Not documented{% endif %}</div>
  </div>
</div>

<h3 class="u-heading-section">Participant Details</h3>
<div class="card">
  <div class="u-grid-cols-2 u-gap-4">
    <div>
      <div class="u-label">Participant</div>
      <div class="u-font-medium">{{ p.person_name }}</div>
    </div>
    <div>
      <div class="u-label">Category</div>
      <div class="u-font-medium">{{ p.category }}</div>
    </div>
    <div>
      <div class="u-label">Food Package</div>
      <div class="u-font-medium">{{ p.food_package }}</div>
    </div>
    <div>
      <div class="u-label">Status</div>
      <span class="badge {% if p.status == "eligible" %}u-status-approved{% elif p.status == "denied" %}u-status-denied{% else %}u-status-neutral{% endif %}">{{ p.status }}</span>
    </div>
    <div>
      <div class="u-label">Certification Period</div>
      <div>{{ p.certification_start }} → {{ p.certification_end }}</div>
    </div>
  </div>
</div>

{% else %}
<div class="card u-empty-state">
  No WIC participant data available. WIC determinations are accessed by ID only;
  a list endpoint is planned for a future release.
</div>
{% endif %}

Verification:

cargo nextest run -p canopy-web --lib
cargo xtask dev reload
# Manual: visit /cases/{id}?program=wic → click "Participant" tab

Step 7: Unit tests + Playwright E2E + documentation

Files: services/canopy-web/src/program.rs (tests already added in Step 1), services/canopy-web/src/clients.rs (test updates in Step 1), tests/e2e/specs/case-detail.spec.ts, tests/e2e/specs/multi-program.spec.ts (new), .claude/docs/services.md, CHANGELOG.adoc

Unit tests (Rust)

The unit tests from Steps 1 (program.rs + clients.rs) should already be in place. Verify they all pass:

cargo nextest run -p canopy-web --lib

Expected additions:

  • program.rs: 7 tests (slug round-trip, unknown slug, default, tab counts per program)

  • clients.rs: updated assertions in existing 2 tests + no new test files needed

Playwright E2E tests

Create tests/e2e/specs/multi-program.spec.ts:

// SPDX-License-Identifier: AGPL-3.0-or-later
import { test, expect } from '@playwright/test';
import { findApproved } from '../lib/seed';

const approved = findApproved();

test.describe('multi-program case detail', () => {
  test.skip(!approved, 'No approved determination in seed data');

  test('default program is SNAP', async ({ page }) => {
    await page.goto(`/cases/${approved!.householdId}`);
    await expect(page.locator('text=SNAP')).toBeVisible();
  });

  test('program selector renders all 5 programs', async ({ page }) => {
    await page.goto(`/cases/${approved!.householdId}`);
    for (const prog of ['SNAP', 'TANF', 'Medicaid', 'CAPS', 'WIC']) {
      await expect(page.locator(`a:has-text("${prog}")`)).toBeVisible();
    }
  });

  test('switching to TANF shows TANF badge', async ({ page }) => {
    await page.goto(`/cases/${approved!.householdId}?program=tanf`);
    // Should show TANF badge in summary bar
    const badge = page.locator('.badge').first();
    await expect(badge).toContainText('TANF');
  });

  test('TANF tab list includes Work Requirements', async ({ page }) => {
    await page.goto(`/cases/${approved!.householdId}?program=tanf`);
    await expect(page.locator('#tab-work_requirements')).toBeVisible();
  });

  test('Medicaid tab list includes COA Cascade', async ({ page }) => {
    await page.goto(`/cases/${approved!.householdId}?program=medicaid`);
    await expect(page.locator('#tab-categories')).toBeVisible();
  });

  test('CAPS tab list includes Authorization', async ({ page }) => {
    await page.goto(`/cases/${approved!.householdId}?program=caps`);
    await expect(page.locator('#tab-authorization')).toBeVisible();
  });

  test('WIC tab list includes Participant', async ({ page }) => {
    await page.goto(`/cases/${approved!.householdId}?program=wic`);
    await expect(page.locator('#tab-participant')).toBeVisible();
  });

  test('unknown program defaults to SNAP', async ({ page }) => {
    await page.goto(`/cases/${approved!.householdId}?program=invalid`);
    await expect(page.locator('text=SNAP')).toBeVisible();
  });

  test('tab htmx requests preserve program param', async ({ page }) => {
    await page.goto(`/cases/${approved!.householdId}?program=tanf`);
    const incomeTab = page.locator('#tab-income');
    const href = await incomeTab.getAttribute('hx-get');
    expect(href).toContain('program=tanf');
  });
});

Update tests/e2e/specs/case-detail.spec.ts:

  • The existing test 'shows SNAP program badge' should continue to pass unchanged (default is SNAP).

Documentation updates

.claude/docs/services.md:

  • Update canopy-web route count: 8 pages → 8 pages (no new page routes, only new tab partials served via existing /cases/{household_id}/tab/{tab_id} route).

  • Add note: "Multi-program support via ?program= query parameter. Program-specific tabs: TANF (work_requirements, time_limits), Medicaid (categories), CAPS (authorization), WIC (participant)."

CHANGELOG.adoc:

  • Add under == Unreleased:

    === Added
    * canopy-web: Multi-program case detail — TANF, Medicaid, CAPS, WIC views with per-program tabs and graceful degradation
    * canopy-web: `Program` enum with slug dispatch, `ServiceClients::program_client()`, 4 new upstream clients
    * canopy-web: Program selector UI on case detail page
    * canopy-web: TANF work requirements + time limits tabs
    * canopy-web: Medicaid COA cascade tab
    * canopy-web: CAPS authorization tab
    * canopy-web: WIC participant tab

Verification:

cargo nextest run -p canopy-web --lib
cargo clippy -p canopy-web -- -D warnings
cargo xtask e2e

Files Touched

File Change

services/canopy-web/src/program.rs

New file: Program enum with from_slug(), slug(), display_name(), badge_class(), tabs(), Default impl, 7 unit tests

services/canopy-web/src/clients.rs

Add tanf, medicaid, caps, wic fields to ServiceClients; add program_client() method; update from_env() with 4 new env vars; update with_token() for 12 clients; update 2 existing tests

services/canopy-web/src/main.rs

Add mod program;

services/canopy-web/src/api/case_detail.rs

Add CaseDetailQuery struct; add Query extractor to get_case_detail and get_tab; remove all_tabs(); add program_slug/program_name/program_badge_class to template; dispatch determination to program_client(); add program param to render_household_tab/render_determination_tab; add 5 new renderer functions + 5 new data types + 5 new template structs for TANF/Medicaid/CAPS/WIC program-specific tabs

services/canopy-web/templates/cases/detail.html

Add program selector row; replace hard-coded "SNAP" badge with template variable; add ?program= to tab hx-get URLs; conditionally hide cert period for non-SNAP

services/canopy-web/templates/cases/tab_tanf_work_requirements.html

New template: TANF work requirements table

services/canopy-web/templates/cases/tab_tanf_time_limits.html

New template: TANF time limits table

services/canopy-web/templates/cases/tab_medicaid_categories.html

New template: Medicaid COA cascade table with assigned COA header

services/canopy-web/templates/cases/tab_caps_authorization.html

New template: CAPS eligibility gates + provider authorization card

services/canopy-web/templates/cases/tab_wic_participant.html

New template: WIC eligibility gates + participant details + food package

docker-compose.yml

Add 4 env vars to canopy-web service: CANOPY_WEBTANF_URL, CANOPY_WEBMEDICAID_URL, CANOPY_WEBCAPS_URL, CANOPY_WEBWIC_URL

tests/e2e/specs/multi-program.spec.ts

New E2E test file: 9 tests for program switching, tab presence, badge display, query param preservation

tests/e2e/specs/case-detail.spec.ts

No changes needed (existing SNAP tests pass via default behavior)

.claude/docs/services.md

Update canopy-web description with multi-program note

CHANGELOG.adoc

Add multi-program expansion entries under Unreleased

Verification

  1. cargo nextest run -p canopy-web --lib — all unit tests pass (including 7 new program.rs tests + updated clients.rs tests)

  2. cargo clippy -p canopy-web — -D warnings — no warnings

  3. cargo xtask dev reload — canopy-web restarts with 4 new upstream clients

  4. cargo xtask e2e — all Playwright tests pass including 9 new multi-program tests

  5. Manual: navigate to /cases/{household_id}?program=tanf — TANF badge shown, Work Requirements and Time Limits tabs appear

  6. Manual: navigate to /cases/{household_id}?program=medicaid — Medicaid badge, COA Cascade tab appears

  7. Manual: navigate to /cases/{household_id}?program=caps — CAPS badge, Authorization tab appears

  8. Manual: navigate to /cases/{household_id}?program=wic — WIC badge, Participant tab appears

  9. Manual: when canopy-tanf is stopped, visiting ?program=tanf determination tab shows graceful error (empty state) rather than 500

Documentation Updates

  • .claude/docs/services.md — update canopy-web section with multi-program support, new env vars, program-specific tab list

  • CHANGELOG.adoc — entry under == Unreleased

  • .claude/CLAUDE.md — update canopy-web route description in Feature Status table (if route count changes)

  • docs/modules/ROOT/pages/services/canopy-web.adoc — add multi-program architecture section, program selector screenshot

Follow-up Work (out of scope)

  • Add GET /v1/determinations?household_id=X list endpoints to canopy-caps and canopy-wic so the determination tab can find determinations without the orchestrator

  • Program-specific action handlers (TANF work activity logging, WIC nutritional risk assessment creation) in canopy-web

  • Program badge CSS classes in canopy-web.css — cosmetic polish, not load-bearing for any acceptance criteria; deferred indefinitely.

  • Dashboard stats from TANF/Medicaid/CAPS/WIC services

  • Cross-program summary view (show all programs' statuses for a household simultaneously)

Tracked follow-ups (filed 2026-05-04 during PI sweep):

  • #391 — canopy-caps/canopy-wic determination list endpoints

  • #392 — Program-specific action handlers

  • #393 — Cross-program dashboard stats

  • #394 — Cross-program summary view per household

Edit this page · default