Commit 50166c8
committed
v4.1.3: edge profile through persistence backend + corpus hardening
Squashed v4.1 release train. Closes the v4.0 GA "edge profile is
theatrical" gap (handlers held a 6-row sqlite-vec smoke harness while
list/get/search/create/update/delete still acquired raw asyncpg
connections from the Postgres pool) and ships the v4.1.1-1.3 hardening
on top.
## Persistence-backend dispatch (was v4.1.0 / v4.1.1)
Every handler that previously did `_pool.acquire()` now goes through
`_persistence_backend.transactional()` so the active backend
(PostgresBackend or SqliteBackend) decides how to access storage:
- list / get / search / create / update / delete memories
- bulk_create_memories
- /stats (MemoryStatsRow + CompressionStatsRow via gather_stats)
- consultation completion + audit log + DAG live-merge webhook fan-out
now go through the transactional outbox (delivery scheduled
post-commit, not mid-handler)
VisibilityFilter (ROOT_BYPASS / READABLE / OWN_ONLY) replaces the
ad-hoc namespace + permission_mode predicates that handlers used to
inline. Fail-closed: namespace=None for non-root callers raises at
filter construction.
`PostgresBackend.transactional()` uses the canonical `async with
self._pool.acquire() as conn:` pattern (the previous shape awaited
acquire() then async-with on the resolved proxy and broke on
asyncpg's PoolConnectionProxy).
## GRAEAE provider routing (was v4.1.2)
- `_is_reasoning_variant` helper in domain/graeae/engine.py prefers
-non-reasoning over -reasoning siblings when ranking model
candidates (xai grok-4.20-0309-non-reasoning was being shadowed by
the -reasoning variant on len-tiebreak; surfaced as `\confidence{N}`
trailers on consensus output).
- Reasoning-variant rows in db/migrations_*model_registry.sql marked
deprecated; non-reasoning kept canonical.
- Container env standard codified: `MNEMOS_KEYS_PATH` env +
`~/.api_keys_master.json:/etc/mnemos/api_keys.json:ro` mount +
`RATE_LIMIT_STORAGE=memory://` are mandatory in every `mnemos serve`
container or GRAEAE silently 401s every consultation.
## Corpus-review hardening (was v4.1.3)
Fixes the 10 issues from the v4.1.1 full-corpus Codex review
(docs/CORPUS-REVIEW-2026-04-29.md).
Security:
- Pin webhook delivery DNS resolution from validation through HTTP
connect via `PinnedDNSAsyncHTTPTransport` (closes DNS-rebinding
SSRF).
- Apply the same SSRF URL validation to federation peers. Private
peer URLs require `FEDERATION_ALLOW_PRIVATE=true`.
Reliability:
- Release GRAEAE provider concurrency slots in finally during
cancelled fan-out (no slot leak on client disconnect).
Profile correctness:
- Sessions, entities, state, MORPHEUS routes now return explicit 503
on edge (SQLite) profile via `_require_postgres_backend`.
- MORPHEUS run telemetry restricted to root/operator callers.
- DAG read preflight aligned with memory read visibility; branch +
merge writes stay strict-owner-scoped.
- Typed `AuthSettings` + server-profile fail-closed auth defaults via
`MNEMOS_AUTH_ENABLED`.
- SQLite duplicate explicit memory IDs raise `DuplicateMemoryError`
instead of silently succeeding.
Plumbing:
- Migrate route-level asyncpg acquires to `PoolManager.acquire()`.
## Tests
- 1087 passed, 0 failed (was 633 before v4.1).
- 9 new test files for the corpus findings (auth_failclosed,
dag_visibility_alignment, edge_profile_unsupported_routes,
federation_peer_ssrf, graeae_cancellation, morpheus_tenant_scoping,
no_raw_pool_acquire, sqlite_insert_dup, webhook_ssrf_rebind).
- `tests/_fake_backend.py` Postgres-flavored `FakePoolBackedBackend`
so consultation/audit/entity/DAG handlers see consistent test data
through the same FakePool that backed `_pool`.1 parent 5983427 commit 50166c8
67 files changed
Lines changed: 4414 additions & 1853 deletions
File tree
- docs
- mnemos
- api
- routes
- core
- db
- domain
- graeae
- portability
- persistence
- webhooks
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 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 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
5 | 54 | | |
6 | 55 | | |
7 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
| 251 | + | |
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
| |||
622 | 622 | | |
623 | 623 | | |
624 | 624 | | |
625 | | - | |
| 625 | + | |
626 | 626 | | |
627 | 627 | | |
628 | 628 | | |
| |||
633 | 633 | | |
634 | 634 | | |
635 | 635 | | |
636 | | - | |
| 636 | + | |
637 | 637 | | |
638 | | - | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
639 | 653 | | |
640 | 654 | | |
641 | 655 | | |
| |||
675 | 689 | | |
676 | 690 | | |
677 | 691 | | |
678 | | - | |
| 692 | + | |
679 | 693 | | |
680 | 694 | | |
681 | 695 | | |
| |||
684 | 698 | | |
685 | 699 | | |
686 | 700 | | |
687 | | - | |
| 701 | + | |
688 | 702 | | |
689 | 703 | | |
690 | 704 | | |
| |||
0 commit comments