Skip to content

fix(honcho): include file size in memo key to detect sub-second honch… - #47844

Closed
giggling-ginger wants to merge 1 commit into
NousResearch:mainfrom
giggling-ginger:fix/honcho-memo-key-include-file-size
Closed

fix(honcho): include file size in memo key to detect sub-second honch…#47844
giggling-ginger wants to merge 1 commit into
NousResearch:mainfrom
giggling-ginger:fix/honcho-memo-key-include-file-size

Conversation

@giggling-ginger

@giggling-ginger giggling-ginger commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

_extract_honcho_cache_busting_config memoized its result using (path, mtime_ns) as the cache key. On most filesystems, mtime_ns has 1-second granularity, so rapid consecutive writes to honcho.json within the same second would share an identical mtime_ns. The second call would then hit the stale cache and return the old configuration, causing pinPeerName flips to be ignored.

This PR adds st_size to the memoization key. When pinPeerName flips (truefalse), the serialized JSON changes length by one byte, ensuring the cache key changes even when mtime_ns remains identical. Since st_size is retrieved during the existing path.stat() call, there is no additional I/O cost.

Related Issue

Fixes #47844

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Modified gateway/run.py in _extract_honcho_cache_busting_config: Included st_size in the memo_key tuple to ensure cache invalidation on file content changes that occur within the same second.

How to Test

  1. Run the specific test case that reproduces the race condition:
    scripts/run_tests.sh tests/honcho_plugin/test_pin_peer_name.py::TestPinTransition::test_cache_busting_signature_reflects_pin_peer_name
  2. Verify that the test passes (it previously failed due to identical cache signatures).
  3. Confirm all tests in the file pass: scripts/run_tests.sh tests/honcho_plugin/test_pin_peer_name.py

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (this PR addresses an existing test failure)
  • I've tested on my platform: Ubuntu 22.04

Documentation & Housekeeping

  • I've updated relevant documentation — N/A
  • I've updated cli-config.yaml.example — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md — N/A
  • I've considered cross-platform impact — Yes, path.stat() is standard.
  • I've updated tool descriptions/schemas — N/A

Screenshots / Logs

[100.0% | 43/43 | ✓43 | ✗ 0] ✓ tests/honcho_plugin/test_pin_peer_name.py (43✓, 2.2s)

…o.json rewrites

The memoization key for _extract_honcho_cache_busting_config was
(path, mtime_ns).  On most filesystems mtime has 1-second granularity,
so two rapid writes within the same second share an identical mtime_ns
and the second call returns the stale cached result.

Add st_size to the key: when pinPeerName flips (true<->false) the JSON
length changes by one byte, so the size changes even when mtime_ns does
not.  Both values come from a single path.stat() call, so there is no
extra I/O cost.

Fixes: TestPinTransition::test_cache_busting_signature_reflects_pin_peer_name
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins tool/memory Memory tool and memory providers P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jun 17, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #46385 — both PRs add st_size to the _extract_honcho_cache_busting_config memo key in gateway/run.py to bust the cache on coarse-mtime filesystems when honcho.json is rewritten within the same second. #46385 (open, earlier) is the canonical fix; the mechanism here is identical.

@giggling-ginger

Copy link
Copy Markdown
Contributor Author

Duplicate of #46385 — both PRs add st_size to the _extract_honcho_cache_busting_config memo key in gateway/run.py to bust the cache on coarse-mtime filesystems when honcho.json is rewritten within the same second. #46385 (open, earlier) is the canonical fix; the mechanism here is identical.

Thanks for the context, alt-glitch. I see that #46385 covers the same logic. Glad to see the issue is being addressed with the same approach. I'll close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants