fix(state): finish the #80216 bug class — archive-preserving rewrites at the ACP and TUI sibling sites - #80933
Merged
kshitijk4poor merged 2 commits intoAug 7, 2026
Conversation
…ing rewrites at the two remaining sibling sites NousResearch#80216 fixed /retry (and a follow-up fixed yuanbao recall) destroying soft-archived active=0/compacted=1 in-place-compaction rows via the destructive replace_messages default. Two sibling sites still carried the same class: - acp_adapter/session.py _persist (non-owned-agent branch): probed has_archived_messages and FAILED OPEN into the destructive full replace on any probe error; the probe can also race a concurrent archive_and_compact. Now passes active_only=True unconditionally — on a fresh create/fork every row is active=1 so behavior is identical, and the probe (its only production caller) is deleted. - tui_gateway/methods_prompt.py edit/regenerate truncation: bare replace_messages() deleted the archived transcript of a compacted session on every edit/regenerate. Now active_only=True. hermes_state.has_archived_messages docstring updated (probe is now test/diagnostic-only). Test stubs in test_tui_gateway_server.py accept the new kwarg. New regression tests: real-SQLite archive-survival for both write shapes, fresh-session equivalence (the claim the unconditional switch rests on), and source-level guards pinning that neither site re-grows the fail-open probe (both mutation-checked: revert either fix and its guard fails).
Collaborator
Related: #80195 already covers the TUI prompt-submit rewrite site. This PR overlaps that repair and additionally addresses the ACP persistence path; please consider consolidating the TUI portion. |
…public-API row counting
- state_db fixture: drop the HERMES_HOME setenv + sys.modules purge
(SessionDB takes an explicit path; tests/conftest.py already sandboxes
HERMES_HOME; the purge risks split-class identity for other modules
holding the old hermes_state reference) — matches the plain
tests/hermes_state/ sibling fixture pattern.
- probe guard asserts on the CALL ('has_archived_messages(') instead of a
local-variable name — a reintroduced probe under any rename now trips
it (mutation-checked: renamed-probe reintroduction fails the guard;
restored stack green).
- _archived_count uses the public get_messages(include_inactive=True)
instead of poking db._lock/_conn.
kshitijk4poor
enabled auto-merge
August 7, 2026 10:13
randlee
pushed a commit
to randlee/hermes-agent
that referenced
this pull request
Aug 11, 2026
…messages-archive-siblings fix(state): finish the NousResearch#80216 bug class — archive-preserving rewrites at the ACP and TUI sibling sites
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Finishes the #80216 bug class: the two remaining rewrite paths that could still destroy soft-archived (
active=0/compacted=1) in-place-compaction history now replace only the live rows. #80913 fixed/retryand yuanbao recall; this covers the ACP adapter and the TUI edit/regenerate path, so every production transcript-rewrite site is now archive-preserving.Who hits this: anyone using Hermes via ACP (VS Code/Zed/JetBrains) or the desktop/TUI whose conversation has been compacted — one edit/regenerate (TUI) or one non-owned
_persistwith a failing probe (ACP) permanently deleted their searchable pre-compaction history, silently.Changes
acp_adapter/session.py_persist: replace the fail-openhas_archived_messagesprobe (except: has_archived = False→ destructive full replace; also racy vs a concurrentarchive_and_compact) with unconditionalactive_only=True. On a fresh create/fork all rows areactive=1, so behavior is identical there; when archived rows exist they now survive.tui_gateway/methods_prompt.pyedit/regenerate truncation: barereplace_messages()→active_only=True.hermes_state.py:has_archived_messagesdocstring updated — its only production caller is gone; kept for tests/diagnostics.tests/test_tui_gateway_server.py: 6_StubDb.replace_messagessignatures accept the new kwarg.tests/hermes_state/test_replace_messages_archive_siblings.py(5 tests): real-SQLite archive survival for both write shapes, fresh-session equivalence (the invariant the unconditional switch rests on), and source-level guards pinning that neither site re-grows the fail-open probe.Validation
_persist, probe raisesFollow-up to #80216 / #80913 (@Adolanium, @poisdahl). The ACP probe pattern was flagged during the #80218 review as the origin of this follow-up.