docs: make the mutate-then-persist marker contract explicit (#92231 review)
Reviewer point on #92539: nothing documented that an in-place content mutation of a stamped dict must pop _DB_PERSISTED_MARKER (and invalidate the bounded flush-scan prefix) or the DB silently goes stale. Both existing mutators (turn_finalizer fill-empty-tail, context_compressor micro-compaction defrag) already follow the contract; this states it at the constant so the next one does too.
This commit is contained in:
@@ -276,6 +276,15 @@ _MAX_TOOL_WORKERS = 8
|
||||
# (agent/transports/chat_completions.py, agent/chat_completion_helpers.py) strip
|
||||
# every top-level ``_``-prefixed key before the request leaves the process, so
|
||||
# this never reaches a strict OpenAI-compatible gateway.
|
||||
#
|
||||
# CONTRACT (#92231): the marker asserts "this dict's CONTENT is durable as
|
||||
# written". Loaded rows are stamped at materialization time
|
||||
# (hermes_state._rows_to_conversation), so any code that mutates a loaded or
|
||||
# flushed dict's content in place and needs the change persisted MUST pop the
|
||||
# marker (and invalidate _db_flush_scan_prefix if the dict may sit inside the
|
||||
# bounded-scan prefix) — see agent/turn_finalizer.py (fill-empty-tail) and
|
||||
# agent/context_compressor.py (micro-compaction defrag) for the two canonical
|
||||
# pop sites. Mutating without popping leaves the DB silently stale.
|
||||
_DB_PERSISTED_MARKER = "_db_persisted"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user