Skip to content

Profile cache never reloads within a process #24

@willwashburn

Description

@willwashburn

Problem

crates/wash/src/profile.rs:77 — the active profile is stored in a OnceLock<Profile> and loaded on first access. There's no path to refresh it. The MCP server lives for the entire session.

This works today because no aggregator writes profiles yet (per the wash#13 plan). When that lands, a profile written mid-session won't be picked up until the next CLI restart. That undermines the adaptive layer's whole point.

Proposed fix

Two reasonable options:

  1. TTL refresh. Wrap the cached profile in a struct holding (Profile, Instant), refresh on access if older than ~30s. Cheap, no IPC.
  2. Mtime watch. Stat the profile file on each access; reload only when mtime moves. Slightly more work per access but always fresh.

Option 2 is probably the right one — profile reads are infrequent (per tool call), and we already stat files in the Read mtime cache.

Either way, cached() needs to switch from OnceLock to a Mutex<Option<...>> or RwLock<...>. The byte-stable tools/list invariant must be preserved (test in tests/mcp_stdio.rs).

Files

  • crates/wash/src/profile.rscached(), get(), and load_active().

Note

The RELAYWASH_PROFILE_PATH test override should keep working — easy to honor in the new path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions