Commit 54fbd13
authored
release: v0.5.4 -- durability & dependency hardening (C3/C4/C5/E3) (#33)
* feat(C5): config-gated event-log fsync + partial-line tolerance
- EventLog(fsync=True) flushes + os.fsync()'s each append for crash
durability; defaults off to protect the hot heartbeat write path.
- Gated by HiveConfig.event_log_fsync (env HIVE_EVENT_LOG_FSYNC); daemon
threads it into its EventLog.
- replay() tolerates a torn/partial last line; stream() consumes only
complete (newline-terminated) lines, leaving a partial tail for the
next poll. Mirrors the TFIDFBackend partial-line pattern.
- Document the append-only guarantee on EventLog.
- Tests: fsync round-trip, partial-last-line replay, env-var bool parse.
* feat(C3): ON DELETE CASCADE on agent child tables + delete_agent
- Add ON DELETE CASCADE to every child-table FK to agents (sessions,
goals, nudges, schedules, sub_agents, tasks, alarms) in _SCHEMA, and a
user_version 1->2 table-rebuild migration to add it to existing DBs.
- New HiveStore.delete_agent(): deletes an agent and cascades to all its
child rows (no more orphans). It is the one place FK enforcement is
turned on.
- Centralize connections behind _connect(); foreign_keys stays OFF by
default (preserves writing child rows for non-persisted agents, a valid
standalone-toolkit pattern) and is opt-in via _connect(foreign_keys=True).
- initialize() runs schema+migrations with FKs off so the table rebuild's
DROP/RENAME can't trip referential checks.
- Tests: cascade delete, missing-agent returns False, v1->v2 migration
round-trip preserving data with cascade then live.
* feat(C4): WAL journaling + explicit busy timeout for concurrency
- initialize() switches the DB to WAL (persistent in the header), so
readers and a single writer no longer lock each other out across the
daemon's concurrent cycles and other processes (MCP server, CLI).
- Every connection sets an explicit 5s busy_timeout so contention queues
instead of erroring with 'database is locked'.
- Deliberately NOT pooling/reusing a single connection: aiosqlite's
worker thread is non-daemon, so a long-lived shared connection without
teardown at all ~20 call sites would block interpreter exit. WAL
delivers the concurrency win without that lifecycle hazard.
- Tests: WAL is enabled persistently for fresh connections; 40 concurrent
writers complete with no lock errors. Stress harness: 7/7, 1200
concurrent writes 0 db-locked.
* build(E3): cap fast-moving deps at next major
Add conservative upper bounds so a breaking major can't silently enter
on a fresh install, while keeping minimums loose for downstream compat:
- anthropic >=0.40,<1 (0.x pre-1.0)
- httpx >=0.27,<1
- openai >=1.30,<3 (currently 2.x; block v3)
- mcp >=1.27,<2
- pydantic >=2.5,<3
Stable/slow-moving deps (typer, rich, aiosqlite, pyyaml, etc.) keep
minimum-only pins. Lockfile refreshed.
* release: v0.5.4 -- durability & dependency hardening
Bump 0.5.3 -> 0.5.4. Bundles C5 (event-log fsync), C3 (FK cascades +
delete_agent), C4 (WAL + busy timeout), E3 (dep upper bounds).
- CHANGELOG.md + docs/changelog.md: 0.5.4 entry.
- docs/guide/architecture.md: WAL/cascade/fsync notes in Performance &
Persistence.
- docs/getting-started/cli-quickstart.md: event_log_fsync config option +
HIVE_EVENT_LOG_FSYNC env var.
- uv.lock synced to 0.5.4.
* fix: address Greptile review on PR #33 (migration crash-safety + log corruption)
P1 -- migration crash window (store.py): a crash after DROP TABLE {table}
but before the RENAME left {table} gone and {table}_new holding the only
data; a re-run's executescript(_SCHEMA) recreated {table} empty, masking
the loss, then the rebuild dropped {table}_new -> data loss. Add
_recover_interrupted_rebuilds() that finishes an interrupted swap (renames
the orphaned {table}_new back) and runs BEFORE _SCHEMA, so the dropped
table can't be silently recreated empty. _migration_2 reverts to the
simple rebuild (recovery handled upstream). Regression test simulates the
exact mid-swap on-disk state and asserts no data loss.
P2 -- over-broad except in events.py: replay() caught Exception for every
line, silently hiding mid-log corruption. Now it tolerates a parse error
ONLY on a torn final line (file not newline-terminated) and re-raises
otherwise; the catch is narrowed to ValueError (covers JSON + pydantic
ValidationError). stream() only ever sees complete lines, so its broad
catch is removed -- malformed complete lines now surface. Regression test
asserts mid-log corruption raises.
963 tests pass; ruff/format/mypy clean.
* docs: address review observations on PR #33
- Changelog (both copies): the '1200 concurrent writes' figure came from
the local (gitignored) stress harness, not the committed test (40
writers). Reword to cite both so the claim is reproducible from the repo.
- pyproject: clarify the anthropic<1 cap -- anthropic is still 0.x (breaks
at minor bumps), so <1 mainly guards the eventual 1.0; note to revisit
when 1.0 ships. No pin change (caps still include all locked versions).
Doc/comment only -- no code or dependency-resolution change.1 parent e2cef9d commit 54fbd13
14 files changed
Lines changed: 645 additions & 75 deletions
File tree
- docs
- getting-started
- guide
- src/hive
- daemon
- memory
- tests
- memory
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
3 | 34 | | |
4 | 35 | | |
5 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
3 | 16 | | |
4 | 17 | | |
5 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
114 | 116 | | |
115 | 117 | | |
116 | | - | |
| 118 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
119 | 131 | | |
120 | 132 | | |
121 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | | - | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| |||
163 | 169 | | |
164 | 170 | | |
165 | 171 | | |
| 172 | + | |
| 173 | + | |
166 | 174 | | |
167 | 175 | | |
168 | 176 | | |
| |||
176 | 184 | | |
177 | 185 | | |
178 | 186 | | |
179 | | - | |
| 187 | + | |
180 | 188 | | |
181 | 189 | | |
182 | 190 | | |
| |||
185 | 193 | | |
186 | 194 | | |
187 | 195 | | |
| 196 | + | |
188 | 197 | | |
189 | 198 | | |
190 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
| 49 | + | |
49 | 50 | | |
50 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
51 | 61 | | |
52 | 62 | | |
| 63 | + | |
53 | 64 | | |
54 | 65 | | |
55 | 66 | | |
| |||
64 | 75 | | |
65 | 76 | | |
66 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
67 | 81 | | |
68 | 82 | | |
69 | 83 | | |
70 | 84 | | |
71 | 85 | | |
72 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
73 | 95 | | |
74 | | - | |
75 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
76 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
77 | 106 | | |
78 | 107 | | |
79 | 108 | | |
| |||
91 | 120 | | |
92 | 121 | | |
93 | 122 | | |
94 | | - | |
95 | | - | |
96 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
97 | 135 | | |
98 | | - | |
| 136 | + | |
99 | 137 | | |
100 | 138 | | |
101 | 139 | | |
| |||
0 commit comments