The status page's walkthrough (M6.6b)
A new package, nisse-ui: a read-only page for studying how the agents work. For each work item it shows the steps (what people and the orchestrator said, and each run), each run's turns, and each turn's request read against the log it was made from: - each message beside the events it came from, tagged unchanged, labelled, narrated, shortened (by how much) or a compaction, with what fitting dropped; - what is new since the turn before, and where the request first differs (where prompt reuse had to stop), next to the server's count; - the reply with its reasoning, and the raw JSON. Runs going in circles are flagged by nisse_core.loop.circles (repeated near-identical replies, one correction given again and again, repeated apologies), a pure function M7.8 can reuse in Driver.run. In nisse-core: - render.py: message_indexes(), from the same code render() uses, so the page's matching can't drift from what was sent. - calls.py: the record notes when recording began; the reader gains calls_for(item) and call(id). - state/readonly.py: opens an agent's SQLite file without creating its -wal/-shm files (mode=ro alone does, once the writer has closed). The page reads only through read-only connections, escapes everything, and sends a Content Security Policy that allows no script. It listens on 127.0.0.1; until M6.6d puts it behind Authelia, reach it over an SSH tunnel. Jinja2 is its one new dependency, for autoescaping. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J5Utyfzw7gF7UhjRDEtjTk
This commit is contained in:
1 parent
c1f3d9dafb
commit
a8e2023183
31 files changed
+2550
-15
No files matched your search
@@ -0,0 +1,43 @@
|
||||
"""Readers beside an agent open its files without writing to them (X6)."""
|
||||
|
||||
import sqlite3
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from nisse_core.state import readonly
|
||||
|
||||
|
||||
def wal_db(path: Path) -> sqlite3.Connection:
|
||||
conn = sqlite3.connect(path, isolation_level=None)
|
||||
conn.execute("PRAGMA journal_mode=WAL")
|
||||
conn.execute("CREATE TABLE t (v TEXT)")
|
||||
conn.execute("INSERT INTO t VALUES ('one')")
|
||||
return conn
|
||||
|
||||
|
||||
def test_a_closed_database_is_read_without_creating_any_file(tmp_path: Path) -> None:
|
||||
wal_db(tmp_path / "a.db").close()
|
||||
assert sorted(p.name for p in tmp_path.iterdir()) == ["a.db"]
|
||||
conn = readonly.connect(tmp_path / "a.db")
|
||||
assert conn.execute("SELECT v FROM t").fetchall()[0]["v"] == "one"
|
||||
conn.close()
|
||||
assert sorted(p.name for p in tmp_path.iterdir()) == ["a.db"]
|
||||
|
||||
|
||||
def test_a_live_database_is_read_as_its_writer_commits(tmp_path: Path) -> None:
|
||||
writer = wal_db(tmp_path / "a.db")
|
||||
conn = readonly.connect(tmp_path / "a.db")
|
||||
writer.execute("INSERT INTO t VALUES ('two')")
|
||||
assert [r["v"] for r in conn.execute("SELECT v FROM t")] == ["one", "two"]
|
||||
with pytest.raises(sqlite3.OperationalError):
|
||||
conn.execute("INSERT INTO t VALUES ('three')")
|
||||
conn.close()
|
||||
writer.execute("INSERT INTO t VALUES ('four')") # no lock left behind
|
||||
writer.close()
|
||||
|
||||
|
||||
def test_a_missing_file_is_an_error_not_a_new_database(tmp_path: Path) -> None:
|
||||
with pytest.raises(sqlite3.OperationalError):
|
||||
readonly.connect(tmp_path / "none.db")
|
||||
assert not (tmp_path / "none.db").exists()
|
||||
Reference in new issue
Block a user