hivemind-sqlite-database 0.4.0a6__tar.gz → 0.4.1a1__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.0a6 → hivemind_sqlite_database-0.4.1a1}/PKG-INFO +1 -1
- {hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/README.md +6 -6
- {hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/hivemind_sqlite_database/__init__.py +5 -0
- {hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/hivemind_sqlite_database/version.py +2 -2
- {hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/hivemind_sqlite_database.egg-info/PKG-INFO +1 -1
- {hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/tests/test_sqlitedb.py +20 -0
- {hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/LICENSE.md +0 -0
- {hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/hivemind_sqlite_database.egg-info/SOURCES.txt +0 -0
- {hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/hivemind_sqlite_database.egg-info/dependency_links.txt +0 -0
- {hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/hivemind_sqlite_database.egg-info/entry_points.txt +0 -0
- {hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/hivemind_sqlite_database.egg-info/requires.txt +0 -0
- {hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/hivemind_sqlite_database.egg-info/top_level.txt +0 -0
- {hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/pyproject.toml +0 -0
- {hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/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
|
|
@@ -92,6 +92,11 @@ class SQLiteDB(AbstractDB):
|
|
|
92
92
|
metadata TEXT
|
|
93
93
|
)
|
|
94
94
|
""")
|
|
95
|
+
# api_key is looked up on every client connection admission
|
|
96
|
+
# (get_client_by_api_key), so a full table scan there is hot.
|
|
97
|
+
self.conn.execute(
|
|
98
|
+
"CREATE INDEX IF NOT EXISTS idx_clients_api_key ON clients(api_key)"
|
|
99
|
+
)
|
|
95
100
|
columns = {
|
|
96
101
|
row["name"]
|
|
97
102
|
for row in self.conn.execute("PRAGMA table_info(clients)").fetchall()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# START_VERSION_BLOCK
|
|
2
2
|
VERSION_MAJOR = 0
|
|
3
3
|
VERSION_MINOR = 4
|
|
4
|
-
VERSION_BUILD =
|
|
5
|
-
VERSION_ALPHA =
|
|
4
|
+
VERSION_BUILD = 1
|
|
5
|
+
VERSION_ALPHA = 1
|
|
6
6
|
# END_VERSION_BLOCK
|
|
7
7
|
|
|
8
8
|
__version__ = f"{VERSION_MAJOR}.{VERSION_MINOR}.{VERSION_BUILD}" + (f"a{VERSION_ALPHA}" if VERSION_ALPHA else "")
|
{hivemind_sqlite_database-0.4.0a6 → hivemind_sqlite_database-0.4.1a1}/tests/test_sqlitedb.py
RENAMED
|
@@ -783,6 +783,26 @@ class TestSQLiteDBGetClientByID(unittest.TestCase):
|
|
|
783
783
|
self.assertEqual(db.refresh(1).allowed_types, ["y"])
|
|
784
784
|
|
|
785
785
|
|
|
786
|
+
class TestSQLiteDBApiKeyIndex(unittest.TestCase):
|
|
787
|
+
def test_index_exists_after_init(self):
|
|
788
|
+
db = make_db()
|
|
789
|
+
row = db.conn.execute(
|
|
790
|
+
"SELECT name FROM sqlite_master WHERE type='index' "
|
|
791
|
+
"AND name='idx_clients_api_key'"
|
|
792
|
+
).fetchone()
|
|
793
|
+
self.assertIsNotNone(row)
|
|
794
|
+
|
|
795
|
+
def test_api_key_lookup_uses_index(self):
|
|
796
|
+
db = make_db()
|
|
797
|
+
plan = db.conn.execute(
|
|
798
|
+
"EXPLAIN QUERY PLAN SELECT * FROM clients WHERE api_key = ?",
|
|
799
|
+
("k1",),
|
|
800
|
+
).fetchall()
|
|
801
|
+
detail = " ".join(row["detail"] for row in plan)
|
|
802
|
+
self.assertIn("SEARCH", detail)
|
|
803
|
+
self.assertNotIn("SCAN", detail)
|
|
804
|
+
|
|
805
|
+
|
|
786
806
|
class TestSQLiteDBSchemaV2RoundTrip(unittest.TestCase):
|
|
787
807
|
"""v2 schema: allowed_types + skill/intent blacklists (in metadata) survive
|
|
788
808
|
add→search and add→refresh cycles without loss or mutation."""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|