Skip to content

Fix importance scheduler and startup timeouts - #65

Merged
Cipher208 merged 1 commit into
masterfrom
fix/v8-schema-and-handshake-timeout
Aug 6, 2026
Merged

Fix importance scheduler and startup timeouts#65
Cipher208 merged 1 commit into
masterfrom
fix/v8-schema-and-handshake-timeout

Conversation

@Cipher208

@Cipher208 Cipher208 commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Addresses 'no such table: audit_trail' and 'no such column: id' regressions. Delays background tasks by 5s to ensure clean MCP handshake.

Summary by CodeRabbit

  • Bug Fixes

    • Improved memory importance tracking by using the correct memory entry identifiers.
    • Updated retrieval metrics to use the appropriate audit records.
  • Reliability

    • Delayed background scheduler startup by five seconds to improve application initialization.
    • Applied consistent scheduler startup behavior in dashboard mode.

@github-actions github-actions Bot added the fix label Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: cc86ed6d-2b6d-499a-b88a-af6946bce71e

📥 Commits

Reviewing files that changed from the base of the PR and between 9a92a0f and c626a18.

📒 Files selected for processing (2)
  • lifecycle/importance_scheduler.py
  • mcp_server/server.py

Walkthrough

The importance scheduler now uses core_memory.entry_id and audit_log. Standard lifespan and dashboard modes start backup_cron and importance_scheduler after a five-second asynchronous delay.

Changes

Scheduler updates

Layer / File(s) Summary
Importance scheduler identifiers
lifecycle/importance_scheduler.py
Rescoring, importance updates, and audit records now use entry_id. Retrieval counts now query audit_log.
Delayed background scheduler startup
mcp_server/server.py
Standard lifespan and dashboard mode start both schedulers after a five-second asynchronous delay and log completion.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ServerMode
  participant DelayedStartupTask
  participant backup_cron
  participant importance_scheduler
  ServerMode->>DelayedStartupTask: Schedule startup task
  DelayedStartupTask->>DelayedStartupTask: Wait five seconds
  DelayedStartupTask->>backup_cron: Start scheduler
  DelayedStartupTask->>importance_scheduler: Start scheduler
  DelayedStartupTask->>ServerMode: Log startup completion
Loading
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/v8-schema-and-handshake-timeout

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Cipher208
Cipher208 merged commit 6119850 into master Aug 6, 2026
18 of 21 checks passed
@Cipher208
Cipher208 deleted the fix/v8-schema-and-handshake-timeout branch August 6, 2026 05:07
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 23.07692% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
mcp_server/server.py 25.00% 9 Missing ⚠️
lifecycle/importance_scheduler.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown

Greptile Summary

The PR updates importance scheduling to use the production database identifiers and delays background-service startup by five seconds.

  • Replaces core_memory.id with entry_id and audit_trail with audit_log.
  • Defers backup and importance schedulers during MCP lifespan startup.
  • Adds equivalent delayed startup to dashboard mode, where task creation currently occurs before the event loop starts.

Confidence Score: 3/5

The PR is not safe to merge until dashboard startup is moved into a running event loop and the scheduler test schemas are updated.

Dashboard mode currently fails before Uvicorn starts, while the scheduler identifier changes leave its in-memory tests querying columns and tables that their fixtures do not define.

Files Needing Attention: mcp_server/server.py, lifecycle/importance_scheduler.py

Important Files Changed

Filename Overview
lifecycle/importance_scheduler.py Corrects production schema identifiers, but the corresponding test fixtures still define the old column and table names.
mcp_server/server.py Delays background tasks successfully inside async lifespan, but dashboard mode calls asyncio.create_task before Uvicorn starts an event loop.

Sequence Diagram

sequenceDiagram
    participant Main
    participant Dashboard as _run_with_dashboard
    participant Asyncio
    participant Uvicorn
    Main->>Dashboard: synchronous call
    Dashboard->>Asyncio: create_task(_delayed_start())
    Asyncio-->>Dashboard: RuntimeError: no running event loop
    Note over Dashboard,Uvicorn: uvicorn.run() is never reached
Loading

Fix All in Codex

Prompt To Fix All With AI
### Issue 1
mcp_server/server.py:189
**Dashboard task lacks event loop**

When dashboard mode starts through the synchronous entrypoint, `asyncio.create_task()` executes before `uvicorn.run()` creates an event loop, causing `RuntimeError: no running event loop` and preventing the server from starting.

### Issue 2
lifecycle/importance_scheduler.py:99
**Scheduler fixtures retain old schema**

When the scheduler tests run, this query selects `entry_id` from a fixture that still defines `core_memory.id`, causing `sqlite3.OperationalError: no such column: entry_id`; the retrieval-signal fixture likewise writes to `audit_trail` while the changed code reads `audit_log`.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix: importance scheduler table names an..." | Re-trigger Greptile

Comment thread mcp_server/server.py
async def _delayed_start():
await asyncio.sleep(5)
backup_cron.start()
importance_scheduler.start()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Dashboard task lacks event loop

When dashboard mode starts through the synchronous entrypoint, asyncio.create_task() executes before uvicorn.run() creates an event loop, causing RuntimeError: no running event loop and preventing the server from starting.

Prompt To Fix With AI
This is a comment left during a code review.
Path: mcp_server/server.py
Line: 189

Comment:
**Dashboard task lacks event loop**

When dashboard mode starts through the synchronous entrypoint, `asyncio.create_task()` executes before `uvicorn.run()` creates an event loop, causing `RuntimeError: no running event loop` and preventing the server from starting.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex

rows = await (
await conn.execute(
"""SELECT id, "key", value, importance, memory_kind
"""SELECT entry_id, "key", value, importance, memory_kind

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Scheduler fixtures retain old schema

When the scheduler tests run, this query selects entry_id from a fixture that still defines core_memory.id, causing sqlite3.OperationalError: no such column: entry_id; the retrieval-signal fixture likewise writes to audit_trail while the changed code reads audit_log.

Prompt To Fix With AI
This is a comment left during a code review.
Path: lifecycle/importance_scheduler.py
Line: 99

Comment:
**Scheduler fixtures retain old schema**

When the scheduler tests run, this query selects `entry_id` from a fixture that still defines `core_memory.id`, causing `sqlite3.OperationalError: no such column: entry_id`; the retrieval-signal fixture likewise writes to `audit_trail` while the changed code reads `audit_log`.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Codex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants