mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-20 10:11:58 +00:00
test: narrow db._conn before raw SQL so ty stops flagging None-union access
The new compression-tip tests poke started_at/ended_at directly via db._conn to force deterministic lineage ordering. _conn is typed Optional[Connection], so ty flagged .execute/.commit as unresolved on None. Bind a local and assert it's non-None first to narrow the union.
This commit is contained in:
parent
49596b70cb
commit
c23c370b8b
2 changed files with 15 additions and 9 deletions
|
|
@ -100,9 +100,11 @@ def test_follows_compression_tip_when_parent_retains_messages(db):
|
|||
db.append_message("cont", role="assistant", content="post-compression reply")
|
||||
# Force deterministic ordering so the continuation's started_at is clearly
|
||||
# at/after the parent's ended_at (the get_compression_tip discriminator).
|
||||
db._conn.execute("UPDATE sessions SET started_at = ?, ended_at = ? WHERE id = 'root'", (base, base + 50))
|
||||
db._conn.execute("UPDATE sessions SET started_at = ? WHERE id = 'cont'", (base + 100,))
|
||||
db._conn.commit()
|
||||
conn = db._conn
|
||||
assert conn is not None
|
||||
conn.execute("UPDATE sessions SET started_at = ?, ended_at = ? WHERE id = 'root'", (base, base + 50))
|
||||
conn.execute("UPDATE sessions SET started_at = ? WHERE id = 'cont'", (base + 100,))
|
||||
conn.commit()
|
||||
|
||||
assert db.resolve_resume_session_id("root") == "cont"
|
||||
|
||||
|
|
@ -116,9 +118,11 @@ def test_compression_tip_not_confused_with_delegation_child(db):
|
|||
db.append_message("conv", role="user", content="parent turn")
|
||||
db.create_session("subagent", source="cli", parent_session_id="conv")
|
||||
db.append_message("subagent", role="assistant", content="delegated work")
|
||||
db._conn.execute("UPDATE sessions SET started_at = ? WHERE id = 'conv'", (base,))
|
||||
db._conn.execute("UPDATE sessions SET started_at = ? WHERE id = 'subagent'", (base + 100,))
|
||||
db._conn.commit()
|
||||
conn = db._conn
|
||||
assert conn is not None
|
||||
conn.execute("UPDATE sessions SET started_at = ? WHERE id = 'conv'", (base,))
|
||||
conn.execute("UPDATE sessions SET started_at = ? WHERE id = 'subagent'", (base + 100,))
|
||||
conn.commit()
|
||||
|
||||
assert db.resolve_resume_session_id("conv") == "conv"
|
||||
|
||||
|
|
|
|||
|
|
@ -973,12 +973,14 @@ def test_session_resume_follows_compression_tip(monkeypatch, tmp_path):
|
|||
db.end_session("parent_root", "compression")
|
||||
db.create_session("cont_tip", source="tui", parent_session_id="parent_root")
|
||||
db.append_message("cont_tip", role="assistant", content="post-compression reply")
|
||||
db._conn.execute(
|
||||
conn = db._conn
|
||||
assert conn is not None
|
||||
conn.execute(
|
||||
"UPDATE sessions SET started_at = ?, ended_at = ? WHERE id = 'parent_root'",
|
||||
(base, base + 50),
|
||||
)
|
||||
db._conn.execute("UPDATE sessions SET started_at = ? WHERE id = 'cont_tip'", (base + 100,))
|
||||
db._conn.commit()
|
||||
conn.execute("UPDATE sessions SET started_at = ? WHERE id = 'cont_tip'", (base + 100,))
|
||||
conn.commit()
|
||||
|
||||
captured = {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue