Skip to content

feat(runtime-host): establish protocol and admission foundations - #1356

Merged
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation
Jul 23, 2026
Merged

feat(runtime-host): establish protocol and admission foundations#1356
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation

Conversation

@M4n5ter

@M4n5terM4n5ter commented Jul 22, 2026

Copy link
Copy Markdown
Member
English

Context

This PR establishes the protocol/dispatcher and root-admission foundation required by the Runtime Host Session-core migration tracked in #1167.

The Host is still non-serving in production; this PR does not switch any Desktop, TUI, CLI, or Headless entrypoint.

What changes

Closed operation protocol

  • Split the operation catalog into typed domain specifications with exact input, output, error, lifecycle-availability, and command/query contracts.
  • Decode requests, responses, and handler outcomes against the same closed catalog. Unknown operations, undeclared errors, extra fields, malformed handler outcomes, and incomplete or duplicate handler composition fail closed.
  • Keep host.status available during bootstrap/recovery while ready-only operations return the existing typed host_not_ready failure.
  • Remove the unused retry/admission metadata instead of carrying fields with no consumer or recovery contract. The Kernel now consumes only the lifecycle availability and command mode that affect behavior.
  • Keep the unreleased wire protocol at v0; there is no production compatibility surface yet.

Root admission authority

  • Extract a shared SessionAdmissionGate: operations for one Session serialize, while different Sessions remain independent.
  • Give each durable root-Turn admission an explicit previousRootTurnId. Recovery reconstructs one linear chain from predecessor facts instead of inferring order from timestamps, and rejects missing predecessors, multiple roots, branches, or disconnected cycles.
  • Make RootAdmissionOwner the single in-Epoch owner of recovered admission identity and the current chain tip. It advances only after the Store returns a valid durable result.
  • If a durable write may have committed before reporting failure, poison that Session for the rest of the Host Epoch. Queued successors fail before touching the Store; a new Host Epoch recovers the canonical chain from disk. This avoids extending a stale tip into sibling admissions without introducing a general recovery mechanism.

The experimental root-admission record moves to schema version 2 for the predecessor fact. This is a storage-record schema, separate from the v0 wire protocol, and no compatibility layer is added for non-production state.

Session-store shutdown completion

After the SQLite Session metadata migration in #1373, SessionStore.close() is asynchronous and idempotent: it waits for the already-started metadata import to settle before closing SQLite. Runtime Host, Desktop, and CLI shutdown paths await that completion, so owner teardown cannot race the import.

Evidence

Coverage includes closed catalog and handler composition, bootstrap-versus-ready dispatch, two real Clients racing one Session, response loss followed by Host restart, same-millisecond ordering, malformed durable graphs, a real Store that commits an admission and then throws, and a real JSONL-to-SQLite import immediately followed by close.

Storage passes 443 tests with one existing Windows-only skip; Runtime Host passes all 72 tests. The full workspace typecheck, affected Biome checks, and git diff --check also pass.

Scope

This foundation intentionally does not add Message, canonical projection, continuity, Interaction, automation/goal ownership, production surface wiring, or the M4 stale-Host activation gate. Those remain in their owning slices after this prerequisite.

Part of #1167. Related to #853.

简体中文

背景

本 PR 建立 Runtime Host Session core 迁移所需的 protocol/dispatcher 与 root-admission foundation,整体由 #1167 跟踪。

Runtime Host 仍未进入 production serving,本 PR 不切换 Desktop、TUI、CLI 或 Headless 的任何入口。

改动内容

封闭 operation protocol

  • 将 operation catalog 拆成带有精确 input、output、error、lifecycle availability 与 command/query 契约的 typed domain specification。
  • request、response 与 handler outcome 共用同一份封闭 catalog 解码。未知 operation、未声明 error、多余字段、畸形 handler outcome,以及缺失或重复的 handler composition 都会 fail closed。
  • host.status 在 bootstrap/recovery 阶段仍可使用;仅 ready 可用的 operation 继续返回已有的 typed host_not_ready failure。
  • 删除没有消费者和恢复契约的 retry/admission 元数据,不保留空语义字段。Kernel 只消费真正影响行为的 lifecycle availability 与 command mode。
  • wire protocol 保持未发布的 v0;当前还不存在 production compatibility surface。

Root admission authority

  • 提取共享的 SessionAdmissionGate:同一个 Session 的 operation 串行执行,不同 Session 之间保持独立。
  • 每条 durable root-Turn admission 显式记录 previousRootTurnId。恢复时根据 predecessor fact 重建唯一线性链,不再根据时间戳推断顺序;missing predecessor、multiple roots、branch 和 disconnected cycle 都会被拒绝。
  • RootAdmissionOwner 成为单个 Host Epoch 内 recovered admission identity 与当前 chain tip 的唯一 owner。只有 Store 返回有效 durable result 后才推进 tip。
  • 如果 durable write 可能已经 commit、但随后报告失败,则在本 Host Epoch 内 poison 该 Session。已经排队的 successor 会在触碰 Store 前失败;新 Host Epoch 再从磁盘恢复 canonical chain。这样可以避免沿 stale tip 写出 sibling admission,也无需引入通用恢复机制。

实验性的 root-admission 持久记录因 predecessor fact 升至 schema version 2。它是存储记录 schema,与 v0 wire protocol 相互独立;非生产状态不增加兼容层。

Session Store 关闭完成语义

#1373 将 Session metadata 迁移到 SQLite 后,SessionStore.close() 改为异步且幂等:它会先等待已经启动的 metadata import settle,再关闭 SQLite。Runtime Host、Desktop 与 CLI 的 shutdown 路径都会等待该 completion,避免 owner teardown 与 import 竞态。

验证证据

覆盖范围包括封闭 catalog 与 handler composition、bootstrap/ready dispatch、两个真实 Client 竞争同一个 Session、response 丢失后重启 Host、同毫秒顺序、畸形 durable graph、真实 Store 先 commit admission 再抛错,以及真实 JSONL-to-SQLite import 后立即 close。

Storage 通过 443 项测试,另有 1 项既有 Windows-only skip;Runtime Host 72 项全部通过。全 workspace typecheck、受影响文件的 Biome check 与 git diff --check 也均通过。

范围

本 foundation 刻意不加入 Message、canonical projection、continuity、Interaction、automation/goal ownership、production surface wiring 或 M4 stale-Host activation gate。这些内容会在该前置合并后,随各自所属 slice 推进。

属于 #1167;关联 #853

@likun666661likun666661 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the protocol/dispatcher and root-admission changes.

The closed operation catalog now consistently validates requests, responses, declared errors, and handler composition, while lifecycle availability is enforced during recovery. The SessionAdmissionGate, explicit predecessor chain, and RootAdmissionOwner establish a coherent per-session serialization and fail-closed recovery model, including ambiguous post-commit failures.

The change remains properly scoped to non-serving foundation work. CI is green, and the targeted Storage and Runtime Host tests cover concurrency, restart recovery, malformed durable graphs, and response-loss retry semantics.

I found no blocking issues. Approved.

@M4n5ter
M4n5terforce-pushed the feat/runtime-host-protocol-admission-foundation branch from 40bbdcc to 414be18CompareJuly 23, 2026 07:56
@Astro-Han
Astro-Han merged commit 992b04c into apache:mainJul 23, 2026
3 checks passed
@M4n5ter
M4n5ter deleted the feat/runtime-host-protocol-admission-foundation branch July 23, 2026 09:24
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.

3 participants

@M4n5ter@likun666661@Astro-Han
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
feat(runtime-host): establish protocol and admission foundations by M4n5ter · Pull Request #1356 · apache/maka · GitHub
Skip to content

feat(runtime-host): establish protocol and admission foundations - #1356

Merged
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation
Jul 23, 2026
Merged

feat(runtime-host): establish protocol and admission foundations#1356
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation

Conversation

@M4n5ter

@M4n5terM4n5ter commented Jul 22, 2026

Copy link
Copy Markdown
Member
English

Context

This PR establishes the protocol/dispatcher and root-admission foundation required by the Runtime Host Session-core migration tracked in #1167.

The Host is still non-serving in production; this PR does not switch any Desktop, TUI, CLI, or Headless entrypoint.

What changes

Closed operation protocol

  • Split the operation catalog into typed domain specifications with exact input, output, error, lifecycle-availability, and command/query contracts.
  • Decode requests, responses, and handler outcomes against the same closed catalog. Unknown operations, undeclared errors, extra fields, malformed handler outcomes, and incomplete or duplicate handler composition fail closed.
  • Keep host.status available during bootstrap/recovery while ready-only operations return the existing typed host_not_ready failure.
  • Remove the unused retry/admission metadata instead of carrying fields with no consumer or recovery contract. The Kernel now consumes only the lifecycle availability and command mode that affect behavior.
  • Keep the unreleased wire protocol at v0; there is no production compatibility surface yet.

Root admission authority

  • Extract a shared SessionAdmissionGate: operations for one Session serialize, while different Sessions remain independent.
  • Give each durable root-Turn admission an explicit previousRootTurnId. Recovery reconstructs one linear chain from predecessor facts instead of inferring order from timestamps, and rejects missing predecessors, multiple roots, branches, or disconnected cycles.
  • Make RootAdmissionOwner the single in-Epoch owner of recovered admission identity and the current chain tip. It advances only after the Store returns a valid durable result.
  • If a durable write may have committed before reporting failure, poison that Session for the rest of the Host Epoch. Queued successors fail before touching the Store; a new Host Epoch recovers the canonical chain from disk. This avoids extending a stale tip into sibling admissions without introducing a general recovery mechanism.

The experimental root-admission record moves to schema version 2 for the predecessor fact. This is a storage-record schema, separate from the v0 wire protocol, and no compatibility layer is added for non-production state.

Session-store shutdown completion

After the SQLite Session metadata migration in #1373, SessionStore.close() is asynchronous and idempotent: it waits for the already-started metadata import to settle before closing SQLite. Runtime Host, Desktop, and CLI shutdown paths await that completion, so owner teardown cannot race the import.

Evidence

Coverage includes closed catalog and handler composition, bootstrap-versus-ready dispatch, two real Clients racing one Session, response loss followed by Host restart, same-millisecond ordering, malformed durable graphs, a real Store that commits an admission and then throws, and a real JSONL-to-SQLite import immediately followed by close.

Storage passes 443 tests with one existing Windows-only skip; Runtime Host passes all 72 tests. The full workspace typecheck, affected Biome checks, and git diff --check also pass.

Scope

This foundation intentionally does not add Message, canonical projection, continuity, Interaction, automation/goal ownership, production surface wiring, or the M4 stale-Host activation gate. Those remain in their owning slices after this prerequisite.

Part of #1167. Related to #853.

简体中文

背景

本 PR 建立 Runtime Host Session core 迁移所需的 protocol/dispatcher 与 root-admission foundation,整体由 #1167 跟踪。

Runtime Host 仍未进入 production serving,本 PR 不切换 Desktop、TUI、CLI 或 Headless 的任何入口。

改动内容

封闭 operation protocol

  • 将 operation catalog 拆成带有精确 input、output、error、lifecycle availability 与 command/query 契约的 typed domain specification。
  • request、response 与 handler outcome 共用同一份封闭 catalog 解码。未知 operation、未声明 error、多余字段、畸形 handler outcome,以及缺失或重复的 handler composition 都会 fail closed。
  • host.status 在 bootstrap/recovery 阶段仍可使用;仅 ready 可用的 operation 继续返回已有的 typed host_not_ready failure。
  • 删除没有消费者和恢复契约的 retry/admission 元数据,不保留空语义字段。Kernel 只消费真正影响行为的 lifecycle availability 与 command mode。
  • wire protocol 保持未发布的 v0;当前还不存在 production compatibility surface。

Root admission authority

  • 提取共享的 SessionAdmissionGate:同一个 Session 的 operation 串行执行,不同 Session 之间保持独立。
  • 每条 durable root-Turn admission 显式记录 previousRootTurnId。恢复时根据 predecessor fact 重建唯一线性链,不再根据时间戳推断顺序;missing predecessor、multiple roots、branch 和 disconnected cycle 都会被拒绝。
  • RootAdmissionOwner 成为单个 Host Epoch 内 recovered admission identity 与当前 chain tip 的唯一 owner。只有 Store 返回有效 durable result 后才推进 tip。
  • 如果 durable write 可能已经 commit、但随后报告失败,则在本 Host Epoch 内 poison 该 Session。已经排队的 successor 会在触碰 Store 前失败;新 Host Epoch 再从磁盘恢复 canonical chain。这样可以避免沿 stale tip 写出 sibling admission,也无需引入通用恢复机制。

实验性的 root-admission 持久记录因 predecessor fact 升至 schema version 2。它是存储记录 schema,与 v0 wire protocol 相互独立;非生产状态不增加兼容层。

Session Store 关闭完成语义

#1373 将 Session metadata 迁移到 SQLite 后,SessionStore.close() 改为异步且幂等:它会先等待已经启动的 metadata import settle,再关闭 SQLite。Runtime Host、Desktop 与 CLI 的 shutdown 路径都会等待该 completion,避免 owner teardown 与 import 竞态。

验证证据

覆盖范围包括封闭 catalog 与 handler composition、bootstrap/ready dispatch、两个真实 Client 竞争同一个 Session、response 丢失后重启 Host、同毫秒顺序、畸形 durable graph、真实 Store 先 commit admission 再抛错,以及真实 JSONL-to-SQLite import 后立即 close。

Storage 通过 443 项测试,另有 1 项既有 Windows-only skip;Runtime Host 72 项全部通过。全 workspace typecheck、受影响文件的 Biome check 与 git diff --check 也均通过。

范围

本 foundation 刻意不加入 Message、canonical projection、continuity、Interaction、automation/goal ownership、production surface wiring 或 M4 stale-Host activation gate。这些内容会在该前置合并后,随各自所属 slice 推进。

属于 #1167;关联 #853

@likun666661likun666661 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the protocol/dispatcher and root-admission changes.

The closed operation catalog now consistently validates requests, responses, declared errors, and handler composition, while lifecycle availability is enforced during recovery. The SessionAdmissionGate, explicit predecessor chain, and RootAdmissionOwner establish a coherent per-session serialization and fail-closed recovery model, including ambiguous post-commit failures.

The change remains properly scoped to non-serving foundation work. CI is green, and the targeted Storage and Runtime Host tests cover concurrency, restart recovery, malformed durable graphs, and response-loss retry semantics.

I found no blocking issues. Approved.

@M4n5ter
M4n5terforce-pushed the feat/runtime-host-protocol-admission-foundation branch from 40bbdcc to 414be18CompareJuly 23, 2026 07:56
@Astro-Han
Astro-Han merged commit 992b04c into apache:mainJul 23, 2026
3 checks passed
@M4n5ter
M4n5ter deleted the feat/runtime-host-protocol-admission-foundation branch July 23, 2026 09:24
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.

3 participants

@M4n5ter@likun666661@Astro-Han
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' feat(runtime-host): establish protocol and admission foundations by M4n5ter · Pull Request #1356 · apache/maka · GitHub
Skip to content

feat(runtime-host): establish protocol and admission foundations - #1356

Merged
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation
Jul 23, 2026
Merged

feat(runtime-host): establish protocol and admission foundations#1356
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation

Conversation

@M4n5ter

@M4n5terM4n5ter commented Jul 22, 2026

Copy link
Copy Markdown
Member
English

Context

This PR establishes the protocol/dispatcher and root-admission foundation required by the Runtime Host Session-core migration tracked in #1167.

The Host is still non-serving in production; this PR does not switch any Desktop, TUI, CLI, or Headless entrypoint.

What changes

Closed operation protocol

  • Split the operation catalog into typed domain specifications with exact input, output, error, lifecycle-availability, and command/query contracts.
  • Decode requests, responses, and handler outcomes against the same closed catalog. Unknown operations, undeclared errors, extra fields, malformed handler outcomes, and incomplete or duplicate handler composition fail closed.
  • Keep host.status available during bootstrap/recovery while ready-only operations return the existing typed host_not_ready failure.
  • Remove the unused retry/admission metadata instead of carrying fields with no consumer or recovery contract. The Kernel now consumes only the lifecycle availability and command mode that affect behavior.
  • Keep the unreleased wire protocol at v0; there is no production compatibility surface yet.

Root admission authority

  • Extract a shared SessionAdmissionGate: operations for one Session serialize, while different Sessions remain independent.
  • Give each durable root-Turn admission an explicit previousRootTurnId. Recovery reconstructs one linear chain from predecessor facts instead of inferring order from timestamps, and rejects missing predecessors, multiple roots, branches, or disconnected cycles.
  • Make RootAdmissionOwner the single in-Epoch owner of recovered admission identity and the current chain tip. It advances only after the Store returns a valid durable result.
  • If a durable write may have committed before reporting failure, poison that Session for the rest of the Host Epoch. Queued successors fail before touching the Store; a new Host Epoch recovers the canonical chain from disk. This avoids extending a stale tip into sibling admissions without introducing a general recovery mechanism.

The experimental root-admission record moves to schema version 2 for the predecessor fact. This is a storage-record schema, separate from the v0 wire protocol, and no compatibility layer is added for non-production state.

Session-store shutdown completion

After the SQLite Session metadata migration in #1373, SessionStore.close() is asynchronous and idempotent: it waits for the already-started metadata import to settle before closing SQLite. Runtime Host, Desktop, and CLI shutdown paths await that completion, so owner teardown cannot race the import.

Evidence

Coverage includes closed catalog and handler composition, bootstrap-versus-ready dispatch, two real Clients racing one Session, response loss followed by Host restart, same-millisecond ordering, malformed durable graphs, a real Store that commits an admission and then throws, and a real JSONL-to-SQLite import immediately followed by close.

Storage passes 443 tests with one existing Windows-only skip; Runtime Host passes all 72 tests. The full workspace typecheck, affected Biome checks, and git diff --check also pass.

Scope

This foundation intentionally does not add Message, canonical projection, continuity, Interaction, automation/goal ownership, production surface wiring, or the M4 stale-Host activation gate. Those remain in their owning slices after this prerequisite.

Part of #1167. Related to #853.

简体中文

背景

本 PR 建立 Runtime Host Session core 迁移所需的 protocol/dispatcher 与 root-admission foundation,整体由 #1167 跟踪。

Runtime Host 仍未进入 production serving,本 PR 不切换 Desktop、TUI、CLI 或 Headless 的任何入口。

改动内容

封闭 operation protocol

  • 将 operation catalog 拆成带有精确 input、output、error、lifecycle availability 与 command/query 契约的 typed domain specification。
  • request、response 与 handler outcome 共用同一份封闭 catalog 解码。未知 operation、未声明 error、多余字段、畸形 handler outcome,以及缺失或重复的 handler composition 都会 fail closed。
  • host.status 在 bootstrap/recovery 阶段仍可使用;仅 ready 可用的 operation 继续返回已有的 typed host_not_ready failure。
  • 删除没有消费者和恢复契约的 retry/admission 元数据,不保留空语义字段。Kernel 只消费真正影响行为的 lifecycle availability 与 command mode。
  • wire protocol 保持未发布的 v0;当前还不存在 production compatibility surface。

Root admission authority

  • 提取共享的 SessionAdmissionGate:同一个 Session 的 operation 串行执行,不同 Session 之间保持独立。
  • 每条 durable root-Turn admission 显式记录 previousRootTurnId。恢复时根据 predecessor fact 重建唯一线性链,不再根据时间戳推断顺序;missing predecessor、multiple roots、branch 和 disconnected cycle 都会被拒绝。
  • RootAdmissionOwner 成为单个 Host Epoch 内 recovered admission identity 与当前 chain tip 的唯一 owner。只有 Store 返回有效 durable result 后才推进 tip。
  • 如果 durable write 可能已经 commit、但随后报告失败,则在本 Host Epoch 内 poison 该 Session。已经排队的 successor 会在触碰 Store 前失败;新 Host Epoch 再从磁盘恢复 canonical chain。这样可以避免沿 stale tip 写出 sibling admission,也无需引入通用恢复机制。

实验性的 root-admission 持久记录因 predecessor fact 升至 schema version 2。它是存储记录 schema,与 v0 wire protocol 相互独立;非生产状态不增加兼容层。

Session Store 关闭完成语义

#1373 将 Session metadata 迁移到 SQLite 后,SessionStore.close() 改为异步且幂等:它会先等待已经启动的 metadata import settle,再关闭 SQLite。Runtime Host、Desktop 与 CLI 的 shutdown 路径都会等待该 completion,避免 owner teardown 与 import 竞态。

验证证据

覆盖范围包括封闭 catalog 与 handler composition、bootstrap/ready dispatch、两个真实 Client 竞争同一个 Session、response 丢失后重启 Host、同毫秒顺序、畸形 durable graph、真实 Store 先 commit admission 再抛错,以及真实 JSONL-to-SQLite import 后立即 close。

Storage 通过 443 项测试,另有 1 项既有 Windows-only skip;Runtime Host 72 项全部通过。全 workspace typecheck、受影响文件的 Biome check 与 git diff --check 也均通过。

范围

本 foundation 刻意不加入 Message、canonical projection、continuity、Interaction、automation/goal ownership、production surface wiring 或 M4 stale-Host activation gate。这些内容会在该前置合并后,随各自所属 slice 推进。

属于 #1167;关联 #853

@likun666661likun666661 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the protocol/dispatcher and root-admission changes.

The closed operation catalog now consistently validates requests, responses, declared errors, and handler composition, while lifecycle availability is enforced during recovery. The SessionAdmissionGate, explicit predecessor chain, and RootAdmissionOwner establish a coherent per-session serialization and fail-closed recovery model, including ambiguous post-commit failures.

The change remains properly scoped to non-serving foundation work. CI is green, and the targeted Storage and Runtime Host tests cover concurrency, restart recovery, malformed durable graphs, and response-loss retry semantics.

I found no blocking issues. Approved.

@M4n5ter
M4n5terforce-pushed the feat/runtime-host-protocol-admission-foundation branch from 40bbdcc to 414be18CompareJuly 23, 2026 07:56
@Astro-Han
Astro-Han merged commit 992b04c into apache:mainJul 23, 2026
3 checks passed
@M4n5ter
M4n5ter deleted the feat/runtime-host-protocol-admission-foundation branch July 23, 2026 09:24
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.

3 participants

@M4n5ter@likun666661@Astro-Han
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', '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('^' + ".*" + ' feat(runtime-host): establish protocol and admission foundations by M4n5ter · Pull Request #1356 · apache/maka · GitHub
Skip to content

feat(runtime-host): establish protocol and admission foundations - #1356

Merged
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation
Jul 23, 2026
Merged

feat(runtime-host): establish protocol and admission foundations#1356
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation

Conversation

@M4n5ter

@M4n5terM4n5ter commented Jul 22, 2026

Copy link
Copy Markdown
Member
English

Context

This PR establishes the protocol/dispatcher and root-admission foundation required by the Runtime Host Session-core migration tracked in #1167.

The Host is still non-serving in production; this PR does not switch any Desktop, TUI, CLI, or Headless entrypoint.

What changes

Closed operation protocol

  • Split the operation catalog into typed domain specifications with exact input, output, error, lifecycle-availability, and command/query contracts.
  • Decode requests, responses, and handler outcomes against the same closed catalog. Unknown operations, undeclared errors, extra fields, malformed handler outcomes, and incomplete or duplicate handler composition fail closed.
  • Keep host.status available during bootstrap/recovery while ready-only operations return the existing typed host_not_ready failure.
  • Remove the unused retry/admission metadata instead of carrying fields with no consumer or recovery contract. The Kernel now consumes only the lifecycle availability and command mode that affect behavior.
  • Keep the unreleased wire protocol at v0; there is no production compatibility surface yet.

Root admission authority

  • Extract a shared SessionAdmissionGate: operations for one Session serialize, while different Sessions remain independent.
  • Give each durable root-Turn admission an explicit previousRootTurnId. Recovery reconstructs one linear chain from predecessor facts instead of inferring order from timestamps, and rejects missing predecessors, multiple roots, branches, or disconnected cycles.
  • Make RootAdmissionOwner the single in-Epoch owner of recovered admission identity and the current chain tip. It advances only after the Store returns a valid durable result.
  • If a durable write may have committed before reporting failure, poison that Session for the rest of the Host Epoch. Queued successors fail before touching the Store; a new Host Epoch recovers the canonical chain from disk. This avoids extending a stale tip into sibling admissions without introducing a general recovery mechanism.

The experimental root-admission record moves to schema version 2 for the predecessor fact. This is a storage-record schema, separate from the v0 wire protocol, and no compatibility layer is added for non-production state.

Session-store shutdown completion

After the SQLite Session metadata migration in #1373, SessionStore.close() is asynchronous and idempotent: it waits for the already-started metadata import to settle before closing SQLite. Runtime Host, Desktop, and CLI shutdown paths await that completion, so owner teardown cannot race the import.

Evidence

Coverage includes closed catalog and handler composition, bootstrap-versus-ready dispatch, two real Clients racing one Session, response loss followed by Host restart, same-millisecond ordering, malformed durable graphs, a real Store that commits an admission and then throws, and a real JSONL-to-SQLite import immediately followed by close.

Storage passes 443 tests with one existing Windows-only skip; Runtime Host passes all 72 tests. The full workspace typecheck, affected Biome checks, and git diff --check also pass.

Scope

This foundation intentionally does not add Message, canonical projection, continuity, Interaction, automation/goal ownership, production surface wiring, or the M4 stale-Host activation gate. Those remain in their owning slices after this prerequisite.

Part of #1167. Related to #853.

简体中文

背景

本 PR 建立 Runtime Host Session core 迁移所需的 protocol/dispatcher 与 root-admission foundation,整体由 #1167 跟踪。

Runtime Host 仍未进入 production serving,本 PR 不切换 Desktop、TUI、CLI 或 Headless 的任何入口。

改动内容

封闭 operation protocol

  • 将 operation catalog 拆成带有精确 input、output、error、lifecycle availability 与 command/query 契约的 typed domain specification。
  • request、response 与 handler outcome 共用同一份封闭 catalog 解码。未知 operation、未声明 error、多余字段、畸形 handler outcome,以及缺失或重复的 handler composition 都会 fail closed。
  • host.status 在 bootstrap/recovery 阶段仍可使用;仅 ready 可用的 operation 继续返回已有的 typed host_not_ready failure。
  • 删除没有消费者和恢复契约的 retry/admission 元数据,不保留空语义字段。Kernel 只消费真正影响行为的 lifecycle availability 与 command mode。
  • wire protocol 保持未发布的 v0;当前还不存在 production compatibility surface。

Root admission authority

  • 提取共享的 SessionAdmissionGate:同一个 Session 的 operation 串行执行,不同 Session 之间保持独立。
  • 每条 durable root-Turn admission 显式记录 previousRootTurnId。恢复时根据 predecessor fact 重建唯一线性链,不再根据时间戳推断顺序;missing predecessor、multiple roots、branch 和 disconnected cycle 都会被拒绝。
  • RootAdmissionOwner 成为单个 Host Epoch 内 recovered admission identity 与当前 chain tip 的唯一 owner。只有 Store 返回有效 durable result 后才推进 tip。
  • 如果 durable write 可能已经 commit、但随后报告失败,则在本 Host Epoch 内 poison 该 Session。已经排队的 successor 会在触碰 Store 前失败;新 Host Epoch 再从磁盘恢复 canonical chain。这样可以避免沿 stale tip 写出 sibling admission,也无需引入通用恢复机制。

实验性的 root-admission 持久记录因 predecessor fact 升至 schema version 2。它是存储记录 schema,与 v0 wire protocol 相互独立;非生产状态不增加兼容层。

Session Store 关闭完成语义

#1373 将 Session metadata 迁移到 SQLite 后,SessionStore.close() 改为异步且幂等:它会先等待已经启动的 metadata import settle,再关闭 SQLite。Runtime Host、Desktop 与 CLI 的 shutdown 路径都会等待该 completion,避免 owner teardown 与 import 竞态。

验证证据

覆盖范围包括封闭 catalog 与 handler composition、bootstrap/ready dispatch、两个真实 Client 竞争同一个 Session、response 丢失后重启 Host、同毫秒顺序、畸形 durable graph、真实 Store 先 commit admission 再抛错,以及真实 JSONL-to-SQLite import 后立即 close。

Storage 通过 443 项测试,另有 1 项既有 Windows-only skip;Runtime Host 72 项全部通过。全 workspace typecheck、受影响文件的 Biome check 与 git diff --check 也均通过。

范围

本 foundation 刻意不加入 Message、canonical projection、continuity、Interaction、automation/goal ownership、production surface wiring 或 M4 stale-Host activation gate。这些内容会在该前置合并后,随各自所属 slice 推进。

属于 #1167;关联 #853

@likun666661likun666661 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the protocol/dispatcher and root-admission changes.

The closed operation catalog now consistently validates requests, responses, declared errors, and handler composition, while lifecycle availability is enforced during recovery. The SessionAdmissionGate, explicit predecessor chain, and RootAdmissionOwner establish a coherent per-session serialization and fail-closed recovery model, including ambiguous post-commit failures.

The change remains properly scoped to non-serving foundation work. CI is green, and the targeted Storage and Runtime Host tests cover concurrency, restart recovery, malformed durable graphs, and response-loss retry semantics.

I found no blocking issues. Approved.

@M4n5ter
M4n5terforce-pushed the feat/runtime-host-protocol-admission-foundation branch from 40bbdcc to 414be18CompareJuly 23, 2026 07:56
@Astro-Han
Astro-Han merged commit 992b04c into apache:mainJul 23, 2026
3 checks passed
@M4n5ter
M4n5ter deleted the feat/runtime-host-protocol-admission-foundation branch July 23, 2026 09:24
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.

3 participants

@M4n5ter@likun666661@Astro-Han
, '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" + ' feat(runtime-host): establish protocol and admission foundations by M4n5ter · Pull Request #1356 · apache/maka · GitHub
Skip to content

feat(runtime-host): establish protocol and admission foundations - #1356

Merged
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation
Jul 23, 2026
Merged

feat(runtime-host): establish protocol and admission foundations#1356
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation

Conversation

@M4n5ter

@M4n5terM4n5ter commented Jul 22, 2026

Copy link
Copy Markdown
Member
English

Context

This PR establishes the protocol/dispatcher and root-admission foundation required by the Runtime Host Session-core migration tracked in #1167.

The Host is still non-serving in production; this PR does not switch any Desktop, TUI, CLI, or Headless entrypoint.

What changes

Closed operation protocol

  • Split the operation catalog into typed domain specifications with exact input, output, error, lifecycle-availability, and command/query contracts.
  • Decode requests, responses, and handler outcomes against the same closed catalog. Unknown operations, undeclared errors, extra fields, malformed handler outcomes, and incomplete or duplicate handler composition fail closed.
  • Keep host.status available during bootstrap/recovery while ready-only operations return the existing typed host_not_ready failure.
  • Remove the unused retry/admission metadata instead of carrying fields with no consumer or recovery contract. The Kernel now consumes only the lifecycle availability and command mode that affect behavior.
  • Keep the unreleased wire protocol at v0; there is no production compatibility surface yet.

Root admission authority

  • Extract a shared SessionAdmissionGate: operations for one Session serialize, while different Sessions remain independent.
  • Give each durable root-Turn admission an explicit previousRootTurnId. Recovery reconstructs one linear chain from predecessor facts instead of inferring order from timestamps, and rejects missing predecessors, multiple roots, branches, or disconnected cycles.
  • Make RootAdmissionOwner the single in-Epoch owner of recovered admission identity and the current chain tip. It advances only after the Store returns a valid durable result.
  • If a durable write may have committed before reporting failure, poison that Session for the rest of the Host Epoch. Queued successors fail before touching the Store; a new Host Epoch recovers the canonical chain from disk. This avoids extending a stale tip into sibling admissions without introducing a general recovery mechanism.

The experimental root-admission record moves to schema version 2 for the predecessor fact. This is a storage-record schema, separate from the v0 wire protocol, and no compatibility layer is added for non-production state.

Session-store shutdown completion

After the SQLite Session metadata migration in #1373, SessionStore.close() is asynchronous and idempotent: it waits for the already-started metadata import to settle before closing SQLite. Runtime Host, Desktop, and CLI shutdown paths await that completion, so owner teardown cannot race the import.

Evidence

Coverage includes closed catalog and handler composition, bootstrap-versus-ready dispatch, two real Clients racing one Session, response loss followed by Host restart, same-millisecond ordering, malformed durable graphs, a real Store that commits an admission and then throws, and a real JSONL-to-SQLite import immediately followed by close.

Storage passes 443 tests with one existing Windows-only skip; Runtime Host passes all 72 tests. The full workspace typecheck, affected Biome checks, and git diff --check also pass.

Scope

This foundation intentionally does not add Message, canonical projection, continuity, Interaction, automation/goal ownership, production surface wiring, or the M4 stale-Host activation gate. Those remain in their owning slices after this prerequisite.

Part of #1167. Related to #853.

简体中文

背景

本 PR 建立 Runtime Host Session core 迁移所需的 protocol/dispatcher 与 root-admission foundation,整体由 #1167 跟踪。

Runtime Host 仍未进入 production serving,本 PR 不切换 Desktop、TUI、CLI 或 Headless 的任何入口。

改动内容

封闭 operation protocol

  • 将 operation catalog 拆成带有精确 input、output、error、lifecycle availability 与 command/query 契约的 typed domain specification。
  • request、response 与 handler outcome 共用同一份封闭 catalog 解码。未知 operation、未声明 error、多余字段、畸形 handler outcome,以及缺失或重复的 handler composition 都会 fail closed。
  • host.status 在 bootstrap/recovery 阶段仍可使用;仅 ready 可用的 operation 继续返回已有的 typed host_not_ready failure。
  • 删除没有消费者和恢复契约的 retry/admission 元数据,不保留空语义字段。Kernel 只消费真正影响行为的 lifecycle availability 与 command mode。
  • wire protocol 保持未发布的 v0;当前还不存在 production compatibility surface。

Root admission authority

  • 提取共享的 SessionAdmissionGate:同一个 Session 的 operation 串行执行,不同 Session 之间保持独立。
  • 每条 durable root-Turn admission 显式记录 previousRootTurnId。恢复时根据 predecessor fact 重建唯一线性链,不再根据时间戳推断顺序;missing predecessor、multiple roots、branch 和 disconnected cycle 都会被拒绝。
  • RootAdmissionOwner 成为单个 Host Epoch 内 recovered admission identity 与当前 chain tip 的唯一 owner。只有 Store 返回有效 durable result 后才推进 tip。
  • 如果 durable write 可能已经 commit、但随后报告失败,则在本 Host Epoch 内 poison 该 Session。已经排队的 successor 会在触碰 Store 前失败;新 Host Epoch 再从磁盘恢复 canonical chain。这样可以避免沿 stale tip 写出 sibling admission,也无需引入通用恢复机制。

实验性的 root-admission 持久记录因 predecessor fact 升至 schema version 2。它是存储记录 schema,与 v0 wire protocol 相互独立;非生产状态不增加兼容层。

Session Store 关闭完成语义

#1373 将 Session metadata 迁移到 SQLite 后,SessionStore.close() 改为异步且幂等:它会先等待已经启动的 metadata import settle,再关闭 SQLite。Runtime Host、Desktop 与 CLI 的 shutdown 路径都会等待该 completion,避免 owner teardown 与 import 竞态。

验证证据

覆盖范围包括封闭 catalog 与 handler composition、bootstrap/ready dispatch、两个真实 Client 竞争同一个 Session、response 丢失后重启 Host、同毫秒顺序、畸形 durable graph、真实 Store 先 commit admission 再抛错,以及真实 JSONL-to-SQLite import 后立即 close。

Storage 通过 443 项测试,另有 1 项既有 Windows-only skip;Runtime Host 72 项全部通过。全 workspace typecheck、受影响文件的 Biome check 与 git diff --check 也均通过。

范围

本 foundation 刻意不加入 Message、canonical projection、continuity、Interaction、automation/goal ownership、production surface wiring 或 M4 stale-Host activation gate。这些内容会在该前置合并后,随各自所属 slice 推进。

属于 #1167;关联 #853

@likun666661likun666661 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the protocol/dispatcher and root-admission changes.

The closed operation catalog now consistently validates requests, responses, declared errors, and handler composition, while lifecycle availability is enforced during recovery. The SessionAdmissionGate, explicit predecessor chain, and RootAdmissionOwner establish a coherent per-session serialization and fail-closed recovery model, including ambiguous post-commit failures.

The change remains properly scoped to non-serving foundation work. CI is green, and the targeted Storage and Runtime Host tests cover concurrency, restart recovery, malformed durable graphs, and response-loss retry semantics.

I found no blocking issues. Approved.

@M4n5ter
M4n5terforce-pushed the feat/runtime-host-protocol-admission-foundation branch from 40bbdcc to 414be18CompareJuly 23, 2026 07:56
@Astro-Han
Astro-Han merged commit 992b04c into apache:mainJul 23, 2026
3 checks passed
@M4n5ter
M4n5ter deleted the feat/runtime-host-protocol-admission-foundation branch July 23, 2026 09:24
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.

3 participants

@M4n5ter@likun666661@Astro-Han
, '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('^' + ".*" + ' feat(runtime-host): establish protocol and admission foundations by M4n5ter · Pull Request #1356 · apache/maka · GitHub
Skip to content

feat(runtime-host): establish protocol and admission foundations - #1356

Merged
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation
Jul 23, 2026
Merged

feat(runtime-host): establish protocol and admission foundations#1356
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation

Conversation

@M4n5ter

@M4n5terM4n5ter commented Jul 22, 2026

Copy link
Copy Markdown
Member
English

Context

This PR establishes the protocol/dispatcher and root-admission foundation required by the Runtime Host Session-core migration tracked in #1167.

The Host is still non-serving in production; this PR does not switch any Desktop, TUI, CLI, or Headless entrypoint.

What changes

Closed operation protocol

  • Split the operation catalog into typed domain specifications with exact input, output, error, lifecycle-availability, and command/query contracts.
  • Decode requests, responses, and handler outcomes against the same closed catalog. Unknown operations, undeclared errors, extra fields, malformed handler outcomes, and incomplete or duplicate handler composition fail closed.
  • Keep host.status available during bootstrap/recovery while ready-only operations return the existing typed host_not_ready failure.
  • Remove the unused retry/admission metadata instead of carrying fields with no consumer or recovery contract. The Kernel now consumes only the lifecycle availability and command mode that affect behavior.
  • Keep the unreleased wire protocol at v0; there is no production compatibility surface yet.

Root admission authority

  • Extract a shared SessionAdmissionGate: operations for one Session serialize, while different Sessions remain independent.
  • Give each durable root-Turn admission an explicit previousRootTurnId. Recovery reconstructs one linear chain from predecessor facts instead of inferring order from timestamps, and rejects missing predecessors, multiple roots, branches, or disconnected cycles.
  • Make RootAdmissionOwner the single in-Epoch owner of recovered admission identity and the current chain tip. It advances only after the Store returns a valid durable result.
  • If a durable write may have committed before reporting failure, poison that Session for the rest of the Host Epoch. Queued successors fail before touching the Store; a new Host Epoch recovers the canonical chain from disk. This avoids extending a stale tip into sibling admissions without introducing a general recovery mechanism.

The experimental root-admission record moves to schema version 2 for the predecessor fact. This is a storage-record schema, separate from the v0 wire protocol, and no compatibility layer is added for non-production state.

Session-store shutdown completion

After the SQLite Session metadata migration in #1373, SessionStore.close() is asynchronous and idempotent: it waits for the already-started metadata import to settle before closing SQLite. Runtime Host, Desktop, and CLI shutdown paths await that completion, so owner teardown cannot race the import.

Evidence

Coverage includes closed catalog and handler composition, bootstrap-versus-ready dispatch, two real Clients racing one Session, response loss followed by Host restart, same-millisecond ordering, malformed durable graphs, a real Store that commits an admission and then throws, and a real JSONL-to-SQLite import immediately followed by close.

Storage passes 443 tests with one existing Windows-only skip; Runtime Host passes all 72 tests. The full workspace typecheck, affected Biome checks, and git diff --check also pass.

Scope

This foundation intentionally does not add Message, canonical projection, continuity, Interaction, automation/goal ownership, production surface wiring, or the M4 stale-Host activation gate. Those remain in their owning slices after this prerequisite.

Part of #1167. Related to #853.

简体中文

背景

本 PR 建立 Runtime Host Session core 迁移所需的 protocol/dispatcher 与 root-admission foundation,整体由 #1167 跟踪。

Runtime Host 仍未进入 production serving,本 PR 不切换 Desktop、TUI、CLI 或 Headless 的任何入口。

改动内容

封闭 operation protocol

  • 将 operation catalog 拆成带有精确 input、output、error、lifecycle availability 与 command/query 契约的 typed domain specification。
  • request、response 与 handler outcome 共用同一份封闭 catalog 解码。未知 operation、未声明 error、多余字段、畸形 handler outcome,以及缺失或重复的 handler composition 都会 fail closed。
  • host.status 在 bootstrap/recovery 阶段仍可使用;仅 ready 可用的 operation 继续返回已有的 typed host_not_ready failure。
  • 删除没有消费者和恢复契约的 retry/admission 元数据,不保留空语义字段。Kernel 只消费真正影响行为的 lifecycle availability 与 command mode。
  • wire protocol 保持未发布的 v0;当前还不存在 production compatibility surface。

Root admission authority

  • 提取共享的 SessionAdmissionGate:同一个 Session 的 operation 串行执行,不同 Session 之间保持独立。
  • 每条 durable root-Turn admission 显式记录 previousRootTurnId。恢复时根据 predecessor fact 重建唯一线性链,不再根据时间戳推断顺序;missing predecessor、multiple roots、branch 和 disconnected cycle 都会被拒绝。
  • RootAdmissionOwner 成为单个 Host Epoch 内 recovered admission identity 与当前 chain tip 的唯一 owner。只有 Store 返回有效 durable result 后才推进 tip。
  • 如果 durable write 可能已经 commit、但随后报告失败,则在本 Host Epoch 内 poison 该 Session。已经排队的 successor 会在触碰 Store 前失败;新 Host Epoch 再从磁盘恢复 canonical chain。这样可以避免沿 stale tip 写出 sibling admission,也无需引入通用恢复机制。

实验性的 root-admission 持久记录因 predecessor fact 升至 schema version 2。它是存储记录 schema,与 v0 wire protocol 相互独立;非生产状态不增加兼容层。

Session Store 关闭完成语义

#1373 将 Session metadata 迁移到 SQLite 后,SessionStore.close() 改为异步且幂等:它会先等待已经启动的 metadata import settle,再关闭 SQLite。Runtime Host、Desktop 与 CLI 的 shutdown 路径都会等待该 completion,避免 owner teardown 与 import 竞态。

验证证据

覆盖范围包括封闭 catalog 与 handler composition、bootstrap/ready dispatch、两个真实 Client 竞争同一个 Session、response 丢失后重启 Host、同毫秒顺序、畸形 durable graph、真实 Store 先 commit admission 再抛错,以及真实 JSONL-to-SQLite import 后立即 close。

Storage 通过 443 项测试,另有 1 项既有 Windows-only skip;Runtime Host 72 项全部通过。全 workspace typecheck、受影响文件的 Biome check 与 git diff --check 也均通过。

范围

本 foundation 刻意不加入 Message、canonical projection、continuity、Interaction、automation/goal ownership、production surface wiring 或 M4 stale-Host activation gate。这些内容会在该前置合并后,随各自所属 slice 推进。

属于 #1167;关联 #853

@likun666661likun666661 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the protocol/dispatcher and root-admission changes.

The closed operation catalog now consistently validates requests, responses, declared errors, and handler composition, while lifecycle availability is enforced during recovery. The SessionAdmissionGate, explicit predecessor chain, and RootAdmissionOwner establish a coherent per-session serialization and fail-closed recovery model, including ambiguous post-commit failures.

The change remains properly scoped to non-serving foundation work. CI is green, and the targeted Storage and Runtime Host tests cover concurrency, restart recovery, malformed durable graphs, and response-loss retry semantics.

I found no blocking issues. Approved.

@M4n5ter
M4n5terforce-pushed the feat/runtime-host-protocol-admission-foundation branch from 40bbdcc to 414be18CompareJuly 23, 2026 07:56
@Astro-Han
Astro-Han merged commit 992b04c into apache:mainJul 23, 2026
3 checks passed
@M4n5ter
M4n5ter deleted the feat/runtime-host-protocol-admission-foundation branch July 23, 2026 09:24
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.

3 participants

@M4n5ter@likun666661@Astro-Han
, '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); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' feat(runtime-host): establish protocol and admission foundations by M4n5ter · Pull Request #1356 · apache/maka · GitHub
Skip to content

feat(runtime-host): establish protocol and admission foundations - #1356

Merged
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation
Jul 23, 2026
Merged

feat(runtime-host): establish protocol and admission foundations#1356
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation

Conversation

@M4n5ter

@M4n5terM4n5ter commented Jul 22, 2026

Copy link
Copy Markdown
Member
English

Context

This PR establishes the protocol/dispatcher and root-admission foundation required by the Runtime Host Session-core migration tracked in #1167.

The Host is still non-serving in production; this PR does not switch any Desktop, TUI, CLI, or Headless entrypoint.

What changes

Closed operation protocol

  • Split the operation catalog into typed domain specifications with exact input, output, error, lifecycle-availability, and command/query contracts.
  • Decode requests, responses, and handler outcomes against the same closed catalog. Unknown operations, undeclared errors, extra fields, malformed handler outcomes, and incomplete or duplicate handler composition fail closed.
  • Keep host.status available during bootstrap/recovery while ready-only operations return the existing typed host_not_ready failure.
  • Remove the unused retry/admission metadata instead of carrying fields with no consumer or recovery contract. The Kernel now consumes only the lifecycle availability and command mode that affect behavior.
  • Keep the unreleased wire protocol at v0; there is no production compatibility surface yet.

Root admission authority

  • Extract a shared SessionAdmissionGate: operations for one Session serialize, while different Sessions remain independent.
  • Give each durable root-Turn admission an explicit previousRootTurnId. Recovery reconstructs one linear chain from predecessor facts instead of inferring order from timestamps, and rejects missing predecessors, multiple roots, branches, or disconnected cycles.
  • Make RootAdmissionOwner the single in-Epoch owner of recovered admission identity and the current chain tip. It advances only after the Store returns a valid durable result.
  • If a durable write may have committed before reporting failure, poison that Session for the rest of the Host Epoch. Queued successors fail before touching the Store; a new Host Epoch recovers the canonical chain from disk. This avoids extending a stale tip into sibling admissions without introducing a general recovery mechanism.

The experimental root-admission record moves to schema version 2 for the predecessor fact. This is a storage-record schema, separate from the v0 wire protocol, and no compatibility layer is added for non-production state.

Session-store shutdown completion

After the SQLite Session metadata migration in #1373, SessionStore.close() is asynchronous and idempotent: it waits for the already-started metadata import to settle before closing SQLite. Runtime Host, Desktop, and CLI shutdown paths await that completion, so owner teardown cannot race the import.

Evidence

Coverage includes closed catalog and handler composition, bootstrap-versus-ready dispatch, two real Clients racing one Session, response loss followed by Host restart, same-millisecond ordering, malformed durable graphs, a real Store that commits an admission and then throws, and a real JSONL-to-SQLite import immediately followed by close.

Storage passes 443 tests with one existing Windows-only skip; Runtime Host passes all 72 tests. The full workspace typecheck, affected Biome checks, and git diff --check also pass.

Scope

This foundation intentionally does not add Message, canonical projection, continuity, Interaction, automation/goal ownership, production surface wiring, or the M4 stale-Host activation gate. Those remain in their owning slices after this prerequisite.

Part of #1167. Related to #853.

简体中文

背景

本 PR 建立 Runtime Host Session core 迁移所需的 protocol/dispatcher 与 root-admission foundation,整体由 #1167 跟踪。

Runtime Host 仍未进入 production serving,本 PR 不切换 Desktop、TUI、CLI 或 Headless 的任何入口。

改动内容

封闭 operation protocol

  • 将 operation catalog 拆成带有精确 input、output、error、lifecycle availability 与 command/query 契约的 typed domain specification。
  • request、response 与 handler outcome 共用同一份封闭 catalog 解码。未知 operation、未声明 error、多余字段、畸形 handler outcome,以及缺失或重复的 handler composition 都会 fail closed。
  • host.status 在 bootstrap/recovery 阶段仍可使用;仅 ready 可用的 operation 继续返回已有的 typed host_not_ready failure。
  • 删除没有消费者和恢复契约的 retry/admission 元数据,不保留空语义字段。Kernel 只消费真正影响行为的 lifecycle availability 与 command mode。
  • wire protocol 保持未发布的 v0;当前还不存在 production compatibility surface。

Root admission authority

  • 提取共享的 SessionAdmissionGate:同一个 Session 的 operation 串行执行,不同 Session 之间保持独立。
  • 每条 durable root-Turn admission 显式记录 previousRootTurnId。恢复时根据 predecessor fact 重建唯一线性链,不再根据时间戳推断顺序;missing predecessor、multiple roots、branch 和 disconnected cycle 都会被拒绝。
  • RootAdmissionOwner 成为单个 Host Epoch 内 recovered admission identity 与当前 chain tip 的唯一 owner。只有 Store 返回有效 durable result 后才推进 tip。
  • 如果 durable write 可能已经 commit、但随后报告失败,则在本 Host Epoch 内 poison 该 Session。已经排队的 successor 会在触碰 Store 前失败;新 Host Epoch 再从磁盘恢复 canonical chain。这样可以避免沿 stale tip 写出 sibling admission,也无需引入通用恢复机制。

实验性的 root-admission 持久记录因 predecessor fact 升至 schema version 2。它是存储记录 schema,与 v0 wire protocol 相互独立;非生产状态不增加兼容层。

Session Store 关闭完成语义

#1373 将 Session metadata 迁移到 SQLite 后,SessionStore.close() 改为异步且幂等:它会先等待已经启动的 metadata import settle,再关闭 SQLite。Runtime Host、Desktop 与 CLI 的 shutdown 路径都会等待该 completion,避免 owner teardown 与 import 竞态。

验证证据

覆盖范围包括封闭 catalog 与 handler composition、bootstrap/ready dispatch、两个真实 Client 竞争同一个 Session、response 丢失后重启 Host、同毫秒顺序、畸形 durable graph、真实 Store 先 commit admission 再抛错,以及真实 JSONL-to-SQLite import 后立即 close。

Storage 通过 443 项测试,另有 1 项既有 Windows-only skip;Runtime Host 72 项全部通过。全 workspace typecheck、受影响文件的 Biome check 与 git diff --check 也均通过。

范围

本 foundation 刻意不加入 Message、canonical projection、continuity、Interaction、automation/goal ownership、production surface wiring 或 M4 stale-Host activation gate。这些内容会在该前置合并后,随各自所属 slice 推进。

属于 #1167;关联 #853

@likun666661likun666661 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the protocol/dispatcher and root-admission changes.

The closed operation catalog now consistently validates requests, responses, declared errors, and handler composition, while lifecycle availability is enforced during recovery. The SessionAdmissionGate, explicit predecessor chain, and RootAdmissionOwner establish a coherent per-session serialization and fail-closed recovery model, including ambiguous post-commit failures.

The change remains properly scoped to non-serving foundation work. CI is green, and the targeted Storage and Runtime Host tests cover concurrency, restart recovery, malformed durable graphs, and response-loss retry semantics.

I found no blocking issues. Approved.

@M4n5ter
M4n5terforce-pushed the feat/runtime-host-protocol-admission-foundation branch from 40bbdcc to 414be18CompareJuly 23, 2026 07:56
@Astro-Han
Astro-Han merged commit 992b04c into apache:mainJul 23, 2026
3 checks passed
@M4n5ter
M4n5ter deleted the feat/runtime-host-protocol-admission-foundation branch July 23, 2026 09:24
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.

3 participants

@M4n5ter@likun666661@Astro-Han
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); feat(runtime-host): establish protocol and admission foundations by M4n5ter · Pull Request #1356 · apache/maka · GitHub
Skip to content

feat(runtime-host): establish protocol and admission foundations - #1356

Merged
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation
Jul 23, 2026
Merged

feat(runtime-host): establish protocol and admission foundations#1356
Astro-Han merged 4 commits into
apache:mainfrom
M4n5ter:feat/runtime-host-protocol-admission-foundation

Conversation

@M4n5ter

@M4n5terM4n5ter commented Jul 22, 2026

Copy link
Copy Markdown
Member
English

Context

This PR establishes the protocol/dispatcher and root-admission foundation required by the Runtime Host Session-core migration tracked in #1167.

The Host is still non-serving in production; this PR does not switch any Desktop, TUI, CLI, or Headless entrypoint.

What changes

Closed operation protocol

  • Split the operation catalog into typed domain specifications with exact input, output, error, lifecycle-availability, and command/query contracts.
  • Decode requests, responses, and handler outcomes against the same closed catalog. Unknown operations, undeclared errors, extra fields, malformed handler outcomes, and incomplete or duplicate handler composition fail closed.
  • Keep host.status available during bootstrap/recovery while ready-only operations return the existing typed host_not_ready failure.
  • Remove the unused retry/admission metadata instead of carrying fields with no consumer or recovery contract. The Kernel now consumes only the lifecycle availability and command mode that affect behavior.
  • Keep the unreleased wire protocol at v0; there is no production compatibility surface yet.

Root admission authority

  • Extract a shared SessionAdmissionGate: operations for one Session serialize, while different Sessions remain independent.
  • Give each durable root-Turn admission an explicit previousRootTurnId. Recovery reconstructs one linear chain from predecessor facts instead of inferring order from timestamps, and rejects missing predecessors, multiple roots, branches, or disconnected cycles.
  • Make RootAdmissionOwner the single in-Epoch owner of recovered admission identity and the current chain tip. It advances only after the Store returns a valid durable result.
  • If a durable write may have committed before reporting failure, poison that Session for the rest of the Host Epoch. Queued successors fail before touching the Store; a new Host Epoch recovers the canonical chain from disk. This avoids extending a stale tip into sibling admissions without introducing a general recovery mechanism.

The experimental root-admission record moves to schema version 2 for the predecessor fact. This is a storage-record schema, separate from the v0 wire protocol, and no compatibility layer is added for non-production state.

Session-store shutdown completion

After the SQLite Session metadata migration in #1373, SessionStore.close() is asynchronous and idempotent: it waits for the already-started metadata import to settle before closing SQLite. Runtime Host, Desktop, and CLI shutdown paths await that completion, so owner teardown cannot race the import.

Evidence

Coverage includes closed catalog and handler composition, bootstrap-versus-ready dispatch, two real Clients racing one Session, response loss followed by Host restart, same-millisecond ordering, malformed durable graphs, a real Store that commits an admission and then throws, and a real JSONL-to-SQLite import immediately followed by close.

Storage passes 443 tests with one existing Windows-only skip; Runtime Host passes all 72 tests. The full workspace typecheck, affected Biome checks, and git diff --check also pass.

Scope

This foundation intentionally does not add Message, canonical projection, continuity, Interaction, automation/goal ownership, production surface wiring, or the M4 stale-Host activation gate. Those remain in their owning slices after this prerequisite.

Part of #1167. Related to #853.

简体中文

背景

本 PR 建立 Runtime Host Session core 迁移所需的 protocol/dispatcher 与 root-admission foundation,整体由 #1167 跟踪。

Runtime Host 仍未进入 production serving,本 PR 不切换 Desktop、TUI、CLI 或 Headless 的任何入口。

改动内容

封闭 operation protocol

  • 将 operation catalog 拆成带有精确 input、output、error、lifecycle availability 与 command/query 契约的 typed domain specification。
  • request、response 与 handler outcome 共用同一份封闭 catalog 解码。未知 operation、未声明 error、多余字段、畸形 handler outcome,以及缺失或重复的 handler composition 都会 fail closed。
  • host.status 在 bootstrap/recovery 阶段仍可使用;仅 ready 可用的 operation 继续返回已有的 typed host_not_ready failure。
  • 删除没有消费者和恢复契约的 retry/admission 元数据,不保留空语义字段。Kernel 只消费真正影响行为的 lifecycle availability 与 command mode。
  • wire protocol 保持未发布的 v0;当前还不存在 production compatibility surface。

Root admission authority

  • 提取共享的 SessionAdmissionGate:同一个 Session 的 operation 串行执行,不同 Session 之间保持独立。
  • 每条 durable root-Turn admission 显式记录 previousRootTurnId。恢复时根据 predecessor fact 重建唯一线性链,不再根据时间戳推断顺序;missing predecessor、multiple roots、branch 和 disconnected cycle 都会被拒绝。
  • RootAdmissionOwner 成为单个 Host Epoch 内 recovered admission identity 与当前 chain tip 的唯一 owner。只有 Store 返回有效 durable result 后才推进 tip。
  • 如果 durable write 可能已经 commit、但随后报告失败,则在本 Host Epoch 内 poison 该 Session。已经排队的 successor 会在触碰 Store 前失败;新 Host Epoch 再从磁盘恢复 canonical chain。这样可以避免沿 stale tip 写出 sibling admission,也无需引入通用恢复机制。

实验性的 root-admission 持久记录因 predecessor fact 升至 schema version 2。它是存储记录 schema,与 v0 wire protocol 相互独立;非生产状态不增加兼容层。

Session Store 关闭完成语义

#1373 将 Session metadata 迁移到 SQLite 后,SessionStore.close() 改为异步且幂等:它会先等待已经启动的 metadata import settle,再关闭 SQLite。Runtime Host、Desktop 与 CLI 的 shutdown 路径都会等待该 completion,避免 owner teardown 与 import 竞态。

验证证据

覆盖范围包括封闭 catalog 与 handler composition、bootstrap/ready dispatch、两个真实 Client 竞争同一个 Session、response 丢失后重启 Host、同毫秒顺序、畸形 durable graph、真实 Store 先 commit admission 再抛错,以及真实 JSONL-to-SQLite import 后立即 close。

Storage 通过 443 项测试,另有 1 项既有 Windows-only skip;Runtime Host 72 项全部通过。全 workspace typecheck、受影响文件的 Biome check 与 git diff --check 也均通过。

范围

本 foundation 刻意不加入 Message、canonical projection、continuity、Interaction、automation/goal ownership、production surface wiring 或 M4 stale-Host activation gate。这些内容会在该前置合并后,随各自所属 slice 推进。

属于 #1167;关联 #853

@likun666661likun666661 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the protocol/dispatcher and root-admission changes.

The closed operation catalog now consistently validates requests, responses, declared errors, and handler composition, while lifecycle availability is enforced during recovery. The SessionAdmissionGate, explicit predecessor chain, and RootAdmissionOwner establish a coherent per-session serialization and fail-closed recovery model, including ambiguous post-commit failures.

The change remains properly scoped to non-serving foundation work. CI is green, and the targeted Storage and Runtime Host tests cover concurrency, restart recovery, malformed durable graphs, and response-loss retry semantics.

I found no blocking issues. Approved.

@M4n5ter
M4n5terforce-pushed the feat/runtime-host-protocol-admission-foundation branch from 40bbdcc to 414be18CompareJuly 23, 2026 07:56
@Astro-Han
Astro-Han merged commit 992b04c into apache:mainJul 23, 2026
3 checks passed
@M4n5ter
M4n5ter deleted the feat/runtime-host-protocol-admission-foundation branch July 23, 2026 09:24
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.

3 participants

@M4n5ter@likun666661@Astro-Han