Skip to content

fix(desktop): hash spawn config as the env receives it, not raw record fields#1621

Merged
wesbillman merged 1 commit into
mainfrom
pinky/spawn-hash-normalization
Jul 8, 2026
Merged

fix(desktop): hash spawn config as the env receives it, not raw record fields#1621
wesbillman merged 1 commit into
mainfrom
pinky/spawn-hash-normalization

Conversation

@wesbillman

Copy link
Copy Markdown
Collaborator

Follow-up to #1602 (restart-required badge), parked behind the spawn_hash persona-resolution rewrite that landed in #1618.

Defect

The spawn-config hash digested raw record values while the spawn env receives normalized ones, so three field edits badged running agents even when a restart would run the exact same process:

Field Spawn env behavior Hash behavior (before)
respond_to_allowlist BUZZ_ACP_RESPOND_TO_ALLOWLIST set only in allowlist mode, from validate_respond_to_allowlist output (trim/lowercase/dedup) raw list, hashed in every mode
max_turn_duration_seconds BUZZ_ACP_MAX_TURN_DURATION written with default filled in raw OptionNoneSome(default)
mcp_toolsets BUZZ_TOOLSETS falls back to the default set raw OptionNone ≠ explicit default

Equal spawned env + unequal raw field = spurious badge.

Fix

Hash what the env receives:

  • Allowlist: hashed only when respond_to == Allowlist, normalized via the same validate_respond_to_allowlist spawn uses. On validation error the raw list is hashed — spawn rejects invalid lists, so a stamped hash always came from a valid one and the invalid edit correctly compares unequal (badge = honest "restart would change/fail" signal).
  • Max turn duration: hashed with DEFAULT_AGENT_MAX_TURN_DURATION_SECONDS filled in, matching the env write.
  • Toolsets: hashed through a new DEFAULT_MCP_TOOLSETS const in types.rs, which also replaces the string literal in runtime.rs's spawn path — hash and env now share one source of truth and cannot drift.

respond_to mode itself stays hashed unconditionally: toggling modes is spawn-visible and must badge.

Tests

+8 in spawn_hash/tests.rs (17 total): equivalence AND sensitivity in both directions for all three fields — dormant-list edits under owner-only don't badge, real allowlist content edits do; normalization-equivalent edits don't, content changes do; None ↔ explicit default doesn't, non-default values do.

Full desktop-tauri suite: 1048 passed / 0 failed. Clippy --all-targets clean, fmt clean, file-size check clean.

Cross-reviewed and approved by Brain in #centralize-personas-and-agents (verified against build_respond_to_env and the runtime.rs env writes; independently ran the suite).

…d fields

The restart-required badge compared raw record values while the spawn env
gets normalized ones, so three edits badged running agents that a restart
would not change:

- respond_to_allowlist: spawn normalizes (trim/lowercase/dedup) and only
  sets BUZZ_ACP_RESPOND_TO_ALLOWLIST in allowlist mode; the hash digested
  the raw list in every mode. Now hashed normalized, and only when
  respond_to == allowlist.
- max_turn_duration_seconds: spawn fills the default into
  BUZZ_ACP_MAX_TURN_DURATION, so None and an explicit default are the same
  spawned value. Now hashed with the default filled in.
- mcp_toolsets: same default-fallback (BUZZ_TOOLSETS); now hashed through
  the new DEFAULT_MCP_TOOLSETS constant, which also replaces the string
  literal in the spawn path so the two can't drift.

Follow-up to #1602 (parked behind the spawn_hash persona-resolution
rewrite that landed in #1618).

Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
@wesbillman wesbillman merged commit f0eb4ec into main Jul 8, 2026
45 of 47 checks passed
@wesbillman wesbillman deleted the pinky/spawn-hash-normalization branch July 8, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant