Repository navigation
Python: Improve atomic writes for Memory and Todos - #9412
westey (westey-m) merged 2 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Verified stream-initialization failures double-close the descriptor, masking the original error and leaving temporary files behind.
1 open finding
What changed in this PR
Centralizes atomic file writes for Python memory and todo storage.
Changes:
- Adds a shared helper with unique temporary filenames and exclusive creation.
- Migrates both stores and documents storage-directory trust requirements.
- Updates failure tests and adds symbolic-link protection coverage.
| File | Description |
|---|---|
python/packages/core/tests/core/test_harness_memory.py |
Updates shared-helper patching and cleanup assertions. |
python/packages/core/tests/core/test_filesystem.py |
Tests rejection of preexisting symbolic links. |
python/packages/core/AGENTS.md |
Documents the filesystem helper’s expanded role. |
python/packages/core/agent_framework/_harness/_todo.py |
Uses shared atomic writes and documents directory trust. |
python/packages/core/agent_framework/_harness/_memory.py |
Removes duplicate implementation and documents directory trust. |
python/packages/core/agent_framework/_filesystem.py |
Implements shared atomic text writes. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): 4c0a977b9052
Model: gpt-5.6-sol
Overview
This PR centralizes the Memory and Todo atomic-write implementations in a private filesystem helper while preserving the stores' serialization and public API contracts. UUID-based sibling names, exclusive creation, atomic replacement, and failure-path tests guard the primary corruption and temporary-file redirection risks. No Critical, High, or Medium issue remains after reconciliation.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

Motivation & Context
Both memory and todos had their own copy of atomic write capabilies
Description & Review Guide
Centralize functionality with some small improvements.
Related Issue
Fixes #
AI Assistance
AI assistance details:
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.