Skip to content

Document files_manager deferred-write semantics and subprocess implications#1720

Merged
nathanjmcdougall merged 2 commits intomainfrom
copilot/add-agent-config-docs-files-manager
Apr 1, 2026
Merged

Document files_manager deferred-write semantics and subprocess implications#1720
nathanjmcdougall merged 2 commits intomainfrom
copilot/add-agent-config-docs-files-manager

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

Agents misdiagnosed test failures (#1652) because they didn't understand that files_manager defers all writes until context exit — subprocesses can't see uncommitted in-memory changes.

  • files_manager() docstring (_config_file.py): Explains locking on entry, lazy reads, atomic flush on exit, and the subprocess visibility constraint.
  • FileManager class docstring (_file/manager.py): Adds a numbered lifecycle (Enter → Read → Commit → Exit) with explicit subprocess guidance.
  • usethis-python-test skill (SKILL.md v1.1): New "Using files_manager in tests" section with correct/incorrect patterns and a decision rule.

Key pattern the skill now teaches:

# Correct: flush to disk before subprocess reads config
with change_cwd(tmp_path), files_manager():
    use_ruff()

call_uv_subprocess(["run", "ruff", "check", "."], change_toml=False)
# Wrong: subprocess runs inside context, config not yet on disk
with change_cwd(tmp_path), files_manager():
    use_ruff()
    call_uv_subprocess(["run", "ruff", "check", "."], change_toml=False)

…idance

- Expanded files_manager() docstring to explain locking, deferred reads,
  atomic writes on exit, and subprocess implications
- Expanded FileManager class docstring with a lifecycle description and
  subprocess guidance
- Added "Using files_manager in tests" section to usethis-python-test
  skill with concrete examples of correct/incorrect patterns

Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/3a6cfc9a-bb96-4d0f-bfab-5f9fb43ef279

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title [WIP] Add agent config and documentation for files manager Document files_manager deferred-write semantics and subprocess implications Apr 1, 2026
Copilot AI requested a review from nathanjmcdougall April 1, 2026 11:34
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review April 1, 2026 11:37
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 1, 2026

Merging this PR will not alter performance

✅ 2 untouched benchmarks


Comparing copilot/add-agent-config-docs-files-manager (73c4237) with main (e057ee9)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (a8b9e7a) during the generation of this report, so e057ee9 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@nathanjmcdougall nathanjmcdougall merged commit b0c8531 into main Apr 1, 2026
20 checks passed
@nathanjmcdougall nathanjmcdougall deleted the copilot/add-agent-config-docs-files-manager branch April 1, 2026 11:47
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 config & docs to explain how files_manager works e.g. in a test contest

2 participants