Skip to content

fix: use targeted JSON patching in sync_daemon_session_status#345

Merged
Wirasm merged 2 commits into
mainfrom
kild/321-agent-status-resave
Feb 11, 2026
Merged

fix: use targeted JSON patching in sync_daemon_session_status#345
Wirasm merged 2 commits into
mainfrom
kild/321-agent-status-resave

Conversation

@Wirasm

@Wirasm Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • sync_daemon_session_status() was using save_session_to_file() which round-trips through the Session struct, silently dropping fields from newer binary versions (e.g., task_list_id)
  • Same class of bug fixed in agent_status.rs by PR feat: transfer task list across agent sessions via CLAUDE_CODE_TASK_LIST_ID #319, just in a different code path (kild list/kild status daemon sync)
  • Replaced full-struct serialization with targeted JSON field patching via new patch_session_json_fields() helper

Changes

File Change
crates/kild-core/src/sessions/persistence.rs Add patch_session_json_fields() for atomic multi-field JSON patching
crates/kild-core/src/sessions/handler.rs Replace save_session_to_file() with field-level patches in sync_daemon_session_status
crates/kild-core/src/sessions/persistence.rs Add test verifying unknown fields survive multi-field patching

Testing

  • cargo fmt --check passes
  • cargo clippy --all -- -D warnings passes
  • cargo test --all passes (all 1243 tests)
  • New test test_patch_session_json_fields_preserves_unknown_fields validates the fix

Validation

cargo fmt --check && cargo clippy --all -- -D warnings && cargo test --all

Fixes #321

@Wirasm

Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner Author

Self-Review

Summary

Clean, focused fix that correctly addresses the root cause: sync_daemon_session_status() was using save_session_to_file() which round-trips through the Session struct, dropping fields unknown to the current binary version. Replaced with targeted JSON field patching, matching the pattern established in PR #319 for agent_status.rs.

Findings

Strengths

  • Root cause correctly identified and fixed (same class of bug as agent_status)
  • patch_session_json_fields() mirrors patch_session_json_field() exactly
  • Atomic file write preserved (single read + write for multiple fields)
  • In-memory session updated unconditionally, matching original behavior
  • Comment explains the "why" clearly

Noted (non-blocking)

  • patch_session_json_fields() shares the non-object JSON error path with patch_session_json_field() which already has test coverage - no additional test needed per YAGNI
  • Other save_session_to_file() call sites (create, open, stop, complete) are safe - they write the full Session on initial creation where no unknown fields can exist

Security

  • No security concerns

Checklist

@Wirasm Wirasm force-pushed the kild/321-agent-status-resave branch from dccde75 to 1e99aad Compare February 11, 2026 09:35
sync_daemon_session_status() was using save_session_to_file() which
round-trips through the Session struct, silently dropping fields from
newer binary versions (e.g., task_list_id). This is the same class of
bug fixed in agent_status.rs by PR #319.

Changes:
- Add patch_session_json_fields() for atomic multi-field JSON patching
- Replace save_session_to_file() with field-level patches in sync_daemon_session_status
- Add test verifying unknown fields survive multi-field patching

Fixes #321
@Wirasm Wirasm force-pushed the kild/321-agent-status-resave branch from 1e99aad to 082d930 Compare February 11, 2026 09:50
@Wirasm Wirasm merged commit f7e40fc into main Feb 11, 2026
1 check passed
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.

agent-status full session re-save can drop fields from newer binary versions

1 participant