hivemind-sqlite-database 0.4.0a5__tar.gz → 0.4.0a7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of hivemind-sqlite-database might be problematic. Click here for more details.
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/PKG-INFO +1 -1
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/README.md +6 -6
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/hivemind_sqlite_database/__init__.py +0 -20
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/hivemind_sqlite_database/version.py +1 -1
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/hivemind_sqlite_database.egg-info/PKG-INFO +1 -1
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/tests/test_sqlitedb.py +0 -16
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/LICENSE.md +0 -0
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/hivemind_sqlite_database.egg-info/SOURCES.txt +0 -0
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/hivemind_sqlite_database.egg-info/dependency_links.txt +0 -0
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/hivemind_sqlite_database.egg-info/entry_points.txt +0 -0
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/hivemind_sqlite_database.egg-info/requires.txt +0 -0
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/hivemind_sqlite_database.egg-info/top_level.txt +0 -0
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/pyproject.toml +0 -0
- {hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/setup.cfg +0 -0
|
@@ -7,7 +7,7 @@ Implements the [`hivemind-plugin-manager`](https://github.com/JarbasHiveMind/hiv
|
|
|
7
7
|
encryption is enabled). Client records (API keys, crypto keys, access-control lists) are stored in
|
|
8
8
|
a local `.db` file with WAL journal mode for safe multi-reader, single-writer access.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
This is the default database backend for fresh hivemind-core installations.
|
|
11
11
|
|
|
12
12
|
## Where it fits
|
|
13
13
|
|
|
@@ -99,13 +99,13 @@ typically `~/.local/share/hivemind-core/clients.db`.
|
|
|
99
99
|
## Schema migration
|
|
100
100
|
|
|
101
101
|
On first open after an upgrade, `SQLiteDB` runs an automatic schema migration.
|
|
102
|
-
Version tracking uses SQLite's built-in `PRAGMA user_version
|
|
102
|
+
Version tracking uses SQLite's built-in `PRAGMA user_version`. There are no sibling files.
|
|
103
103
|
|
|
104
104
|
The v1→v2 migration folds legacy `intent_blacklist` / `skill_blacklist` column
|
|
105
105
|
data into each row's `metadata` JSON field and NULLs the legacy columns.
|
|
106
106
|
`message_blacklist` is purged outright.
|
|
107
107
|
|
|
108
|
-
The migration is idempotent
|
|
108
|
+
The migration is idempotent and crash-safe. The row rewrites
|
|
109
109
|
and the `user_version` bump happen in one transaction.
|
|
110
110
|
|
|
111
111
|
To migrate an existing installation to this backend, use hivemind-core's built-in
|
|
@@ -117,6 +117,6 @@ hivemind-core migrate-db
|
|
|
117
117
|
|
|
118
118
|
## Docs
|
|
119
119
|
|
|
120
|
-
- [docs/architecture.md](docs/architecture.md)
|
|
121
|
-
- [docs/configuration.md](docs/configuration.md)
|
|
122
|
-
- [docs/operations.md](docs/operations.md)
|
|
120
|
+
- [docs/architecture.md](docs/architecture.md): internals, WAL mode, schema, migration
|
|
121
|
+
- [docs/configuration.md](docs/configuration.md): full configuration reference
|
|
122
|
+
- [docs/operations.md](docs/operations.md): file locations, backup, encryption, authoring a plugin
|
|
@@ -215,26 +215,6 @@ class SQLiteDB(AbstractDB):
|
|
|
215
215
|
LOG.error(f"Failed to add client to SQLite: {e}")
|
|
216
216
|
return False
|
|
217
217
|
|
|
218
|
-
def update_last_seen(self, api_key: str, seen_at: float) -> bool:
|
|
219
|
-
"""Atomically advance ``last_seen`` for the matching API key."""
|
|
220
|
-
try:
|
|
221
|
-
with self._write_lock, self.conn:
|
|
222
|
-
cursor = self.conn.execute(
|
|
223
|
-
"""
|
|
224
|
-
UPDATE clients
|
|
225
|
-
SET last_seen = CASE
|
|
226
|
-
WHEN last_seen IS NULL OR last_seen < ? THEN ?
|
|
227
|
-
ELSE last_seen
|
|
228
|
-
END
|
|
229
|
-
WHERE api_key = ?
|
|
230
|
-
""",
|
|
231
|
-
(seen_at, seen_at, api_key),
|
|
232
|
-
)
|
|
233
|
-
return cursor.rowcount > 0
|
|
234
|
-
except sqlite3.Error as e:
|
|
235
|
-
LOG.error(f"Failed to update last_seen in SQLite: {e}")
|
|
236
|
-
return False
|
|
237
|
-
|
|
238
218
|
def search_by_value(self, key: str, val: Union[str, bool, int, float]) -> List[Client]:
|
|
239
219
|
"""
|
|
240
220
|
Search for clients by a specific key-value pair in the SQLite database.
|
{hivemind_sqlite_database-0.4.0a5 → hivemind_sqlite_database-0.4.0a7}/tests/test_sqlitedb.py
RENAMED
|
@@ -189,22 +189,6 @@ class TestSQLiteDBSearchByValue(unittest.TestCase):
|
|
|
189
189
|
self.assertEqual(results, [])
|
|
190
190
|
|
|
191
191
|
|
|
192
|
-
class TestSQLiteDBLastSeen(unittest.TestCase):
|
|
193
|
-
def test_update_last_seen_never_moves_timestamp_backward(self):
|
|
194
|
-
db = make_db()
|
|
195
|
-
db.add_item(make_client(1, "key", last_seen=200.0))
|
|
196
|
-
|
|
197
|
-
self.assertTrue(db.update_last_seen("key", 100.0))
|
|
198
|
-
self.assertEqual(db.search_by_value("api_key", "key")[0].last_seen, 200.0)
|
|
199
|
-
|
|
200
|
-
self.assertTrue(db.update_last_seen("key", 300.0))
|
|
201
|
-
self.assertEqual(db.search_by_value("api_key", "key")[0].last_seen, 300.0)
|
|
202
|
-
|
|
203
|
-
def test_update_last_seen_returns_false_for_missing_key(self):
|
|
204
|
-
db = make_db()
|
|
205
|
-
self.assertFalse(db.update_last_seen("missing", 100.0))
|
|
206
|
-
|
|
207
|
-
|
|
208
192
|
class TestSQLiteDBIter(unittest.TestCase):
|
|
209
193
|
def test_iter_yields_all_rows(self):
|
|
210
194
|
db = make_db()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|