refactor(sessions): one owner for the non-continuation child predicate
Prune's _CONTINUATION_EDGE_SQL re-implemented SessionDB's _NON_CONTINUATION_CHILD_FILTER_SQL clause by clause. If a new fork marker lands in one copy only, prune and compression disagree about which children continue a lineage and prune can again delete the start of a live chat. Both constants are now built from hermes_state_common._non_continuation_child_sql (same pattern as _legacy_reset_child_sql); the class constant is byte-identical and the prune edge differs only in whitespace.
This commit is contained in:
@@ -17,7 +17,8 @@ from agent.session_activity import (
|
||||
from hermes_startup_watchdog import report_startup_progress
|
||||
from hermes_state_common import (
|
||||
_LISTABLE_CHILD_SQL, _PREVIEW_ELIGIBLE_SQL, _PREVIEW_RAW_SELECT, _RECOVERABLE_END_REASONS,
|
||||
_RECOVERABLE_END_REASONS_SQL, _RESET_CHILD_SQL, _RESET_END_REASONS, _legacy_reset_child_sql, _shape_preview,
|
||||
_RECOVERABLE_END_REASONS_SQL, _RESET_CHILD_SQL, _RESET_END_REASONS, _legacy_reset_child_sql, _non_continuation_child_sql,
|
||||
_shape_preview,
|
||||
_sql_in_window, _sql_json_extract, _sql_session_last_active, _sql_session_last_active_by_id,
|
||||
escape_like as _escape_like, _SQL_IN_CHUNK, _id_chunks, _placeholders as _session_ids_placeholders,
|
||||
)
|
||||
@@ -451,16 +452,9 @@ class SessionSessionsMixin:
|
||||
# quiet and its unkeyed successor (incident was ~60s; 15 min without spanning conversations).
|
||||
_ORPHAN_ADOPTION_MAX_GAP_S = 900.0
|
||||
|
||||
# Children that are NOT compression continuations (branches, delegates, reset forks, tool
|
||||
# sessions). Markers are bound to the queried parent id: continuations inherit model_config
|
||||
# verbatim, so presence-matching misclassified them as delegates. Callers bind the parent id
|
||||
# three times for this filter.
|
||||
_NON_CONTINUATION_CHILD_FILTER_SQL = (
|
||||
f" AND COALESCE({_sql_json_extract('{alias}model_config', '$._branched_from')}, '') != ?\n"
|
||||
f" AND COALESCE({_sql_json_extract('{alias}model_config', '$._delegate_from')}, '') != ?\n"
|
||||
f" AND COALESCE({_sql_json_extract('{alias}model_config', '$._reset_from')}, '') != ?\n"
|
||||
" AND COALESCE({alias}source, '') != 'tool'\n"
|
||||
)
|
||||
# Children that are NOT compression continuations (see _non_continuation_child_sql); presence-
|
||||
# matching misclassified inherited markers as delegates. Callers bind the parent id three times.
|
||||
_NON_CONTINUATION_CHILD_FILTER_SQL = _non_continuation_child_sql("{alias}")
|
||||
|
||||
def end_session(self, session_id: str, end_reason: str) -> None:
|
||||
"""Mark a session ended; the first end_reason wins (a compression split must keep
|
||||
|
||||
Reference in New Issue
Block a user