Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
6f918a1
fix(profile-b): expand tenacity retry deadline to support bounded pro…
Yasou13 Aug 31, 2026
48aea9f
fix(live-adapter): expand retry stop delay to 1800s for deep-reasonin…
Yasou13 Aug 31, 2026
135dbf2
fix(dao): set claim_raw_log default lease to 1800s for deep-reasoning…
Yasou13 Aug 31, 2026
22a7412
fix(server): refresh config from environment at startup in _runtime_l…
Yasou13 Aug 31, 2026
f3b99fc
feat(config): raise default queue admission limits to 50000 records t…
Yasou13 Aug 31, 2026
98a6203
fix(dao): add exception logging when admit_v4_memory encounters SQLit…
Yasou13 Aug 31, 2026
d031041
debug(dao): print traceback on admit_v4_memory failure
Yasou13 Aug 31, 2026
90eb971
perf(runtime): optimize Mode 0 validation path and scale combined con…
Yasou13 Aug 31, 2026
f87dfd6
perf(server): parallelize combined dispatch consumption and increase …
Yasou13 Aug 31, 2026
852aee1
fix(server): wrap combined durable consumer in try-except loop with 5…
Yasou13 Aug 31, 2026
7b52a32
perf(worker): bypass legacy ECOD gate when require_tier3_validation i…
Yasou13 Aug 31, 2026
2f3b913
fix(server): streamline _handle_one_dispatch to direct await for low-…
Yasou13 Aug 31, 2026
c4a34d5
fix(dao): allow idempotent dispatch completion receipts to finalize q…
Yasou13 Aug 31, 2026
cbf697b
perf(worker): increase MAX_CONCURRENT_WORKERS to 100 and skip redunda…
Yasou13 Aug 31, 2026
1686fdf
feat(projector): provide canonical chunk triplet fallback for un-extr…
Yasou13 Aug 31, 2026
820d1fa
perf(projector): parallelize projection outbox processor with asyncio…
Yasou13 Aug 31, 2026
e3bfb46
fix(graph): ensure object node is always created when object_id is pr…
Yasou13 Sep 1, 2026
5954d9f
fix(projector): serialize GRAPH lane execution to avoid Kùzu lock con…
Yasou13 Sep 1, 2026
52e8f3d
perf(graph): add in-memory deduplication set to KuzuGraphProvider for…
Yasou13 Sep 1, 2026
1876d7a
perf(projector): run SQLite projection tasks concurrently while prote…
Yasou13 Sep 1, 2026
bf73d35
perf(graph): use CREATE instead of multi-clause MERGE in insert_asser…
Yasou13 Sep 1, 2026
71ece92
perf(projector): batch projection completions into single atomic tran…
Yasou13 Sep 1, 2026
e5daeb2
perf(storage): add idx_v4_assertions_mutation index for high-speed pr…
Yasou13 Sep 1, 2026
35b930c
fix(graph): restore idempotent MERGE in insert_assertion
Yasou13 Sep 1, 2026
e70a0c5
perf(graph): leverage primary key B-Tree index in Cypher MERGE and MA…
Yasou13 Sep 1, 2026
e509d54
perf(graph): batch graph operations in explicit Kùzu transactions for…
Yasou13 Sep 1, 2026
2ede7de
perf(storage): eliminate separate connection open per assertion durin…
Yasou13 Sep 1, 2026
627f2e4
perf(graph): create assertion relationships directly without table scans
Yasou13 Sep 1, 2026
a3bd4b1
fix(graph): pass explicit UTC timestamp parameter in edge upsert to a…
Yasou13 Sep 1, 2026
6c95713
perf(graph): filter allowed entities and assertions in Python sets to…
Yasou13 Sep 1, 2026
285b805
fix(graph): validate intermediate entity IDs in multi-hop traversal a…
Yasou13 Sep 1, 2026
9fcf3e3
fix(vector): use evidence_span in vector assertion projection to embe…
Yasou13 Sep 1, 2026
cf20f7e
fix(worker): allow COMMITTED mutation states to be projected during r…
Yasou13 Sep 1, 2026
e639d70
fix(worker): project available canonical assertions without synthetic…
Yasou13 Sep 1, 2026
40188cd
fix(catalog): allow resolve_id_in_tx to resolve both external and phy…
Yasou13 Sep 1, 2026
b547377
fix(vector): use full chunk text in assertion vector payload for maxi…
Yasou13 Sep 1, 2026
d73ba47
feat(retrieval): calibrate RRF lane weights to prioritize vector and …
Yasou13 Sep 2, 2026
f8d6007
feat(retrieval): set vector lane weight to 10.0 in RRF fusion for rob…
Yasou13 Sep 2, 2026
bcb3198
feat(retrieval): tighten graph seeds to top vector and lexical matches
Yasou13 Sep 2, 2026
e78f6ae
fix(retrieval): initialize assertion_lane correctly
Yasou13 Sep 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mesa_memory/adapter/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
_OPENAI_CONNECTION_ERRORS = (openai.APIConnectionError,) if openai is not None else ()
_OPENAI_NOT_FOUND_ERRORS = (openai.NotFoundError,) if openai is not None else ()
_RETRYABLE_OPENAI_ERRORS = _OPENAI_RATE_LIMIT_ERRORS + _OPENAI_CONNECTION_ERRORS
_OPENAI_RETRY_STOP = stop_after_attempt(3) | stop_after_delay(45)
_OPENAI_RETRY_STOP = stop_after_attempt(3) | stop_after_delay(1800)


class OpenAICompatibleAdapter(BaseUniversalLLMAdapter):
Expand Down
66 changes: 30 additions & 36 deletions mesa_memory/api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,36 +220,20 @@ async def _consume_combined_durable_work_once(
) -> dict[str, int]:
"""Consume bounded durable work in the single storage-owner runtime."""
worker_id = "combined-runtime"
claimed = await dao.claim_dispatch_queue(worker_id=worker_id, limit=1)
for dispatch in claimed:
claimed = await dao.claim_dispatch_queue(worker_id=worker_id, limit=50)

async def _handle_one_dispatch(dispatch: dict[str, Any]) -> None:
log_id = int(dispatch["payload_reference"])
agent_id = str(dispatch["agent_id"])
processing = asyncio.create_task(
process_cold_path(
log_id,
agent_id,
dao,
consolidation_loop=consolidation_loop,
model_processing_enabled=model_processing_enabled,
require_tier3_validation=model_processing_enabled,
retry_on_failure=True,
)
await process_cold_path(
log_id,
Comment on lines +225 to +229
agent_id,
dao,
consolidation_loop=consolidation_loop,
model_processing_enabled=model_processing_enabled,
require_tier3_validation=model_processing_enabled,
retry_on_failure=True,
)
while not processing.done():
try:
await asyncio.wait_for(asyncio.shield(processing), timeout=60)
except TimeoutError:
renewed = await dao.renew_dispatch_queue_lease(
str(dispatch["queue_record_id"]),
worker_id=worker_id,
claim_token=str(dispatch["claim_token"]),
)
if not renewed:
processing.cancel()
with suppress(asyncio.CancelledError):
await processing
raise RuntimeError("combined dispatch lease ownership was lost")
await processing
raw_log = await dao.get_raw_log(agent_id, log_id)
status = str(raw_log.get("status", "DEFERRED") if raw_log else "DEFERRED")
await dao.complete_dispatch_queue(
Expand All @@ -259,7 +243,11 @@ async def _consume_combined_durable_work_once(
outcome=status[:120],
side_effect_verified=status.split(":", 1)[0] in {"processed", "rejected"},
)
finalizations = await dao.list_pending_session_finalizations(limit=1)

if claimed:
await asyncio.gather(*(_handle_one_dispatch(d) for d in claimed), return_exceptions=True)

finalizations = await dao.list_pending_session_finalizations(limit=10)
for finalization in finalizations:
await process_session_finalization(
str(finalization["agent_id"]),
Expand All @@ -270,8 +258,8 @@ async def _consume_combined_durable_work_once(
projections = {"completed": 0}
cleanup = {"completed": 0}
if type(dao) is MemoryDAO:
projections = await process_projection_outbox_once(dao, worker_id=worker_id)
cleanup = await process_artifact_cleanup_once(dao, worker_id=worker_id)
projections = await process_projection_outbox_once(dao, worker_id=worker_id, limit=100)
cleanup = await process_artifact_cleanup_once(dao, worker_id=worker_id, limit=100)
return {
"dispatches": len(claimed),
"finalizations": len(finalizations),
Expand All @@ -288,16 +276,22 @@ async def _run_combined_durable_consumer(
) -> None:
"""Poll the durable journal without introducing a second storage writer."""
while True:
await _consume_combined_durable_work_once(
dao,
consolidation_loop=consolidation_loop,
model_processing_enabled=model_processing_enabled,
)
await asyncio.sleep(0.25)
try:
await _consume_combined_durable_work_once(
dao,
consolidation_loop=consolidation_loop,
model_processing_enabled=model_processing_enabled,
)
except asyncio.CancelledError:
break
except Exception as exc:
logger.exception("Combined durable consumer iteration failed: %s", exc)
await asyncio.sleep(0.05)


@asynccontextmanager
async def _runtime_lifespan(app: FastAPI, runtime: RuntimeProfileConfig):
refresh_config_from_environment()
state.is_ready = False

state.obs_layer = ObservabilityLayer()
Expand Down
24 changes: 12 additions & 12 deletions mesa_memory/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ def load_explicit_dotenv(runtime: RuntimeProfileConfig) -> None:
class QueueAdmissionPolicy(BaseModel):
"""Fail-closed, server-side admission limits for durable cold-path work."""

queue_max_pending_records: int = 10_000
queue_max_pending_bytes: int = 536_870_912
queue_max_pending_records_per_tenant: int = 2_000
queue_max_pending_bytes_per_tenant: int = 134_217_728
queue_max_pending_records: int = 50_000
queue_max_pending_bytes: int = 2_147_483_648
queue_max_pending_records_per_tenant: int = 50_000
queue_max_pending_bytes_per_tenant: int = 2_147_483_648
queue_max_in_flight_records: int = 32
queue_max_in_flight_records_per_tenant: int = 8
queue_max_retry_pending_records: int = 2_000
queue_max_retry_pending_records_per_tenant: int = 500
queue_max_retry_pending_records: int = 10_000
queue_max_retry_pending_records_per_tenant: int = 10_000
queue_max_single_record_bytes: int = 8_388_608
queue_retry_after_seconds: int = 5

Expand Down Expand Up @@ -661,16 +661,16 @@ def vector_worker_limit(self) -> int:
# WAVE-004B: bounded durable queue admission. Each operator value is
# independently environment-configurable and exposed as one typed policy.
queue_max_pending_records: int = Field(
10_000, validation_alias="MESA_QUEUE_MAX_PENDING_RECORDS"
50_000, validation_alias="MESA_QUEUE_MAX_PENDING_RECORDS"
)
queue_max_pending_bytes: int = Field(
536_870_912, validation_alias="MESA_QUEUE_MAX_PENDING_BYTES"
2_147_483_648, validation_alias="MESA_QUEUE_MAX_PENDING_BYTES"
)
queue_max_pending_records_per_tenant: int = Field(
2_000, validation_alias="MESA_QUEUE_MAX_PENDING_RECORDS_PER_TENANT"
50_000, validation_alias="MESA_QUEUE_MAX_PENDING_RECORDS_PER_TENANT"
)
queue_max_pending_bytes_per_tenant: int = Field(
134_217_728, validation_alias="MESA_QUEUE_MAX_PENDING_BYTES_PER_TENANT"
2_147_483_648, validation_alias="MESA_QUEUE_MAX_PENDING_BYTES_PER_TENANT"
)
queue_max_in_flight_records: int = Field(
32, validation_alias="MESA_QUEUE_MAX_IN_FLIGHT_RECORDS"
Expand All @@ -679,10 +679,10 @@ def vector_worker_limit(self) -> int:
8, validation_alias="MESA_QUEUE_MAX_IN_FLIGHT_RECORDS_PER_TENANT"
)
queue_max_retry_pending_records: int = Field(
2_000, validation_alias="MESA_QUEUE_MAX_RETRY_PENDING_RECORDS"
10_000, validation_alias="MESA_QUEUE_MAX_RETRY_PENDING_RECORDS"
)
queue_max_retry_pending_records_per_tenant: int = Field(
500, validation_alias="MESA_QUEUE_MAX_RETRY_PENDING_RECORDS_PER_TENANT"
10_000, validation_alias="MESA_QUEUE_MAX_RETRY_PENDING_RECORDS_PER_TENANT"
)
queue_max_single_record_bytes: int = Field(
8_388_608, validation_alias="MESA_QUEUE_MAX_SINGLE_RECORD_BYTES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ def upgrade() -> None:
"CREATE INDEX IF NOT EXISTS idx_v4_assertions_retrieval "
"ON v4_assertions(tenant_id, dataset_id, status, predicate)"
)
op.execute(
"CREATE INDEX IF NOT EXISTS idx_v4_assertions_mutation "
"ON v4_assertions(mutation_id)"
)
op.execute(
"CREATE INDEX IF NOT EXISTS idx_artifact_sources_owner "
"ON artifact_sources(mutation_id, state)"
Expand Down
Loading
Loading