') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Prefer RuntimeEvent read model for session reads by likun666661 · Pull Request #13 · apache/maka · GitHub
Skip to content

Prefer RuntimeEvent read model for session reads - #13

Merged
likun666661 merged 2 commits into
apache:mainfrom
likun666661:runtime-v2-aggressive-read-cutover
Jun 15, 2026
Merged

Prefer RuntimeEvent read model for session reads#13
likun666661 merged 2 commits into
apache:mainfrom
likun666661:runtime-v2-aggressive-read-cutover

Conversation

@likun666661

Copy link
Copy Markdown
Member

Summary

  • Make SessionManager.getMessages() and listTurns() prefer RuntimeEvent-projected session views when durable per-run runtime ledgers are usable.
  • Route retry/regenerate turn lookup, user-message lookup, and branch copy through the same RuntimeEvent-primary read view.
  • Expand RuntimeEvent read projection for assistant thinking, abort source metadata, and multi-run lineage.
  • Keep external IPC/preload/gateway/renderer contracts unchanged: callers still receive StoredMessage[] and TurnRecord[].

Rive

  • Workflow: wfrun_65d83dede37f4a8bb7af4375ab5fbb89
  • Scheduler: sched_715dace105ce4c7399692dafcfa46ff4
  • Final verdict: pass_with_risks

Fallback policy

RuntimeEvent reads fall back to legacy SessionStore for no runStore, no runs, active/non-terminal runs, missing/empty runtime ledgers, missing terminal RuntimeEvents, hard projection diagnostics, run-store read failures, or hard compatibility gaps.

MAKA_RUNTIME_READ_SOURCE=legacy forces legacy reads as an emergency rollback.

Known risks

  • AgentRunStore.readRuntimeEvents() still skips corrupt RuntimeEvent JSONL lines silently, so semantic compatibility remains the current safety boundary until storage exposes corruption diagnostics.
  • The runtime view sorts RuntimeEvents chronologically with deterministic tiebreakers; the initial contract mentioned listSessionRuns/per-run concatenation. Tests pass with the chronological policy, but this should stay visible in review.

Verification

  • npm run build --workspace packages/core
  • npm run typecheck --workspace packages/runtime
  • npm run test --workspace packages/runtime -- --runInBand (427 tests, 0 failures)
  • git diff --check
  • Rive stress node also ran npm run test --workspaces --if-present successfully, including desktop 1399 tests / 0 failures.

@likun666661

Copy link
Copy Markdown
MemberAuthor

Follow-up risk cleanup is pushed in 6a27af44 Harden RuntimeEvent read cutover.

What changed:

  • AgentRunStore.readRuntimeEvents() now rejects durable corrupt RuntimeEvent JSONL rows instead of silently shortening the canonical ledger. Unterminated partial tails are still ignored as incomplete writes.
  • SessionManager.readSessionView() now treats runtime-ledger read failure as an explicit legacy fallback path and carries the read error in diagnostics.
  • Multi-run RuntimeEvent read ordering is locked to session chronology by RuntimeEvent.ts, with stable run/ledger/id tiebreakers and a regression test.
  • MAKA_RUNTIME_READ_SOURCE=legacy now has an explicit rollback test.

Verification:

  • npm run test --workspace packages/storage -- --runInBand: 80 tests / 10 suites / 0 failures
  • npm run test --workspace packages/runtime -- --runInBand: 430 tests / 86 suites / 0 failures
  • npm run build --workspace packages/core: pass
  • npm run typecheck --workspace packages/runtime: pass
  • git diff --check: pass
  • npm run test --workspaces --if-present: core 614, storage 80, runtime 430, desktop 1399, all 0 failures

Final verdict: pass.

@likun666661
likun666661 merged commit 71da853 into apache:mainJun 15, 2026
jackwener pushed a commit that referenced this pull request Jun 21, 2026
…tover
Prefer RuntimeEvent read model for session reads
jackwener pushed a commit that referenced this pull request Jun 21, 2026
…tover
Prefer RuntimeEvent read model for session reads
jackwener pushed a commit that referenced this pull request Jun 21, 2026
…tover
Prefer RuntimeEvent read model for session reads
jackwener pushed a commit that referenced this pull request Jun 21, 2026
…tover
Prefer RuntimeEvent read model for session reads
anaconda110 added a commit to anaconda110/maka-agent that referenced this pull request Aug 3, 2026
All current dependencies (React Native, keychain, sqlite, AppCompat,
Hermes) are hosted on google() and mavenCentral(); no dependency pulls
from JitPack. The extra repository only slows resolution and adds a
supply-chain surface, so drop it.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@likun666661