Skip to content

feat(cli): reconcile local Runtime Host generations - #3254

Draft
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff
Draft

feat(cli): reconcile local Runtime Host generations#3254
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff

Conversation

@me2seeks

@me2seeksme2seeks commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Current status

This Draft is paused as implementation and qualification evidence while #3709 and the #3228 reconciliation gates stabilize. It is not the target owner architecture and should not be marked Ready in its current form. The retained value is its generation/epoch diagnostics, Restart/Wait/Cancel UX, exact-epoch fencing, released-Host takeover adapter, and real PTY evidence. After the gates close, the implementation should be split or rewritten so replacement policy no longer lives in ordinary connectOrSpawn election.

简体中文

本 Draft 暂停实现,用作 #3709#3228 reconciliation gate 稳定前的实现和 qualification 证据。它不是目标 owner 架构,当前形态不应转为 Ready。需要保留的是 generation/epoch 诊断、Restart/Wait/Cancel UX、exact-epoch fencing、已发布 Host takeover adapter 与真实 PTY 证据。Gate 闭合后应拆分或重写实现,使 replacement policy 不再位于普通 connectOrSpawn election 中。

Convergence disposition

The branch has now been audited against the owner/transfer rules in #3709. When work resumes, it should be split or rewritten according to this inventory; the current Draft must not be merged as one lifecycle implementation.

Retain as evidence

  • real PTY Restart / Wait / Cancel scenarios across released compatibility epochs;
  • exact observed-HostEpoch fencing and stale-takeover rejection;
  • same-epoch compatibility evidence showing that build/deployment skew does not require replacement;
  • remote-profile and service-mode isolation;
  • bounded Host activity/residency diagnostics and explicit interruption warning;
  • invocation and cache-disappearance scenarios, rewritten against the selected npx contract.

Migrate behind the owner/reconciler seam

  • TUI conflict wording and decision parsing become a thin presentation adapter over typed connect | owner_transfer_required | wait | cancel | operator_required outcomes;
  • the handshake takeover path becomes a bounded released-Host capability adapter with an explicit removal condition;
  • package/provenance resolution becomes an input adapter that returns verified DeploymentIdentity; it does not decide authority;
  • candidate launch keeps exact deployment identity, but it is invoked by the owner transaction rather than ordinary connection election;
  • _npx detection remains a negative provenance guard shared with managed setup, never positive owner proof.

Delete or rewrite

  • replacement-policy fields and the extra exact-generation probe carried through ordinary connectOrSpawn;
  • installationScope === 'persistent' as replacement authority;
  • package version or a per-process development UUID as verified deployment identity;
  • the TUI-owned retry/replacement loop as a lifecycle state machine;
  • any last-launch-wins behavior or implication that a successful connection, package path, PID, version, or compatible epoch transfers ownership;
  • the branch-local architecture drafts in their current form once their durable decisions and qualification evidence are captured by architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709; they should not become a second target-architecture authority.

Simplification result

  • P0: none.
  • P1 — remove lifecycle authority from ordinary connection election.localGenerationRequest, candidateGeneration, and the TUI-owned retry loop currently form a parallel replacement path. Migrating the released-Host takeover mechanism behind one owner transaction lets these connection-level policy representations and the Surface state machine disappear while preserving compatibility admission and exact-epoch fencing.
  • P2 — remove proxy identities and proxy authority.installationScope === 'persistent' and version/development-UUID generation are maintained only to approximate facts now owned by the durable owner record and verified DeploymentIdentity. The shared _npx detector remains because managed setup and invocation policy still consume its negative provenance fact.
  • P2 — remove duplicate target-architecture documents from the eventual implementation PR.architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 is now the target architecture and decision authority. The PR should retain links, tests, and implementation-specific documentation, not another full lifecycle design whose Current/Planned status can drift.
  • Decision gate — legacy adapter removal. The handshake takeover path remains until the minimum supported released Host set exposes the stable owner-side lifecycle capability; the decisive evidence is the released-version support/qualification matrix.
  • Decision gate — rollback qualification. Previous-artifact retry cannot be simplified into unconditional rollback until fix(storage): retire completed legacy migration metadata #3227 proves the relevant storage transitions safe.

Audit coverage

SliceStatusDisposition
installation/provenance contextReviewedretain resolution seam and shared _npx guard; replace authority and identity inference
ordinary local connection/electionReviewedremove replacement policy; preserve compatibility admission
TUI conflict adapterReviewedretain presentation and decision vocabulary; migrate lifecycle ownership
Host handshake takeoverReviewedretain only as bounded legacy adapter
remote/service isolationReviewedretain unchanged operator boundary
unit/integration/PTY qualificationReviewedmigrate invariant and released-artifact evidence, not branch structure
branch architecture documentsReviewedconsolidate target authority in #3709; rewrite or remove duplicated Current claims
storage downgrade/recoveryPartialretain fail-closed boundary; exact qualification remains owned by #3227
简体中文

收敛处置清单

该分支已经按 #3709 的 owner/transfer 规则完成审计。恢复工作后,应依据以下清单拆分或重写;当前 Draft 不能作为一整套 lifecycle implementation 合并。

作为证据保留

  • 跨已发布 compatibility epoch 的真实 PTY Restart / Wait / Cancel 场景;
  • 绑定 observed HostEpoch 的精确 fencing 与 stale takeover rejection;
  • 证明 same-epoch build/deployment skew 不要求 replacement 的兼容性证据;
  • remote profile 与 service-mode 隔离;
  • 有界 Host activity/residency 诊断和明确 interruption warning;
  • invocation 与 cache disappearance 场景,但要按已选 npx contract 重写。

迁移到 owner/reconciler seam 后面

  • TUI conflict 文案与 decision parsing 变成 typed connect | owner_transfer_required | wait | cancel | operator_required outcome 的薄 presentation adapter;
  • handshake takeover 变成有明确删除条件的 bounded released-Host capability adapter;
  • package/provenance resolution 变成返回 verified DeploymentIdentity 的 input adapter,不再决定 authority;
  • candidate launch 保留 exact deployment identity,但由 owner transaction 调用,不再由普通 connection election 调用;
  • _npx detection 保留为与 managed setup 共享的负向 provenance guard,永远不是正向 owner proof。

删除或重写

  • 普通 connectOrSpawn 中携带的 replacement-policy 字段与额外 exact-generation probe;
  • installationScope === 'persistent' 当作 replacement authority;
  • 把 package version 或 process-scoped development UUID 当作 verified deployment identity;
  • 把 TUI-owned retry/replacement loop 当作 lifecycle state machine;
  • 任何 last-launch-wins 行为,以及“成功连接、package path、PID、version 或 compatible epoch 会转移 ownership”的暗示;
  • 当前形态的 branch-local architecture draft:其中长期有效的决定和 qualification 证据进入 architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 后,不应再形成第二个 target-architecture authority。

简化审计结果

  • P0: 无。
  • P1——从普通 connection election 删除 lifecycle authority。localGenerationRequestcandidateGeneration 与 TUI-owned retry loop 当前形成一条平行 replacement path。把 released-Host takeover mechanism 迁移到唯一 owner transaction 后,可以删除这些 connection-level policy representation 与 Surface state machine,同时保留 compatibility admission 和 exact-epoch fencing。
  • P2——删除代理 identity 与代理 authority。installationScope === 'persistent' 和 version/development-UUID generation 只是近似 durable owner record 与 verified DeploymentIdentity 应拥有的事实。共享 _npx detector 仍保留,因为 managed setup 与 invocation policy 真实消费它提供的负向 provenance fact。
  • P2——从最终 implementation PR 删除重复 target-architecture document。architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 已是目标架构与决策 authority。PR 应保留链接、测试和 implementation-specific 文档,而不是再维护一份 Current/Planned 状态可能漂移的完整 lifecycle design。
  • Decision gate——legacy adapter 删除时机。 在最低支持的 released Host 集合提供稳定 owner-side lifecycle capability 前,handshake takeover path 仍要保留;决定性证据是 released-version support/qualification matrix。
  • Decision gate——rollback qualification。fix(storage): retire completed legacy migration metadata #3227 证明相关 storage transition 安全前,previous-artifact retry 不能简化成无条件 rollback。

审计覆盖

Slice状态处置
installation/provenance contextReviewed保留 resolution seam 与共享 _npx guard;替换 authority/identity inference
普通 local connection/electionReviewed删除 replacement policy;保留 compatibility admission
TUI conflict adapterReviewed保留 presentation/decision vocabulary;迁移 lifecycle ownership
Host handshake takeoverReviewed仅作为 bounded legacy adapter 保留
remote/service isolationReviewed保持 operator boundary 不变
unit/integration/PTY qualificationReviewed迁移 invariant 与 released-artifact evidence,不迁移 branch structure
branch architecture documentsReviewedtarget authority 收敛到 #3709;重写或删除重复的 Current claim
storage downgrade/recoveryPartial保留 fail-closed boundary;精确 qualification 仍由 #3227 负责

Summary

Teach the local CLI/TUI to identify the installation that supplied its Runtime Host candidate and negotiate that candidate generation explicitly.

Compatible same-epoch Clients continue using the active Host even when builds differ. For a local cross-epoch conflict, TUI presents Restart, Wait, or Cancel using authoritative Host activity; Restart is fenced to the observed Host epoch. Remote profiles never receive local replacement authority, and transient npx launches cannot request takeover.

This is the first bounded slice of the installation lifecycle design. Artifact staging/switching, a public update command, same-epoch replacement, managed remote updates, and durable npx ownership remain out of scope.

Refs #3231
Refs #3243
Refs #3244
Refs #3245
Refs #3709

Verification

  • Biome check passed for the changed code and tests.
  • @maka/core, @maka/storage, @maka/mcp, @maka/runtime, @maka/runtime-host, and maka-agent builds passed.
  • Runtime Host and CLI typechecks passed.
  • Focused CLI/context, service guard, and Host candidate-generation tests passed (19/19).
  • Real PTY epoch 24 → 26 checks covered Restart, Wait, and Cancel while a Scheduled Task retained the old Host.
  • git diff --check passed.

Not run: full repository test suite or Desktop UI tests.

Draft scope

  • Resolve installation scope and artifact generation once per CLI launch
  • Admit compatible same-epoch Clients without replacing the Host
  • Fence explicit local takeover to the observed Host epoch
  • Keep remote and transient npx callers outside local replacement authority
  • Document Current, Planned, and Exploratory lifecycle boundaries
  • Review product wording and protocol ownership with maintainers
  • Add release-package and platform qualification before marking ready

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex assisted with architecture analysis, implementation, documentation, tests, and local review. The human contributor will review the Draft before it is submitted for merge.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@me2seeks
me2seeksforce-pushed the feat/cli-runtime-host-generation-handoff branch from f3c93a9 to d59f548CompareAugust 23, 2026 10:19
Main retired the client surface identity; the replayed generation-rejection
and election tests still passed it, breaking typecheck.
Generated-by: maka

@Astro-HanAstro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for keeping this Draft's status and convergence notes honest. I reviewed exact head 8a197b08ae50445b88ea5d671b977c821d072131 (14 files, +1294/-50).

The underlying problem is demonstrated: an older local Runtime Host can remain resident across a compatibility-epoch change, leaving a newer CLI unable to make progress. Exact observed-epoch fencing, authoritative activity diagnostics, remote/service/npx isolation, and the Restart / Wait / Cancel vocabulary are useful evidence worth preserving.

The current implementation, however, is no longer the right solution owner. It carries replacement policy through the ordinary TUI → CLI context → connectOrSpawn election path, using installation path/version/development UUID as proxy deployment identity. Current main now has durable deployment ownership, handoff, and owner-transaction seams; keeping this path would create a second lifecycle authority. By first principles, ordinary connection election should report typed compatibility facts, while the verified owner transaction performs retirement, replacement, and candidate launch.

So the correct disposition is not to repair this 1,294-line branch into a mergeable PR. Keep/migrate the exact-epoch and real-Host evidence, then delete or rewrite the branch-local replacement policy, TUI-owned retry state machine, proxy identity, fake-connector wiring tests, and roughly 754 lines of duplicate architecture drafts. #3709 should remain the single target-architecture authority.

I left the most concrete code findings inline:

  • P1:candidateGeneration / takeoverHostEpoch put replacement authority in ordinary connectOrSpawn;
  • P2: Restart is offered when connections === 0, although the Host also requires zero active operations/residencies, producing a recoverable conflict loop;
  • P1: the current head does not parse because join is imported twice.

There are additional current-head delivery failures: six new source/docs files lack ASF headers; tests still pass the retired surface field; and changed-file formatting fails. The exact head has no hosted checks and conflicts with current main. These reinforce the Draft status, but they are not a reason to preserve the obsolete architecture.

Next step: keep this Draft paused. Rebuild the smallest coherent slice behind the current owner/handoff seam, migrate only the valuable Host-kernel and released-artifact/PTTY evidence, remove duplicate architecture documents, then refresh exact-head CI and qualification. Do not simply rebase this branch and mark it Ready.

中文对照

感谢你在 Draft 正文里坦诚记录了当前状态和收敛方向。底层问题是真实的:旧版 Local Runtime Host 可能因为驻留任务跨 compatibility epoch 继续运行,导致新版 CLI 无法继续。精确 epoch fencing、Host activity 诊断、remote/service/npx 隔离,以及 Restart / Wait / Cancel 的交互词汇都值得保留。

但当前实现已经不再属于正确的 owner。它把 replacement policy 放进 TUI → CLI context → 普通 connectOrSpawn election,并使用安装路径、版本和 development UUID 近似 deployment identity。现在 main 已经有 durable owner、handoff 和 owner transaction;继续保留这条路径会形成第二套生命周期 authority。普通连接选举应只返回 typed compatibility facts,真正的 retirement、replacement 和 candidate launch 应由 verified owner transaction 完成。

因此,不建议把这 1294 行分支继续修成可合并 PR。应迁移 exact-epoch 和真实 Host 证据,然后删除或重写 branch-local replacement policy、TUI 自己维护的 retry state machine、代理 identity、只验证字段映射的 fake connector 测试,以及约 754 行重复架构草稿;#3709 保持唯一目标架构 authority。

当前 head 另外还存在重复 import、ASF header、退役测试字段和格式问题,并且与 main 冲突、没有 CI。这些都说明保持 Draft 是正确的,但不值得为了修这些表面问题继续保留旧架构。正确下一步是基于当前 owner/handoff seam 重建一个最小完整切片,只迁移有价值的 qualification 证据。


AI-assisted review notice: Codex coordinated independent review lanes; I verified the exact-head diff, current-main owner seams, reachability, and severity before publication. This does not replace the repository's required independent human approval.

protocol: ProtocolRange;
compositionId: string;
generation?: string;
candidateGeneration?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This makes ordinary connection election carry replacement policy. A non-npx path, package version, or development UUID is not verified deployment ownership, yet the TUI can turn those proxy facts into a generation takeover request. Current main has a durable owner/handoff transaction that is the natural authority for retirement and successor launch. Please keep connectOrSpawn as a compatibility-fact/admission seam and move this replacement action behind the verified owner transaction; otherwise the repository retains two lifecycle authorities.

const activity = error.conflict.handshake?.activity;
return error.conflict.kind === 'upgrade_required'
? error.conflict.restartable
: activity !== undefined && activity.connections === 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2 · category ①] connections === 0 is weaker than the Host's actual takeover condition, which also requires zero active operations and residencies. A normal scheduled-task residency can therefore make the TUI offer Restart, only for the Kernel to reject it and return the user to the same prompt. This is recoverable through Wait/Cancel, so P2 is the calibrated level. The thin adapter should consume an authoritative replacement disposition rather than re-derive idleness here.

import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { deriveMakaDataRoots, resolveMakaDataRoots } from './workspace-root.js';
import { join } from 'node:path';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This exact head imports join twice, so the CLI module fails to parse (Identifier 'join' has already been declared). The branch also retains unused imports around this edit. Please delete the duplicate/dead imports; if this code is rewritten behind the owner seam, avoid carrying this stale composition forward.

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

Labels

effort/XLOver 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@me2seeks@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(cli): reconcile local Runtime Host generations by me2seeks · Pull Request #3254 · apache/maka · GitHub
Skip to content

feat(cli): reconcile local Runtime Host generations - #3254

Draft
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff
Draft

feat(cli): reconcile local Runtime Host generations#3254
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff

Conversation

@me2seeks

@me2seeksme2seeks commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Current status

This Draft is paused as implementation and qualification evidence while #3709 and the #3228 reconciliation gates stabilize. It is not the target owner architecture and should not be marked Ready in its current form. The retained value is its generation/epoch diagnostics, Restart/Wait/Cancel UX, exact-epoch fencing, released-Host takeover adapter, and real PTY evidence. After the gates close, the implementation should be split or rewritten so replacement policy no longer lives in ordinary connectOrSpawn election.

简体中文

本 Draft 暂停实现,用作 #3709#3228 reconciliation gate 稳定前的实现和 qualification 证据。它不是目标 owner 架构,当前形态不应转为 Ready。需要保留的是 generation/epoch 诊断、Restart/Wait/Cancel UX、exact-epoch fencing、已发布 Host takeover adapter 与真实 PTY 证据。Gate 闭合后应拆分或重写实现,使 replacement policy 不再位于普通 connectOrSpawn election 中。

Convergence disposition

The branch has now been audited against the owner/transfer rules in #3709. When work resumes, it should be split or rewritten according to this inventory; the current Draft must not be merged as one lifecycle implementation.

Retain as evidence

  • real PTY Restart / Wait / Cancel scenarios across released compatibility epochs;
  • exact observed-HostEpoch fencing and stale-takeover rejection;
  • same-epoch compatibility evidence showing that build/deployment skew does not require replacement;
  • remote-profile and service-mode isolation;
  • bounded Host activity/residency diagnostics and explicit interruption warning;
  • invocation and cache-disappearance scenarios, rewritten against the selected npx contract.

Migrate behind the owner/reconciler seam

  • TUI conflict wording and decision parsing become a thin presentation adapter over typed connect | owner_transfer_required | wait | cancel | operator_required outcomes;
  • the handshake takeover path becomes a bounded released-Host capability adapter with an explicit removal condition;
  • package/provenance resolution becomes an input adapter that returns verified DeploymentIdentity; it does not decide authority;
  • candidate launch keeps exact deployment identity, but it is invoked by the owner transaction rather than ordinary connection election;
  • _npx detection remains a negative provenance guard shared with managed setup, never positive owner proof.

Delete or rewrite

  • replacement-policy fields and the extra exact-generation probe carried through ordinary connectOrSpawn;
  • installationScope === 'persistent' as replacement authority;
  • package version or a per-process development UUID as verified deployment identity;
  • the TUI-owned retry/replacement loop as a lifecycle state machine;
  • any last-launch-wins behavior or implication that a successful connection, package path, PID, version, or compatible epoch transfers ownership;
  • the branch-local architecture drafts in their current form once their durable decisions and qualification evidence are captured by architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709; they should not become a second target-architecture authority.

Simplification result

  • P0: none.
  • P1 — remove lifecycle authority from ordinary connection election.localGenerationRequest, candidateGeneration, and the TUI-owned retry loop currently form a parallel replacement path. Migrating the released-Host takeover mechanism behind one owner transaction lets these connection-level policy representations and the Surface state machine disappear while preserving compatibility admission and exact-epoch fencing.
  • P2 — remove proxy identities and proxy authority.installationScope === 'persistent' and version/development-UUID generation are maintained only to approximate facts now owned by the durable owner record and verified DeploymentIdentity. The shared _npx detector remains because managed setup and invocation policy still consume its negative provenance fact.
  • P2 — remove duplicate target-architecture documents from the eventual implementation PR.architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 is now the target architecture and decision authority. The PR should retain links, tests, and implementation-specific documentation, not another full lifecycle design whose Current/Planned status can drift.
  • Decision gate — legacy adapter removal. The handshake takeover path remains until the minimum supported released Host set exposes the stable owner-side lifecycle capability; the decisive evidence is the released-version support/qualification matrix.
  • Decision gate — rollback qualification. Previous-artifact retry cannot be simplified into unconditional rollback until fix(storage): retire completed legacy migration metadata #3227 proves the relevant storage transitions safe.

Audit coverage

SliceStatusDisposition
installation/provenance contextReviewedretain resolution seam and shared _npx guard; replace authority and identity inference
ordinary local connection/electionReviewedremove replacement policy; preserve compatibility admission
TUI conflict adapterReviewedretain presentation and decision vocabulary; migrate lifecycle ownership
Host handshake takeoverReviewedretain only as bounded legacy adapter
remote/service isolationReviewedretain unchanged operator boundary
unit/integration/PTY qualificationReviewedmigrate invariant and released-artifact evidence, not branch structure
branch architecture documentsReviewedconsolidate target authority in #3709; rewrite or remove duplicated Current claims
storage downgrade/recoveryPartialretain fail-closed boundary; exact qualification remains owned by #3227
简体中文

收敛处置清单

该分支已经按 #3709 的 owner/transfer 规则完成审计。恢复工作后,应依据以下清单拆分或重写;当前 Draft 不能作为一整套 lifecycle implementation 合并。

作为证据保留

  • 跨已发布 compatibility epoch 的真实 PTY Restart / Wait / Cancel 场景;
  • 绑定 observed HostEpoch 的精确 fencing 与 stale takeover rejection;
  • 证明 same-epoch build/deployment skew 不要求 replacement 的兼容性证据;
  • remote profile 与 service-mode 隔离;
  • 有界 Host activity/residency 诊断和明确 interruption warning;
  • invocation 与 cache disappearance 场景,但要按已选 npx contract 重写。

迁移到 owner/reconciler seam 后面

  • TUI conflict 文案与 decision parsing 变成 typed connect | owner_transfer_required | wait | cancel | operator_required outcome 的薄 presentation adapter;
  • handshake takeover 变成有明确删除条件的 bounded released-Host capability adapter;
  • package/provenance resolution 变成返回 verified DeploymentIdentity 的 input adapter,不再决定 authority;
  • candidate launch 保留 exact deployment identity,但由 owner transaction 调用,不再由普通 connection election 调用;
  • _npx detection 保留为与 managed setup 共享的负向 provenance guard,永远不是正向 owner proof。

删除或重写

  • 普通 connectOrSpawn 中携带的 replacement-policy 字段与额外 exact-generation probe;
  • installationScope === 'persistent' 当作 replacement authority;
  • 把 package version 或 process-scoped development UUID 当作 verified deployment identity;
  • 把 TUI-owned retry/replacement loop 当作 lifecycle state machine;
  • 任何 last-launch-wins 行为,以及“成功连接、package path、PID、version 或 compatible epoch 会转移 ownership”的暗示;
  • 当前形态的 branch-local architecture draft:其中长期有效的决定和 qualification 证据进入 architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 后,不应再形成第二个 target-architecture authority。

简化审计结果

  • P0: 无。
  • P1——从普通 connection election 删除 lifecycle authority。localGenerationRequestcandidateGeneration 与 TUI-owned retry loop 当前形成一条平行 replacement path。把 released-Host takeover mechanism 迁移到唯一 owner transaction 后,可以删除这些 connection-level policy representation 与 Surface state machine,同时保留 compatibility admission 和 exact-epoch fencing。
  • P2——删除代理 identity 与代理 authority。installationScope === 'persistent' 和 version/development-UUID generation 只是近似 durable owner record 与 verified DeploymentIdentity 应拥有的事实。共享 _npx detector 仍保留,因为 managed setup 与 invocation policy 真实消费它提供的负向 provenance fact。
  • P2——从最终 implementation PR 删除重复 target-architecture document。architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 已是目标架构与决策 authority。PR 应保留链接、测试和 implementation-specific 文档,而不是再维护一份 Current/Planned 状态可能漂移的完整 lifecycle design。
  • Decision gate——legacy adapter 删除时机。 在最低支持的 released Host 集合提供稳定 owner-side lifecycle capability 前,handshake takeover path 仍要保留;决定性证据是 released-version support/qualification matrix。
  • Decision gate——rollback qualification。fix(storage): retire completed legacy migration metadata #3227 证明相关 storage transition 安全前,previous-artifact retry 不能简化成无条件 rollback。

审计覆盖

Slice状态处置
installation/provenance contextReviewed保留 resolution seam 与共享 _npx guard;替换 authority/identity inference
普通 local connection/electionReviewed删除 replacement policy;保留 compatibility admission
TUI conflict adapterReviewed保留 presentation/decision vocabulary;迁移 lifecycle ownership
Host handshake takeoverReviewed仅作为 bounded legacy adapter 保留
remote/service isolationReviewed保持 operator boundary 不变
unit/integration/PTY qualificationReviewed迁移 invariant 与 released-artifact evidence,不迁移 branch structure
branch architecture documentsReviewedtarget authority 收敛到 #3709;重写或删除重复的 Current claim
storage downgrade/recoveryPartial保留 fail-closed boundary;精确 qualification 仍由 #3227 负责

Summary

Teach the local CLI/TUI to identify the installation that supplied its Runtime Host candidate and negotiate that candidate generation explicitly.

Compatible same-epoch Clients continue using the active Host even when builds differ. For a local cross-epoch conflict, TUI presents Restart, Wait, or Cancel using authoritative Host activity; Restart is fenced to the observed Host epoch. Remote profiles never receive local replacement authority, and transient npx launches cannot request takeover.

This is the first bounded slice of the installation lifecycle design. Artifact staging/switching, a public update command, same-epoch replacement, managed remote updates, and durable npx ownership remain out of scope.

Refs #3231
Refs #3243
Refs #3244
Refs #3245
Refs #3709

Verification

  • Biome check passed for the changed code and tests.
  • @maka/core, @maka/storage, @maka/mcp, @maka/runtime, @maka/runtime-host, and maka-agent builds passed.
  • Runtime Host and CLI typechecks passed.
  • Focused CLI/context, service guard, and Host candidate-generation tests passed (19/19).
  • Real PTY epoch 24 → 26 checks covered Restart, Wait, and Cancel while a Scheduled Task retained the old Host.
  • git diff --check passed.

Not run: full repository test suite or Desktop UI tests.

Draft scope

  • Resolve installation scope and artifact generation once per CLI launch
  • Admit compatible same-epoch Clients without replacing the Host
  • Fence explicit local takeover to the observed Host epoch
  • Keep remote and transient npx callers outside local replacement authority
  • Document Current, Planned, and Exploratory lifecycle boundaries
  • Review product wording and protocol ownership with maintainers
  • Add release-package and platform qualification before marking ready

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex assisted with architecture analysis, implementation, documentation, tests, and local review. The human contributor will review the Draft before it is submitted for merge.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@me2seeks
me2seeksforce-pushed the feat/cli-runtime-host-generation-handoff branch from f3c93a9 to d59f548CompareAugust 23, 2026 10:19
Main retired the client surface identity; the replayed generation-rejection
and election tests still passed it, breaking typecheck.
Generated-by: maka

@Astro-HanAstro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for keeping this Draft's status and convergence notes honest. I reviewed exact head 8a197b08ae50445b88ea5d671b977c821d072131 (14 files, +1294/-50).

The underlying problem is demonstrated: an older local Runtime Host can remain resident across a compatibility-epoch change, leaving a newer CLI unable to make progress. Exact observed-epoch fencing, authoritative activity diagnostics, remote/service/npx isolation, and the Restart / Wait / Cancel vocabulary are useful evidence worth preserving.

The current implementation, however, is no longer the right solution owner. It carries replacement policy through the ordinary TUI → CLI context → connectOrSpawn election path, using installation path/version/development UUID as proxy deployment identity. Current main now has durable deployment ownership, handoff, and owner-transaction seams; keeping this path would create a second lifecycle authority. By first principles, ordinary connection election should report typed compatibility facts, while the verified owner transaction performs retirement, replacement, and candidate launch.

So the correct disposition is not to repair this 1,294-line branch into a mergeable PR. Keep/migrate the exact-epoch and real-Host evidence, then delete or rewrite the branch-local replacement policy, TUI-owned retry state machine, proxy identity, fake-connector wiring tests, and roughly 754 lines of duplicate architecture drafts. #3709 should remain the single target-architecture authority.

I left the most concrete code findings inline:

  • P1:candidateGeneration / takeoverHostEpoch put replacement authority in ordinary connectOrSpawn;
  • P2: Restart is offered when connections === 0, although the Host also requires zero active operations/residencies, producing a recoverable conflict loop;
  • P1: the current head does not parse because join is imported twice.

There are additional current-head delivery failures: six new source/docs files lack ASF headers; tests still pass the retired surface field; and changed-file formatting fails. The exact head has no hosted checks and conflicts with current main. These reinforce the Draft status, but they are not a reason to preserve the obsolete architecture.

Next step: keep this Draft paused. Rebuild the smallest coherent slice behind the current owner/handoff seam, migrate only the valuable Host-kernel and released-artifact/PTTY evidence, remove duplicate architecture documents, then refresh exact-head CI and qualification. Do not simply rebase this branch and mark it Ready.

中文对照

感谢你在 Draft 正文里坦诚记录了当前状态和收敛方向。底层问题是真实的:旧版 Local Runtime Host 可能因为驻留任务跨 compatibility epoch 继续运行,导致新版 CLI 无法继续。精确 epoch fencing、Host activity 诊断、remote/service/npx 隔离,以及 Restart / Wait / Cancel 的交互词汇都值得保留。

但当前实现已经不再属于正确的 owner。它把 replacement policy 放进 TUI → CLI context → 普通 connectOrSpawn election,并使用安装路径、版本和 development UUID 近似 deployment identity。现在 main 已经有 durable owner、handoff 和 owner transaction;继续保留这条路径会形成第二套生命周期 authority。普通连接选举应只返回 typed compatibility facts,真正的 retirement、replacement 和 candidate launch 应由 verified owner transaction 完成。

因此,不建议把这 1294 行分支继续修成可合并 PR。应迁移 exact-epoch 和真实 Host 证据,然后删除或重写 branch-local replacement policy、TUI 自己维护的 retry state machine、代理 identity、只验证字段映射的 fake connector 测试,以及约 754 行重复架构草稿;#3709 保持唯一目标架构 authority。

当前 head 另外还存在重复 import、ASF header、退役测试字段和格式问题,并且与 main 冲突、没有 CI。这些都说明保持 Draft 是正确的,但不值得为了修这些表面问题继续保留旧架构。正确下一步是基于当前 owner/handoff seam 重建一个最小完整切片,只迁移有价值的 qualification 证据。


AI-assisted review notice: Codex coordinated independent review lanes; I verified the exact-head diff, current-main owner seams, reachability, and severity before publication. This does not replace the repository's required independent human approval.

protocol: ProtocolRange;
compositionId: string;
generation?: string;
candidateGeneration?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This makes ordinary connection election carry replacement policy. A non-npx path, package version, or development UUID is not verified deployment ownership, yet the TUI can turn those proxy facts into a generation takeover request. Current main has a durable owner/handoff transaction that is the natural authority for retirement and successor launch. Please keep connectOrSpawn as a compatibility-fact/admission seam and move this replacement action behind the verified owner transaction; otherwise the repository retains two lifecycle authorities.

const activity = error.conflict.handshake?.activity;
return error.conflict.kind === 'upgrade_required'
? error.conflict.restartable
: activity !== undefined && activity.connections === 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2 · category ①] connections === 0 is weaker than the Host's actual takeover condition, which also requires zero active operations and residencies. A normal scheduled-task residency can therefore make the TUI offer Restart, only for the Kernel to reject it and return the user to the same prompt. This is recoverable through Wait/Cancel, so P2 is the calibrated level. The thin adapter should consume an authoritative replacement disposition rather than re-derive idleness here.

import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { deriveMakaDataRoots, resolveMakaDataRoots } from './workspace-root.js';
import { join } from 'node:path';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This exact head imports join twice, so the CLI module fails to parse (Identifier 'join' has already been declared). The branch also retains unused imports around this edit. Please delete the duplicate/dead imports; if this code is rewritten behind the owner seam, avoid carrying this stale composition forward.

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

Labels

effort/XLOver 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@me2seeks@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(cli): reconcile local Runtime Host generations by me2seeks · Pull Request #3254 · apache/maka · GitHub
Skip to content

feat(cli): reconcile local Runtime Host generations - #3254

Draft
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff
Draft

feat(cli): reconcile local Runtime Host generations#3254
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff

Conversation

@me2seeks

@me2seeksme2seeks commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Current status

This Draft is paused as implementation and qualification evidence while #3709 and the #3228 reconciliation gates stabilize. It is not the target owner architecture and should not be marked Ready in its current form. The retained value is its generation/epoch diagnostics, Restart/Wait/Cancel UX, exact-epoch fencing, released-Host takeover adapter, and real PTY evidence. After the gates close, the implementation should be split or rewritten so replacement policy no longer lives in ordinary connectOrSpawn election.

简体中文

本 Draft 暂停实现,用作 #3709#3228 reconciliation gate 稳定前的实现和 qualification 证据。它不是目标 owner 架构,当前形态不应转为 Ready。需要保留的是 generation/epoch 诊断、Restart/Wait/Cancel UX、exact-epoch fencing、已发布 Host takeover adapter 与真实 PTY 证据。Gate 闭合后应拆分或重写实现,使 replacement policy 不再位于普通 connectOrSpawn election 中。

Convergence disposition

The branch has now been audited against the owner/transfer rules in #3709. When work resumes, it should be split or rewritten according to this inventory; the current Draft must not be merged as one lifecycle implementation.

Retain as evidence

  • real PTY Restart / Wait / Cancel scenarios across released compatibility epochs;
  • exact observed-HostEpoch fencing and stale-takeover rejection;
  • same-epoch compatibility evidence showing that build/deployment skew does not require replacement;
  • remote-profile and service-mode isolation;
  • bounded Host activity/residency diagnostics and explicit interruption warning;
  • invocation and cache-disappearance scenarios, rewritten against the selected npx contract.

Migrate behind the owner/reconciler seam

  • TUI conflict wording and decision parsing become a thin presentation adapter over typed connect | owner_transfer_required | wait | cancel | operator_required outcomes;
  • the handshake takeover path becomes a bounded released-Host capability adapter with an explicit removal condition;
  • package/provenance resolution becomes an input adapter that returns verified DeploymentIdentity; it does not decide authority;
  • candidate launch keeps exact deployment identity, but it is invoked by the owner transaction rather than ordinary connection election;
  • _npx detection remains a negative provenance guard shared with managed setup, never positive owner proof.

Delete or rewrite

  • replacement-policy fields and the extra exact-generation probe carried through ordinary connectOrSpawn;
  • installationScope === 'persistent' as replacement authority;
  • package version or a per-process development UUID as verified deployment identity;
  • the TUI-owned retry/replacement loop as a lifecycle state machine;
  • any last-launch-wins behavior or implication that a successful connection, package path, PID, version, or compatible epoch transfers ownership;
  • the branch-local architecture drafts in their current form once their durable decisions and qualification evidence are captured by architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709; they should not become a second target-architecture authority.

Simplification result

  • P0: none.
  • P1 — remove lifecycle authority from ordinary connection election.localGenerationRequest, candidateGeneration, and the TUI-owned retry loop currently form a parallel replacement path. Migrating the released-Host takeover mechanism behind one owner transaction lets these connection-level policy representations and the Surface state machine disappear while preserving compatibility admission and exact-epoch fencing.
  • P2 — remove proxy identities and proxy authority.installationScope === 'persistent' and version/development-UUID generation are maintained only to approximate facts now owned by the durable owner record and verified DeploymentIdentity. The shared _npx detector remains because managed setup and invocation policy still consume its negative provenance fact.
  • P2 — remove duplicate target-architecture documents from the eventual implementation PR.architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 is now the target architecture and decision authority. The PR should retain links, tests, and implementation-specific documentation, not another full lifecycle design whose Current/Planned status can drift.
  • Decision gate — legacy adapter removal. The handshake takeover path remains until the minimum supported released Host set exposes the stable owner-side lifecycle capability; the decisive evidence is the released-version support/qualification matrix.
  • Decision gate — rollback qualification. Previous-artifact retry cannot be simplified into unconditional rollback until fix(storage): retire completed legacy migration metadata #3227 proves the relevant storage transitions safe.

Audit coverage

SliceStatusDisposition
installation/provenance contextReviewedretain resolution seam and shared _npx guard; replace authority and identity inference
ordinary local connection/electionReviewedremove replacement policy; preserve compatibility admission
TUI conflict adapterReviewedretain presentation and decision vocabulary; migrate lifecycle ownership
Host handshake takeoverReviewedretain only as bounded legacy adapter
remote/service isolationReviewedretain unchanged operator boundary
unit/integration/PTY qualificationReviewedmigrate invariant and released-artifact evidence, not branch structure
branch architecture documentsReviewedconsolidate target authority in #3709; rewrite or remove duplicated Current claims
storage downgrade/recoveryPartialretain fail-closed boundary; exact qualification remains owned by #3227
简体中文

收敛处置清单

该分支已经按 #3709 的 owner/transfer 规则完成审计。恢复工作后,应依据以下清单拆分或重写;当前 Draft 不能作为一整套 lifecycle implementation 合并。

作为证据保留

  • 跨已发布 compatibility epoch 的真实 PTY Restart / Wait / Cancel 场景;
  • 绑定 observed HostEpoch 的精确 fencing 与 stale takeover rejection;
  • 证明 same-epoch build/deployment skew 不要求 replacement 的兼容性证据;
  • remote profile 与 service-mode 隔离;
  • 有界 Host activity/residency 诊断和明确 interruption warning;
  • invocation 与 cache disappearance 场景,但要按已选 npx contract 重写。

迁移到 owner/reconciler seam 后面

  • TUI conflict 文案与 decision parsing 变成 typed connect | owner_transfer_required | wait | cancel | operator_required outcome 的薄 presentation adapter;
  • handshake takeover 变成有明确删除条件的 bounded released-Host capability adapter;
  • package/provenance resolution 变成返回 verified DeploymentIdentity 的 input adapter,不再决定 authority;
  • candidate launch 保留 exact deployment identity,但由 owner transaction 调用,不再由普通 connection election 调用;
  • _npx detection 保留为与 managed setup 共享的负向 provenance guard,永远不是正向 owner proof。

删除或重写

  • 普通 connectOrSpawn 中携带的 replacement-policy 字段与额外 exact-generation probe;
  • installationScope === 'persistent' 当作 replacement authority;
  • 把 package version 或 process-scoped development UUID 当作 verified deployment identity;
  • 把 TUI-owned retry/replacement loop 当作 lifecycle state machine;
  • 任何 last-launch-wins 行为,以及“成功连接、package path、PID、version 或 compatible epoch 会转移 ownership”的暗示;
  • 当前形态的 branch-local architecture draft:其中长期有效的决定和 qualification 证据进入 architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 后,不应再形成第二个 target-architecture authority。

简化审计结果

  • P0: 无。
  • P1——从普通 connection election 删除 lifecycle authority。localGenerationRequestcandidateGeneration 与 TUI-owned retry loop 当前形成一条平行 replacement path。把 released-Host takeover mechanism 迁移到唯一 owner transaction 后,可以删除这些 connection-level policy representation 与 Surface state machine,同时保留 compatibility admission 和 exact-epoch fencing。
  • P2——删除代理 identity 与代理 authority。installationScope === 'persistent' 和 version/development-UUID generation 只是近似 durable owner record 与 verified DeploymentIdentity 应拥有的事实。共享 _npx detector 仍保留,因为 managed setup 与 invocation policy 真实消费它提供的负向 provenance fact。
  • P2——从最终 implementation PR 删除重复 target-architecture document。architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 已是目标架构与决策 authority。PR 应保留链接、测试和 implementation-specific 文档,而不是再维护一份 Current/Planned 状态可能漂移的完整 lifecycle design。
  • Decision gate——legacy adapter 删除时机。 在最低支持的 released Host 集合提供稳定 owner-side lifecycle capability 前,handshake takeover path 仍要保留;决定性证据是 released-version support/qualification matrix。
  • Decision gate——rollback qualification。fix(storage): retire completed legacy migration metadata #3227 证明相关 storage transition 安全前,previous-artifact retry 不能简化成无条件 rollback。

审计覆盖

Slice状态处置
installation/provenance contextReviewed保留 resolution seam 与共享 _npx guard;替换 authority/identity inference
普通 local connection/electionReviewed删除 replacement policy;保留 compatibility admission
TUI conflict adapterReviewed保留 presentation/decision vocabulary;迁移 lifecycle ownership
Host handshake takeoverReviewed仅作为 bounded legacy adapter 保留
remote/service isolationReviewed保持 operator boundary 不变
unit/integration/PTY qualificationReviewed迁移 invariant 与 released-artifact evidence,不迁移 branch structure
branch architecture documentsReviewedtarget authority 收敛到 #3709;重写或删除重复的 Current claim
storage downgrade/recoveryPartial保留 fail-closed boundary;精确 qualification 仍由 #3227 负责

Summary

Teach the local CLI/TUI to identify the installation that supplied its Runtime Host candidate and negotiate that candidate generation explicitly.

Compatible same-epoch Clients continue using the active Host even when builds differ. For a local cross-epoch conflict, TUI presents Restart, Wait, or Cancel using authoritative Host activity; Restart is fenced to the observed Host epoch. Remote profiles never receive local replacement authority, and transient npx launches cannot request takeover.

This is the first bounded slice of the installation lifecycle design. Artifact staging/switching, a public update command, same-epoch replacement, managed remote updates, and durable npx ownership remain out of scope.

Refs #3231
Refs #3243
Refs #3244
Refs #3245
Refs #3709

Verification

  • Biome check passed for the changed code and tests.
  • @maka/core, @maka/storage, @maka/mcp, @maka/runtime, @maka/runtime-host, and maka-agent builds passed.
  • Runtime Host and CLI typechecks passed.
  • Focused CLI/context, service guard, and Host candidate-generation tests passed (19/19).
  • Real PTY epoch 24 → 26 checks covered Restart, Wait, and Cancel while a Scheduled Task retained the old Host.
  • git diff --check passed.

Not run: full repository test suite or Desktop UI tests.

Draft scope

  • Resolve installation scope and artifact generation once per CLI launch
  • Admit compatible same-epoch Clients without replacing the Host
  • Fence explicit local takeover to the observed Host epoch
  • Keep remote and transient npx callers outside local replacement authority
  • Document Current, Planned, and Exploratory lifecycle boundaries
  • Review product wording and protocol ownership with maintainers
  • Add release-package and platform qualification before marking ready

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex assisted with architecture analysis, implementation, documentation, tests, and local review. The human contributor will review the Draft before it is submitted for merge.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@me2seeks
me2seeksforce-pushed the feat/cli-runtime-host-generation-handoff branch from f3c93a9 to d59f548CompareAugust 23, 2026 10:19
Main retired the client surface identity; the replayed generation-rejection
and election tests still passed it, breaking typecheck.
Generated-by: maka

@Astro-HanAstro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for keeping this Draft's status and convergence notes honest. I reviewed exact head 8a197b08ae50445b88ea5d671b977c821d072131 (14 files, +1294/-50).

The underlying problem is demonstrated: an older local Runtime Host can remain resident across a compatibility-epoch change, leaving a newer CLI unable to make progress. Exact observed-epoch fencing, authoritative activity diagnostics, remote/service/npx isolation, and the Restart / Wait / Cancel vocabulary are useful evidence worth preserving.

The current implementation, however, is no longer the right solution owner. It carries replacement policy through the ordinary TUI → CLI context → connectOrSpawn election path, using installation path/version/development UUID as proxy deployment identity. Current main now has durable deployment ownership, handoff, and owner-transaction seams; keeping this path would create a second lifecycle authority. By first principles, ordinary connection election should report typed compatibility facts, while the verified owner transaction performs retirement, replacement, and candidate launch.

So the correct disposition is not to repair this 1,294-line branch into a mergeable PR. Keep/migrate the exact-epoch and real-Host evidence, then delete or rewrite the branch-local replacement policy, TUI-owned retry state machine, proxy identity, fake-connector wiring tests, and roughly 754 lines of duplicate architecture drafts. #3709 should remain the single target-architecture authority.

I left the most concrete code findings inline:

  • P1:candidateGeneration / takeoverHostEpoch put replacement authority in ordinary connectOrSpawn;
  • P2: Restart is offered when connections === 0, although the Host also requires zero active operations/residencies, producing a recoverable conflict loop;
  • P1: the current head does not parse because join is imported twice.

There are additional current-head delivery failures: six new source/docs files lack ASF headers; tests still pass the retired surface field; and changed-file formatting fails. The exact head has no hosted checks and conflicts with current main. These reinforce the Draft status, but they are not a reason to preserve the obsolete architecture.

Next step: keep this Draft paused. Rebuild the smallest coherent slice behind the current owner/handoff seam, migrate only the valuable Host-kernel and released-artifact/PTTY evidence, remove duplicate architecture documents, then refresh exact-head CI and qualification. Do not simply rebase this branch and mark it Ready.

中文对照

感谢你在 Draft 正文里坦诚记录了当前状态和收敛方向。底层问题是真实的:旧版 Local Runtime Host 可能因为驻留任务跨 compatibility epoch 继续运行,导致新版 CLI 无法继续。精确 epoch fencing、Host activity 诊断、remote/service/npx 隔离,以及 Restart / Wait / Cancel 的交互词汇都值得保留。

但当前实现已经不再属于正确的 owner。它把 replacement policy 放进 TUI → CLI context → 普通 connectOrSpawn election,并使用安装路径、版本和 development UUID 近似 deployment identity。现在 main 已经有 durable owner、handoff 和 owner transaction;继续保留这条路径会形成第二套生命周期 authority。普通连接选举应只返回 typed compatibility facts,真正的 retirement、replacement 和 candidate launch 应由 verified owner transaction 完成。

因此,不建议把这 1294 行分支继续修成可合并 PR。应迁移 exact-epoch 和真实 Host 证据,然后删除或重写 branch-local replacement policy、TUI 自己维护的 retry state machine、代理 identity、只验证字段映射的 fake connector 测试,以及约 754 行重复架构草稿;#3709 保持唯一目标架构 authority。

当前 head 另外还存在重复 import、ASF header、退役测试字段和格式问题,并且与 main 冲突、没有 CI。这些都说明保持 Draft 是正确的,但不值得为了修这些表面问题继续保留旧架构。正确下一步是基于当前 owner/handoff seam 重建一个最小完整切片,只迁移有价值的 qualification 证据。


AI-assisted review notice: Codex coordinated independent review lanes; I verified the exact-head diff, current-main owner seams, reachability, and severity before publication. This does not replace the repository's required independent human approval.

protocol: ProtocolRange;
compositionId: string;
generation?: string;
candidateGeneration?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This makes ordinary connection election carry replacement policy. A non-npx path, package version, or development UUID is not verified deployment ownership, yet the TUI can turn those proxy facts into a generation takeover request. Current main has a durable owner/handoff transaction that is the natural authority for retirement and successor launch. Please keep connectOrSpawn as a compatibility-fact/admission seam and move this replacement action behind the verified owner transaction; otherwise the repository retains two lifecycle authorities.

const activity = error.conflict.handshake?.activity;
return error.conflict.kind === 'upgrade_required'
? error.conflict.restartable
: activity !== undefined && activity.connections === 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2 · category ①] connections === 0 is weaker than the Host's actual takeover condition, which also requires zero active operations and residencies. A normal scheduled-task residency can therefore make the TUI offer Restart, only for the Kernel to reject it and return the user to the same prompt. This is recoverable through Wait/Cancel, so P2 is the calibrated level. The thin adapter should consume an authoritative replacement disposition rather than re-derive idleness here.

import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { deriveMakaDataRoots, resolveMakaDataRoots } from './workspace-root.js';
import { join } from 'node:path';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This exact head imports join twice, so the CLI module fails to parse (Identifier 'join' has already been declared). The branch also retains unused imports around this edit. Please delete the duplicate/dead imports; if this code is rewritten behind the owner seam, avoid carrying this stale composition forward.

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

Labels

effort/XLOver 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@me2seeks@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(cli): reconcile local Runtime Host generations by me2seeks · Pull Request #3254 · apache/maka · GitHub
Skip to content

feat(cli): reconcile local Runtime Host generations - #3254

Draft
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff
Draft

feat(cli): reconcile local Runtime Host generations#3254
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff

Conversation

@me2seeks

@me2seeksme2seeks commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Current status

This Draft is paused as implementation and qualification evidence while #3709 and the #3228 reconciliation gates stabilize. It is not the target owner architecture and should not be marked Ready in its current form. The retained value is its generation/epoch diagnostics, Restart/Wait/Cancel UX, exact-epoch fencing, released-Host takeover adapter, and real PTY evidence. After the gates close, the implementation should be split or rewritten so replacement policy no longer lives in ordinary connectOrSpawn election.

简体中文

本 Draft 暂停实现,用作 #3709#3228 reconciliation gate 稳定前的实现和 qualification 证据。它不是目标 owner 架构,当前形态不应转为 Ready。需要保留的是 generation/epoch 诊断、Restart/Wait/Cancel UX、exact-epoch fencing、已发布 Host takeover adapter 与真实 PTY 证据。Gate 闭合后应拆分或重写实现,使 replacement policy 不再位于普通 connectOrSpawn election 中。

Convergence disposition

The branch has now been audited against the owner/transfer rules in #3709. When work resumes, it should be split or rewritten according to this inventory; the current Draft must not be merged as one lifecycle implementation.

Retain as evidence

  • real PTY Restart / Wait / Cancel scenarios across released compatibility epochs;
  • exact observed-HostEpoch fencing and stale-takeover rejection;
  • same-epoch compatibility evidence showing that build/deployment skew does not require replacement;
  • remote-profile and service-mode isolation;
  • bounded Host activity/residency diagnostics and explicit interruption warning;
  • invocation and cache-disappearance scenarios, rewritten against the selected npx contract.

Migrate behind the owner/reconciler seam

  • TUI conflict wording and decision parsing become a thin presentation adapter over typed connect | owner_transfer_required | wait | cancel | operator_required outcomes;
  • the handshake takeover path becomes a bounded released-Host capability adapter with an explicit removal condition;
  • package/provenance resolution becomes an input adapter that returns verified DeploymentIdentity; it does not decide authority;
  • candidate launch keeps exact deployment identity, but it is invoked by the owner transaction rather than ordinary connection election;
  • _npx detection remains a negative provenance guard shared with managed setup, never positive owner proof.

Delete or rewrite

  • replacement-policy fields and the extra exact-generation probe carried through ordinary connectOrSpawn;
  • installationScope === 'persistent' as replacement authority;
  • package version or a per-process development UUID as verified deployment identity;
  • the TUI-owned retry/replacement loop as a lifecycle state machine;
  • any last-launch-wins behavior or implication that a successful connection, package path, PID, version, or compatible epoch transfers ownership;
  • the branch-local architecture drafts in their current form once their durable decisions and qualification evidence are captured by architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709; they should not become a second target-architecture authority.

Simplification result

  • P0: none.
  • P1 — remove lifecycle authority from ordinary connection election.localGenerationRequest, candidateGeneration, and the TUI-owned retry loop currently form a parallel replacement path. Migrating the released-Host takeover mechanism behind one owner transaction lets these connection-level policy representations and the Surface state machine disappear while preserving compatibility admission and exact-epoch fencing.
  • P2 — remove proxy identities and proxy authority.installationScope === 'persistent' and version/development-UUID generation are maintained only to approximate facts now owned by the durable owner record and verified DeploymentIdentity. The shared _npx detector remains because managed setup and invocation policy still consume its negative provenance fact.
  • P2 — remove duplicate target-architecture documents from the eventual implementation PR.architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 is now the target architecture and decision authority. The PR should retain links, tests, and implementation-specific documentation, not another full lifecycle design whose Current/Planned status can drift.
  • Decision gate — legacy adapter removal. The handshake takeover path remains until the minimum supported released Host set exposes the stable owner-side lifecycle capability; the decisive evidence is the released-version support/qualification matrix.
  • Decision gate — rollback qualification. Previous-artifact retry cannot be simplified into unconditional rollback until fix(storage): retire completed legacy migration metadata #3227 proves the relevant storage transitions safe.

Audit coverage

SliceStatusDisposition
installation/provenance contextReviewedretain resolution seam and shared _npx guard; replace authority and identity inference
ordinary local connection/electionReviewedremove replacement policy; preserve compatibility admission
TUI conflict adapterReviewedretain presentation and decision vocabulary; migrate lifecycle ownership
Host handshake takeoverReviewedretain only as bounded legacy adapter
remote/service isolationReviewedretain unchanged operator boundary
unit/integration/PTY qualificationReviewedmigrate invariant and released-artifact evidence, not branch structure
branch architecture documentsReviewedconsolidate target authority in #3709; rewrite or remove duplicated Current claims
storage downgrade/recoveryPartialretain fail-closed boundary; exact qualification remains owned by #3227
简体中文

收敛处置清单

该分支已经按 #3709 的 owner/transfer 规则完成审计。恢复工作后,应依据以下清单拆分或重写;当前 Draft 不能作为一整套 lifecycle implementation 合并。

作为证据保留

  • 跨已发布 compatibility epoch 的真实 PTY Restart / Wait / Cancel 场景;
  • 绑定 observed HostEpoch 的精确 fencing 与 stale takeover rejection;
  • 证明 same-epoch build/deployment skew 不要求 replacement 的兼容性证据;
  • remote profile 与 service-mode 隔离;
  • 有界 Host activity/residency 诊断和明确 interruption warning;
  • invocation 与 cache disappearance 场景,但要按已选 npx contract 重写。

迁移到 owner/reconciler seam 后面

  • TUI conflict 文案与 decision parsing 变成 typed connect | owner_transfer_required | wait | cancel | operator_required outcome 的薄 presentation adapter;
  • handshake takeover 变成有明确删除条件的 bounded released-Host capability adapter;
  • package/provenance resolution 变成返回 verified DeploymentIdentity 的 input adapter,不再决定 authority;
  • candidate launch 保留 exact deployment identity,但由 owner transaction 调用,不再由普通 connection election 调用;
  • _npx detection 保留为与 managed setup 共享的负向 provenance guard,永远不是正向 owner proof。

删除或重写

  • 普通 connectOrSpawn 中携带的 replacement-policy 字段与额外 exact-generation probe;
  • installationScope === 'persistent' 当作 replacement authority;
  • 把 package version 或 process-scoped development UUID 当作 verified deployment identity;
  • 把 TUI-owned retry/replacement loop 当作 lifecycle state machine;
  • 任何 last-launch-wins 行为,以及“成功连接、package path、PID、version 或 compatible epoch 会转移 ownership”的暗示;
  • 当前形态的 branch-local architecture draft:其中长期有效的决定和 qualification 证据进入 architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 后,不应再形成第二个 target-architecture authority。

简化审计结果

  • P0: 无。
  • P1——从普通 connection election 删除 lifecycle authority。localGenerationRequestcandidateGeneration 与 TUI-owned retry loop 当前形成一条平行 replacement path。把 released-Host takeover mechanism 迁移到唯一 owner transaction 后,可以删除这些 connection-level policy representation 与 Surface state machine,同时保留 compatibility admission 和 exact-epoch fencing。
  • P2——删除代理 identity 与代理 authority。installationScope === 'persistent' 和 version/development-UUID generation 只是近似 durable owner record 与 verified DeploymentIdentity 应拥有的事实。共享 _npx detector 仍保留,因为 managed setup 与 invocation policy 真实消费它提供的负向 provenance fact。
  • P2——从最终 implementation PR 删除重复 target-architecture document。architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 已是目标架构与决策 authority。PR 应保留链接、测试和 implementation-specific 文档,而不是再维护一份 Current/Planned 状态可能漂移的完整 lifecycle design。
  • Decision gate——legacy adapter 删除时机。 在最低支持的 released Host 集合提供稳定 owner-side lifecycle capability 前,handshake takeover path 仍要保留;决定性证据是 released-version support/qualification matrix。
  • Decision gate——rollback qualification。fix(storage): retire completed legacy migration metadata #3227 证明相关 storage transition 安全前,previous-artifact retry 不能简化成无条件 rollback。

审计覆盖

Slice状态处置
installation/provenance contextReviewed保留 resolution seam 与共享 _npx guard;替换 authority/identity inference
普通 local connection/electionReviewed删除 replacement policy;保留 compatibility admission
TUI conflict adapterReviewed保留 presentation/decision vocabulary;迁移 lifecycle ownership
Host handshake takeoverReviewed仅作为 bounded legacy adapter 保留
remote/service isolationReviewed保持 operator boundary 不变
unit/integration/PTY qualificationReviewed迁移 invariant 与 released-artifact evidence,不迁移 branch structure
branch architecture documentsReviewedtarget authority 收敛到 #3709;重写或删除重复的 Current claim
storage downgrade/recoveryPartial保留 fail-closed boundary;精确 qualification 仍由 #3227 负责

Summary

Teach the local CLI/TUI to identify the installation that supplied its Runtime Host candidate and negotiate that candidate generation explicitly.

Compatible same-epoch Clients continue using the active Host even when builds differ. For a local cross-epoch conflict, TUI presents Restart, Wait, or Cancel using authoritative Host activity; Restart is fenced to the observed Host epoch. Remote profiles never receive local replacement authority, and transient npx launches cannot request takeover.

This is the first bounded slice of the installation lifecycle design. Artifact staging/switching, a public update command, same-epoch replacement, managed remote updates, and durable npx ownership remain out of scope.

Refs #3231
Refs #3243
Refs #3244
Refs #3245
Refs #3709

Verification

  • Biome check passed for the changed code and tests.
  • @maka/core, @maka/storage, @maka/mcp, @maka/runtime, @maka/runtime-host, and maka-agent builds passed.
  • Runtime Host and CLI typechecks passed.
  • Focused CLI/context, service guard, and Host candidate-generation tests passed (19/19).
  • Real PTY epoch 24 → 26 checks covered Restart, Wait, and Cancel while a Scheduled Task retained the old Host.
  • git diff --check passed.

Not run: full repository test suite or Desktop UI tests.

Draft scope

  • Resolve installation scope and artifact generation once per CLI launch
  • Admit compatible same-epoch Clients without replacing the Host
  • Fence explicit local takeover to the observed Host epoch
  • Keep remote and transient npx callers outside local replacement authority
  • Document Current, Planned, and Exploratory lifecycle boundaries
  • Review product wording and protocol ownership with maintainers
  • Add release-package and platform qualification before marking ready

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex assisted with architecture analysis, implementation, documentation, tests, and local review. The human contributor will review the Draft before it is submitted for merge.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@me2seeks
me2seeksforce-pushed the feat/cli-runtime-host-generation-handoff branch from f3c93a9 to d59f548CompareAugust 23, 2026 10:19
Main retired the client surface identity; the replayed generation-rejection
and election tests still passed it, breaking typecheck.
Generated-by: maka

@Astro-HanAstro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for keeping this Draft's status and convergence notes honest. I reviewed exact head 8a197b08ae50445b88ea5d671b977c821d072131 (14 files, +1294/-50).

The underlying problem is demonstrated: an older local Runtime Host can remain resident across a compatibility-epoch change, leaving a newer CLI unable to make progress. Exact observed-epoch fencing, authoritative activity diagnostics, remote/service/npx isolation, and the Restart / Wait / Cancel vocabulary are useful evidence worth preserving.

The current implementation, however, is no longer the right solution owner. It carries replacement policy through the ordinary TUI → CLI context → connectOrSpawn election path, using installation path/version/development UUID as proxy deployment identity. Current main now has durable deployment ownership, handoff, and owner-transaction seams; keeping this path would create a second lifecycle authority. By first principles, ordinary connection election should report typed compatibility facts, while the verified owner transaction performs retirement, replacement, and candidate launch.

So the correct disposition is not to repair this 1,294-line branch into a mergeable PR. Keep/migrate the exact-epoch and real-Host evidence, then delete or rewrite the branch-local replacement policy, TUI-owned retry state machine, proxy identity, fake-connector wiring tests, and roughly 754 lines of duplicate architecture drafts. #3709 should remain the single target-architecture authority.

I left the most concrete code findings inline:

  • P1:candidateGeneration / takeoverHostEpoch put replacement authority in ordinary connectOrSpawn;
  • P2: Restart is offered when connections === 0, although the Host also requires zero active operations/residencies, producing a recoverable conflict loop;
  • P1: the current head does not parse because join is imported twice.

There are additional current-head delivery failures: six new source/docs files lack ASF headers; tests still pass the retired surface field; and changed-file formatting fails. The exact head has no hosted checks and conflicts with current main. These reinforce the Draft status, but they are not a reason to preserve the obsolete architecture.

Next step: keep this Draft paused. Rebuild the smallest coherent slice behind the current owner/handoff seam, migrate only the valuable Host-kernel and released-artifact/PTTY evidence, remove duplicate architecture documents, then refresh exact-head CI and qualification. Do not simply rebase this branch and mark it Ready.

中文对照

感谢你在 Draft 正文里坦诚记录了当前状态和收敛方向。底层问题是真实的:旧版 Local Runtime Host 可能因为驻留任务跨 compatibility epoch 继续运行,导致新版 CLI 无法继续。精确 epoch fencing、Host activity 诊断、remote/service/npx 隔离,以及 Restart / Wait / Cancel 的交互词汇都值得保留。

但当前实现已经不再属于正确的 owner。它把 replacement policy 放进 TUI → CLI context → 普通 connectOrSpawn election,并使用安装路径、版本和 development UUID 近似 deployment identity。现在 main 已经有 durable owner、handoff 和 owner transaction;继续保留这条路径会形成第二套生命周期 authority。普通连接选举应只返回 typed compatibility facts,真正的 retirement、replacement 和 candidate launch 应由 verified owner transaction 完成。

因此,不建议把这 1294 行分支继续修成可合并 PR。应迁移 exact-epoch 和真实 Host 证据,然后删除或重写 branch-local replacement policy、TUI 自己维护的 retry state machine、代理 identity、只验证字段映射的 fake connector 测试,以及约 754 行重复架构草稿;#3709 保持唯一目标架构 authority。

当前 head 另外还存在重复 import、ASF header、退役测试字段和格式问题,并且与 main 冲突、没有 CI。这些都说明保持 Draft 是正确的,但不值得为了修这些表面问题继续保留旧架构。正确下一步是基于当前 owner/handoff seam 重建一个最小完整切片,只迁移有价值的 qualification 证据。


AI-assisted review notice: Codex coordinated independent review lanes; I verified the exact-head diff, current-main owner seams, reachability, and severity before publication. This does not replace the repository's required independent human approval.

protocol: ProtocolRange;
compositionId: string;
generation?: string;
candidateGeneration?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This makes ordinary connection election carry replacement policy. A non-npx path, package version, or development UUID is not verified deployment ownership, yet the TUI can turn those proxy facts into a generation takeover request. Current main has a durable owner/handoff transaction that is the natural authority for retirement and successor launch. Please keep connectOrSpawn as a compatibility-fact/admission seam and move this replacement action behind the verified owner transaction; otherwise the repository retains two lifecycle authorities.

const activity = error.conflict.handshake?.activity;
return error.conflict.kind === 'upgrade_required'
? error.conflict.restartable
: activity !== undefined && activity.connections === 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2 · category ①] connections === 0 is weaker than the Host's actual takeover condition, which also requires zero active operations and residencies. A normal scheduled-task residency can therefore make the TUI offer Restart, only for the Kernel to reject it and return the user to the same prompt. This is recoverable through Wait/Cancel, so P2 is the calibrated level. The thin adapter should consume an authoritative replacement disposition rather than re-derive idleness here.

import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { deriveMakaDataRoots, resolveMakaDataRoots } from './workspace-root.js';
import { join } from 'node:path';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This exact head imports join twice, so the CLI module fails to parse (Identifier 'join' has already been declared). The branch also retains unused imports around this edit. Please delete the duplicate/dead imports; if this code is rewritten behind the owner seam, avoid carrying this stale composition forward.

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

Labels

effort/XLOver 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@me2seeks@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(cli): reconcile local Runtime Host generations by me2seeks · Pull Request #3254 · apache/maka · GitHub
Skip to content

feat(cli): reconcile local Runtime Host generations - #3254

Draft
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff
Draft

feat(cli): reconcile local Runtime Host generations#3254
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff

Conversation

@me2seeks

@me2seeksme2seeks commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Current status

This Draft is paused as implementation and qualification evidence while #3709 and the #3228 reconciliation gates stabilize. It is not the target owner architecture and should not be marked Ready in its current form. The retained value is its generation/epoch diagnostics, Restart/Wait/Cancel UX, exact-epoch fencing, released-Host takeover adapter, and real PTY evidence. After the gates close, the implementation should be split or rewritten so replacement policy no longer lives in ordinary connectOrSpawn election.

简体中文

本 Draft 暂停实现,用作 #3709#3228 reconciliation gate 稳定前的实现和 qualification 证据。它不是目标 owner 架构,当前形态不应转为 Ready。需要保留的是 generation/epoch 诊断、Restart/Wait/Cancel UX、exact-epoch fencing、已发布 Host takeover adapter 与真实 PTY 证据。Gate 闭合后应拆分或重写实现,使 replacement policy 不再位于普通 connectOrSpawn election 中。

Convergence disposition

The branch has now been audited against the owner/transfer rules in #3709. When work resumes, it should be split or rewritten according to this inventory; the current Draft must not be merged as one lifecycle implementation.

Retain as evidence

  • real PTY Restart / Wait / Cancel scenarios across released compatibility epochs;
  • exact observed-HostEpoch fencing and stale-takeover rejection;
  • same-epoch compatibility evidence showing that build/deployment skew does not require replacement;
  • remote-profile and service-mode isolation;
  • bounded Host activity/residency diagnostics and explicit interruption warning;
  • invocation and cache-disappearance scenarios, rewritten against the selected npx contract.

Migrate behind the owner/reconciler seam

  • TUI conflict wording and decision parsing become a thin presentation adapter over typed connect | owner_transfer_required | wait | cancel | operator_required outcomes;
  • the handshake takeover path becomes a bounded released-Host capability adapter with an explicit removal condition;
  • package/provenance resolution becomes an input adapter that returns verified DeploymentIdentity; it does not decide authority;
  • candidate launch keeps exact deployment identity, but it is invoked by the owner transaction rather than ordinary connection election;
  • _npx detection remains a negative provenance guard shared with managed setup, never positive owner proof.

Delete or rewrite

  • replacement-policy fields and the extra exact-generation probe carried through ordinary connectOrSpawn;
  • installationScope === 'persistent' as replacement authority;
  • package version or a per-process development UUID as verified deployment identity;
  • the TUI-owned retry/replacement loop as a lifecycle state machine;
  • any last-launch-wins behavior or implication that a successful connection, package path, PID, version, or compatible epoch transfers ownership;
  • the branch-local architecture drafts in their current form once their durable decisions and qualification evidence are captured by architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709; they should not become a second target-architecture authority.

Simplification result

  • P0: none.
  • P1 — remove lifecycle authority from ordinary connection election.localGenerationRequest, candidateGeneration, and the TUI-owned retry loop currently form a parallel replacement path. Migrating the released-Host takeover mechanism behind one owner transaction lets these connection-level policy representations and the Surface state machine disappear while preserving compatibility admission and exact-epoch fencing.
  • P2 — remove proxy identities and proxy authority.installationScope === 'persistent' and version/development-UUID generation are maintained only to approximate facts now owned by the durable owner record and verified DeploymentIdentity. The shared _npx detector remains because managed setup and invocation policy still consume its negative provenance fact.
  • P2 — remove duplicate target-architecture documents from the eventual implementation PR.architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 is now the target architecture and decision authority. The PR should retain links, tests, and implementation-specific documentation, not another full lifecycle design whose Current/Planned status can drift.
  • Decision gate — legacy adapter removal. The handshake takeover path remains until the minimum supported released Host set exposes the stable owner-side lifecycle capability; the decisive evidence is the released-version support/qualification matrix.
  • Decision gate — rollback qualification. Previous-artifact retry cannot be simplified into unconditional rollback until fix(storage): retire completed legacy migration metadata #3227 proves the relevant storage transitions safe.

Audit coverage

SliceStatusDisposition
installation/provenance contextReviewedretain resolution seam and shared _npx guard; replace authority and identity inference
ordinary local connection/electionReviewedremove replacement policy; preserve compatibility admission
TUI conflict adapterReviewedretain presentation and decision vocabulary; migrate lifecycle ownership
Host handshake takeoverReviewedretain only as bounded legacy adapter
remote/service isolationReviewedretain unchanged operator boundary
unit/integration/PTY qualificationReviewedmigrate invariant and released-artifact evidence, not branch structure
branch architecture documentsReviewedconsolidate target authority in #3709; rewrite or remove duplicated Current claims
storage downgrade/recoveryPartialretain fail-closed boundary; exact qualification remains owned by #3227
简体中文

收敛处置清单

该分支已经按 #3709 的 owner/transfer 规则完成审计。恢复工作后,应依据以下清单拆分或重写;当前 Draft 不能作为一整套 lifecycle implementation 合并。

作为证据保留

  • 跨已发布 compatibility epoch 的真实 PTY Restart / Wait / Cancel 场景;
  • 绑定 observed HostEpoch 的精确 fencing 与 stale takeover rejection;
  • 证明 same-epoch build/deployment skew 不要求 replacement 的兼容性证据;
  • remote profile 与 service-mode 隔离;
  • 有界 Host activity/residency 诊断和明确 interruption warning;
  • invocation 与 cache disappearance 场景,但要按已选 npx contract 重写。

迁移到 owner/reconciler seam 后面

  • TUI conflict 文案与 decision parsing 变成 typed connect | owner_transfer_required | wait | cancel | operator_required outcome 的薄 presentation adapter;
  • handshake takeover 变成有明确删除条件的 bounded released-Host capability adapter;
  • package/provenance resolution 变成返回 verified DeploymentIdentity 的 input adapter,不再决定 authority;
  • candidate launch 保留 exact deployment identity,但由 owner transaction 调用,不再由普通 connection election 调用;
  • _npx detection 保留为与 managed setup 共享的负向 provenance guard,永远不是正向 owner proof。

删除或重写

  • 普通 connectOrSpawn 中携带的 replacement-policy 字段与额外 exact-generation probe;
  • installationScope === 'persistent' 当作 replacement authority;
  • 把 package version 或 process-scoped development UUID 当作 verified deployment identity;
  • 把 TUI-owned retry/replacement loop 当作 lifecycle state machine;
  • 任何 last-launch-wins 行为,以及“成功连接、package path、PID、version 或 compatible epoch 会转移 ownership”的暗示;
  • 当前形态的 branch-local architecture draft:其中长期有效的决定和 qualification 证据进入 architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 后,不应再形成第二个 target-architecture authority。

简化审计结果

  • P0: 无。
  • P1——从普通 connection election 删除 lifecycle authority。localGenerationRequestcandidateGeneration 与 TUI-owned retry loop 当前形成一条平行 replacement path。把 released-Host takeover mechanism 迁移到唯一 owner transaction 后,可以删除这些 connection-level policy representation 与 Surface state machine,同时保留 compatibility admission 和 exact-epoch fencing。
  • P2——删除代理 identity 与代理 authority。installationScope === 'persistent' 和 version/development-UUID generation 只是近似 durable owner record 与 verified DeploymentIdentity 应拥有的事实。共享 _npx detector 仍保留,因为 managed setup 与 invocation policy 真实消费它提供的负向 provenance fact。
  • P2——从最终 implementation PR 删除重复 target-architecture document。architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 已是目标架构与决策 authority。PR 应保留链接、测试和 implementation-specific 文档,而不是再维护一份 Current/Planned 状态可能漂移的完整 lifecycle design。
  • Decision gate——legacy adapter 删除时机。 在最低支持的 released Host 集合提供稳定 owner-side lifecycle capability 前,handshake takeover path 仍要保留;决定性证据是 released-version support/qualification matrix。
  • Decision gate——rollback qualification。fix(storage): retire completed legacy migration metadata #3227 证明相关 storage transition 安全前,previous-artifact retry 不能简化成无条件 rollback。

审计覆盖

Slice状态处置
installation/provenance contextReviewed保留 resolution seam 与共享 _npx guard;替换 authority/identity inference
普通 local connection/electionReviewed删除 replacement policy;保留 compatibility admission
TUI conflict adapterReviewed保留 presentation/decision vocabulary;迁移 lifecycle ownership
Host handshake takeoverReviewed仅作为 bounded legacy adapter 保留
remote/service isolationReviewed保持 operator boundary 不变
unit/integration/PTY qualificationReviewed迁移 invariant 与 released-artifact evidence,不迁移 branch structure
branch architecture documentsReviewedtarget authority 收敛到 #3709;重写或删除重复的 Current claim
storage downgrade/recoveryPartial保留 fail-closed boundary;精确 qualification 仍由 #3227 负责

Summary

Teach the local CLI/TUI to identify the installation that supplied its Runtime Host candidate and negotiate that candidate generation explicitly.

Compatible same-epoch Clients continue using the active Host even when builds differ. For a local cross-epoch conflict, TUI presents Restart, Wait, or Cancel using authoritative Host activity; Restart is fenced to the observed Host epoch. Remote profiles never receive local replacement authority, and transient npx launches cannot request takeover.

This is the first bounded slice of the installation lifecycle design. Artifact staging/switching, a public update command, same-epoch replacement, managed remote updates, and durable npx ownership remain out of scope.

Refs #3231
Refs #3243
Refs #3244
Refs #3245
Refs #3709

Verification

  • Biome check passed for the changed code and tests.
  • @maka/core, @maka/storage, @maka/mcp, @maka/runtime, @maka/runtime-host, and maka-agent builds passed.
  • Runtime Host and CLI typechecks passed.
  • Focused CLI/context, service guard, and Host candidate-generation tests passed (19/19).
  • Real PTY epoch 24 → 26 checks covered Restart, Wait, and Cancel while a Scheduled Task retained the old Host.
  • git diff --check passed.

Not run: full repository test suite or Desktop UI tests.

Draft scope

  • Resolve installation scope and artifact generation once per CLI launch
  • Admit compatible same-epoch Clients without replacing the Host
  • Fence explicit local takeover to the observed Host epoch
  • Keep remote and transient npx callers outside local replacement authority
  • Document Current, Planned, and Exploratory lifecycle boundaries
  • Review product wording and protocol ownership with maintainers
  • Add release-package and platform qualification before marking ready

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex assisted with architecture analysis, implementation, documentation, tests, and local review. The human contributor will review the Draft before it is submitted for merge.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@me2seeks
me2seeksforce-pushed the feat/cli-runtime-host-generation-handoff branch from f3c93a9 to d59f548CompareAugust 23, 2026 10:19
Main retired the client surface identity; the replayed generation-rejection
and election tests still passed it, breaking typecheck.
Generated-by: maka

@Astro-HanAstro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for keeping this Draft's status and convergence notes honest. I reviewed exact head 8a197b08ae50445b88ea5d671b977c821d072131 (14 files, +1294/-50).

The underlying problem is demonstrated: an older local Runtime Host can remain resident across a compatibility-epoch change, leaving a newer CLI unable to make progress. Exact observed-epoch fencing, authoritative activity diagnostics, remote/service/npx isolation, and the Restart / Wait / Cancel vocabulary are useful evidence worth preserving.

The current implementation, however, is no longer the right solution owner. It carries replacement policy through the ordinary TUI → CLI context → connectOrSpawn election path, using installation path/version/development UUID as proxy deployment identity. Current main now has durable deployment ownership, handoff, and owner-transaction seams; keeping this path would create a second lifecycle authority. By first principles, ordinary connection election should report typed compatibility facts, while the verified owner transaction performs retirement, replacement, and candidate launch.

So the correct disposition is not to repair this 1,294-line branch into a mergeable PR. Keep/migrate the exact-epoch and real-Host evidence, then delete or rewrite the branch-local replacement policy, TUI-owned retry state machine, proxy identity, fake-connector wiring tests, and roughly 754 lines of duplicate architecture drafts. #3709 should remain the single target-architecture authority.

I left the most concrete code findings inline:

  • P1:candidateGeneration / takeoverHostEpoch put replacement authority in ordinary connectOrSpawn;
  • P2: Restart is offered when connections === 0, although the Host also requires zero active operations/residencies, producing a recoverable conflict loop;
  • P1: the current head does not parse because join is imported twice.

There are additional current-head delivery failures: six new source/docs files lack ASF headers; tests still pass the retired surface field; and changed-file formatting fails. The exact head has no hosted checks and conflicts with current main. These reinforce the Draft status, but they are not a reason to preserve the obsolete architecture.

Next step: keep this Draft paused. Rebuild the smallest coherent slice behind the current owner/handoff seam, migrate only the valuable Host-kernel and released-artifact/PTTY evidence, remove duplicate architecture documents, then refresh exact-head CI and qualification. Do not simply rebase this branch and mark it Ready.

中文对照

感谢你在 Draft 正文里坦诚记录了当前状态和收敛方向。底层问题是真实的:旧版 Local Runtime Host 可能因为驻留任务跨 compatibility epoch 继续运行,导致新版 CLI 无法继续。精确 epoch fencing、Host activity 诊断、remote/service/npx 隔离,以及 Restart / Wait / Cancel 的交互词汇都值得保留。

但当前实现已经不再属于正确的 owner。它把 replacement policy 放进 TUI → CLI context → 普通 connectOrSpawn election,并使用安装路径、版本和 development UUID 近似 deployment identity。现在 main 已经有 durable owner、handoff 和 owner transaction;继续保留这条路径会形成第二套生命周期 authority。普通连接选举应只返回 typed compatibility facts,真正的 retirement、replacement 和 candidate launch 应由 verified owner transaction 完成。

因此,不建议把这 1294 行分支继续修成可合并 PR。应迁移 exact-epoch 和真实 Host 证据,然后删除或重写 branch-local replacement policy、TUI 自己维护的 retry state machine、代理 identity、只验证字段映射的 fake connector 测试,以及约 754 行重复架构草稿;#3709 保持唯一目标架构 authority。

当前 head 另外还存在重复 import、ASF header、退役测试字段和格式问题,并且与 main 冲突、没有 CI。这些都说明保持 Draft 是正确的,但不值得为了修这些表面问题继续保留旧架构。正确下一步是基于当前 owner/handoff seam 重建一个最小完整切片,只迁移有价值的 qualification 证据。


AI-assisted review notice: Codex coordinated independent review lanes; I verified the exact-head diff, current-main owner seams, reachability, and severity before publication. This does not replace the repository's required independent human approval.

protocol: ProtocolRange;
compositionId: string;
generation?: string;
candidateGeneration?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This makes ordinary connection election carry replacement policy. A non-npx path, package version, or development UUID is not verified deployment ownership, yet the TUI can turn those proxy facts into a generation takeover request. Current main has a durable owner/handoff transaction that is the natural authority for retirement and successor launch. Please keep connectOrSpawn as a compatibility-fact/admission seam and move this replacement action behind the verified owner transaction; otherwise the repository retains two lifecycle authorities.

const activity = error.conflict.handshake?.activity;
return error.conflict.kind === 'upgrade_required'
? error.conflict.restartable
: activity !== undefined && activity.connections === 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2 · category ①] connections === 0 is weaker than the Host's actual takeover condition, which also requires zero active operations and residencies. A normal scheduled-task residency can therefore make the TUI offer Restart, only for the Kernel to reject it and return the user to the same prompt. This is recoverable through Wait/Cancel, so P2 is the calibrated level. The thin adapter should consume an authoritative replacement disposition rather than re-derive idleness here.

import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { deriveMakaDataRoots, resolveMakaDataRoots } from './workspace-root.js';
import { join } from 'node:path';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This exact head imports join twice, so the CLI module fails to parse (Identifier 'join' has already been declared). The branch also retains unused imports around this edit. Please delete the duplicate/dead imports; if this code is rewritten behind the owner seam, avoid carrying this stale composition forward.

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

Labels

effort/XLOver 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@me2seeks@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(cli): reconcile local Runtime Host generations by me2seeks · Pull Request #3254 · apache/maka · GitHub
Skip to content

feat(cli): reconcile local Runtime Host generations - #3254

Draft
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff
Draft

feat(cli): reconcile local Runtime Host generations#3254
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff

Conversation

@me2seeks

@me2seeksme2seeks commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Current status

This Draft is paused as implementation and qualification evidence while #3709 and the #3228 reconciliation gates stabilize. It is not the target owner architecture and should not be marked Ready in its current form. The retained value is its generation/epoch diagnostics, Restart/Wait/Cancel UX, exact-epoch fencing, released-Host takeover adapter, and real PTY evidence. After the gates close, the implementation should be split or rewritten so replacement policy no longer lives in ordinary connectOrSpawn election.

简体中文

本 Draft 暂停实现,用作 #3709#3228 reconciliation gate 稳定前的实现和 qualification 证据。它不是目标 owner 架构,当前形态不应转为 Ready。需要保留的是 generation/epoch 诊断、Restart/Wait/Cancel UX、exact-epoch fencing、已发布 Host takeover adapter 与真实 PTY 证据。Gate 闭合后应拆分或重写实现,使 replacement policy 不再位于普通 connectOrSpawn election 中。

Convergence disposition

The branch has now been audited against the owner/transfer rules in #3709. When work resumes, it should be split or rewritten according to this inventory; the current Draft must not be merged as one lifecycle implementation.

Retain as evidence

  • real PTY Restart / Wait / Cancel scenarios across released compatibility epochs;
  • exact observed-HostEpoch fencing and stale-takeover rejection;
  • same-epoch compatibility evidence showing that build/deployment skew does not require replacement;
  • remote-profile and service-mode isolation;
  • bounded Host activity/residency diagnostics and explicit interruption warning;
  • invocation and cache-disappearance scenarios, rewritten against the selected npx contract.

Migrate behind the owner/reconciler seam

  • TUI conflict wording and decision parsing become a thin presentation adapter over typed connect | owner_transfer_required | wait | cancel | operator_required outcomes;
  • the handshake takeover path becomes a bounded released-Host capability adapter with an explicit removal condition;
  • package/provenance resolution becomes an input adapter that returns verified DeploymentIdentity; it does not decide authority;
  • candidate launch keeps exact deployment identity, but it is invoked by the owner transaction rather than ordinary connection election;
  • _npx detection remains a negative provenance guard shared with managed setup, never positive owner proof.

Delete or rewrite

  • replacement-policy fields and the extra exact-generation probe carried through ordinary connectOrSpawn;
  • installationScope === 'persistent' as replacement authority;
  • package version or a per-process development UUID as verified deployment identity;
  • the TUI-owned retry/replacement loop as a lifecycle state machine;
  • any last-launch-wins behavior or implication that a successful connection, package path, PID, version, or compatible epoch transfers ownership;
  • the branch-local architecture drafts in their current form once their durable decisions and qualification evidence are captured by architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709; they should not become a second target-architecture authority.

Simplification result

  • P0: none.
  • P1 — remove lifecycle authority from ordinary connection election.localGenerationRequest, candidateGeneration, and the TUI-owned retry loop currently form a parallel replacement path. Migrating the released-Host takeover mechanism behind one owner transaction lets these connection-level policy representations and the Surface state machine disappear while preserving compatibility admission and exact-epoch fencing.
  • P2 — remove proxy identities and proxy authority.installationScope === 'persistent' and version/development-UUID generation are maintained only to approximate facts now owned by the durable owner record and verified DeploymentIdentity. The shared _npx detector remains because managed setup and invocation policy still consume its negative provenance fact.
  • P2 — remove duplicate target-architecture documents from the eventual implementation PR.architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 is now the target architecture and decision authority. The PR should retain links, tests, and implementation-specific documentation, not another full lifecycle design whose Current/Planned status can drift.
  • Decision gate — legacy adapter removal. The handshake takeover path remains until the minimum supported released Host set exposes the stable owner-side lifecycle capability; the decisive evidence is the released-version support/qualification matrix.
  • Decision gate — rollback qualification. Previous-artifact retry cannot be simplified into unconditional rollback until fix(storage): retire completed legacy migration metadata #3227 proves the relevant storage transitions safe.

Audit coverage

SliceStatusDisposition
installation/provenance contextReviewedretain resolution seam and shared _npx guard; replace authority and identity inference
ordinary local connection/electionReviewedremove replacement policy; preserve compatibility admission
TUI conflict adapterReviewedretain presentation and decision vocabulary; migrate lifecycle ownership
Host handshake takeoverReviewedretain only as bounded legacy adapter
remote/service isolationReviewedretain unchanged operator boundary
unit/integration/PTY qualificationReviewedmigrate invariant and released-artifact evidence, not branch structure
branch architecture documentsReviewedconsolidate target authority in #3709; rewrite or remove duplicated Current claims
storage downgrade/recoveryPartialretain fail-closed boundary; exact qualification remains owned by #3227
简体中文

收敛处置清单

该分支已经按 #3709 的 owner/transfer 规则完成审计。恢复工作后,应依据以下清单拆分或重写;当前 Draft 不能作为一整套 lifecycle implementation 合并。

作为证据保留

  • 跨已发布 compatibility epoch 的真实 PTY Restart / Wait / Cancel 场景;
  • 绑定 observed HostEpoch 的精确 fencing 与 stale takeover rejection;
  • 证明 same-epoch build/deployment skew 不要求 replacement 的兼容性证据;
  • remote profile 与 service-mode 隔离;
  • 有界 Host activity/residency 诊断和明确 interruption warning;
  • invocation 与 cache disappearance 场景,但要按已选 npx contract 重写。

迁移到 owner/reconciler seam 后面

  • TUI conflict 文案与 decision parsing 变成 typed connect | owner_transfer_required | wait | cancel | operator_required outcome 的薄 presentation adapter;
  • handshake takeover 变成有明确删除条件的 bounded released-Host capability adapter;
  • package/provenance resolution 变成返回 verified DeploymentIdentity 的 input adapter,不再决定 authority;
  • candidate launch 保留 exact deployment identity,但由 owner transaction 调用,不再由普通 connection election 调用;
  • _npx detection 保留为与 managed setup 共享的负向 provenance guard,永远不是正向 owner proof。

删除或重写

  • 普通 connectOrSpawn 中携带的 replacement-policy 字段与额外 exact-generation probe;
  • installationScope === 'persistent' 当作 replacement authority;
  • 把 package version 或 process-scoped development UUID 当作 verified deployment identity;
  • 把 TUI-owned retry/replacement loop 当作 lifecycle state machine;
  • 任何 last-launch-wins 行为,以及“成功连接、package path、PID、version 或 compatible epoch 会转移 ownership”的暗示;
  • 当前形态的 branch-local architecture draft:其中长期有效的决定和 qualification 证据进入 architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 后,不应再形成第二个 target-architecture authority。

简化审计结果

  • P0: 无。
  • P1——从普通 connection election 删除 lifecycle authority。localGenerationRequestcandidateGeneration 与 TUI-owned retry loop 当前形成一条平行 replacement path。把 released-Host takeover mechanism 迁移到唯一 owner transaction 后,可以删除这些 connection-level policy representation 与 Surface state machine,同时保留 compatibility admission 和 exact-epoch fencing。
  • P2——删除代理 identity 与代理 authority。installationScope === 'persistent' 和 version/development-UUID generation 只是近似 durable owner record 与 verified DeploymentIdentity 应拥有的事实。共享 _npx detector 仍保留,因为 managed setup 与 invocation policy 真实消费它提供的负向 provenance fact。
  • P2——从最终 implementation PR 删除重复 target-architecture document。architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 已是目标架构与决策 authority。PR 应保留链接、测试和 implementation-specific 文档,而不是再维护一份 Current/Planned 状态可能漂移的完整 lifecycle design。
  • Decision gate——legacy adapter 删除时机。 在最低支持的 released Host 集合提供稳定 owner-side lifecycle capability 前,handshake takeover path 仍要保留;决定性证据是 released-version support/qualification matrix。
  • Decision gate——rollback qualification。fix(storage): retire completed legacy migration metadata #3227 证明相关 storage transition 安全前,previous-artifact retry 不能简化成无条件 rollback。

审计覆盖

Slice状态处置
installation/provenance contextReviewed保留 resolution seam 与共享 _npx guard;替换 authority/identity inference
普通 local connection/electionReviewed删除 replacement policy;保留 compatibility admission
TUI conflict adapterReviewed保留 presentation/decision vocabulary;迁移 lifecycle ownership
Host handshake takeoverReviewed仅作为 bounded legacy adapter 保留
remote/service isolationReviewed保持 operator boundary 不变
unit/integration/PTY qualificationReviewed迁移 invariant 与 released-artifact evidence,不迁移 branch structure
branch architecture documentsReviewedtarget authority 收敛到 #3709;重写或删除重复的 Current claim
storage downgrade/recoveryPartial保留 fail-closed boundary;精确 qualification 仍由 #3227 负责

Summary

Teach the local CLI/TUI to identify the installation that supplied its Runtime Host candidate and negotiate that candidate generation explicitly.

Compatible same-epoch Clients continue using the active Host even when builds differ. For a local cross-epoch conflict, TUI presents Restart, Wait, or Cancel using authoritative Host activity; Restart is fenced to the observed Host epoch. Remote profiles never receive local replacement authority, and transient npx launches cannot request takeover.

This is the first bounded slice of the installation lifecycle design. Artifact staging/switching, a public update command, same-epoch replacement, managed remote updates, and durable npx ownership remain out of scope.

Refs #3231
Refs #3243
Refs #3244
Refs #3245
Refs #3709

Verification

  • Biome check passed for the changed code and tests.
  • @maka/core, @maka/storage, @maka/mcp, @maka/runtime, @maka/runtime-host, and maka-agent builds passed.
  • Runtime Host and CLI typechecks passed.
  • Focused CLI/context, service guard, and Host candidate-generation tests passed (19/19).
  • Real PTY epoch 24 → 26 checks covered Restart, Wait, and Cancel while a Scheduled Task retained the old Host.
  • git diff --check passed.

Not run: full repository test suite or Desktop UI tests.

Draft scope

  • Resolve installation scope and artifact generation once per CLI launch
  • Admit compatible same-epoch Clients without replacing the Host
  • Fence explicit local takeover to the observed Host epoch
  • Keep remote and transient npx callers outside local replacement authority
  • Document Current, Planned, and Exploratory lifecycle boundaries
  • Review product wording and protocol ownership with maintainers
  • Add release-package and platform qualification before marking ready

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex assisted with architecture analysis, implementation, documentation, tests, and local review. The human contributor will review the Draft before it is submitted for merge.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@me2seeks
me2seeksforce-pushed the feat/cli-runtime-host-generation-handoff branch from f3c93a9 to d59f548CompareAugust 23, 2026 10:19
Main retired the client surface identity; the replayed generation-rejection
and election tests still passed it, breaking typecheck.
Generated-by: maka

@Astro-HanAstro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for keeping this Draft's status and convergence notes honest. I reviewed exact head 8a197b08ae50445b88ea5d671b977c821d072131 (14 files, +1294/-50).

The underlying problem is demonstrated: an older local Runtime Host can remain resident across a compatibility-epoch change, leaving a newer CLI unable to make progress. Exact observed-epoch fencing, authoritative activity diagnostics, remote/service/npx isolation, and the Restart / Wait / Cancel vocabulary are useful evidence worth preserving.

The current implementation, however, is no longer the right solution owner. It carries replacement policy through the ordinary TUI → CLI context → connectOrSpawn election path, using installation path/version/development UUID as proxy deployment identity. Current main now has durable deployment ownership, handoff, and owner-transaction seams; keeping this path would create a second lifecycle authority. By first principles, ordinary connection election should report typed compatibility facts, while the verified owner transaction performs retirement, replacement, and candidate launch.

So the correct disposition is not to repair this 1,294-line branch into a mergeable PR. Keep/migrate the exact-epoch and real-Host evidence, then delete or rewrite the branch-local replacement policy, TUI-owned retry state machine, proxy identity, fake-connector wiring tests, and roughly 754 lines of duplicate architecture drafts. #3709 should remain the single target-architecture authority.

I left the most concrete code findings inline:

  • P1:candidateGeneration / takeoverHostEpoch put replacement authority in ordinary connectOrSpawn;
  • P2: Restart is offered when connections === 0, although the Host also requires zero active operations/residencies, producing a recoverable conflict loop;
  • P1: the current head does not parse because join is imported twice.

There are additional current-head delivery failures: six new source/docs files lack ASF headers; tests still pass the retired surface field; and changed-file formatting fails. The exact head has no hosted checks and conflicts with current main. These reinforce the Draft status, but they are not a reason to preserve the obsolete architecture.

Next step: keep this Draft paused. Rebuild the smallest coherent slice behind the current owner/handoff seam, migrate only the valuable Host-kernel and released-artifact/PTTY evidence, remove duplicate architecture documents, then refresh exact-head CI and qualification. Do not simply rebase this branch and mark it Ready.

中文对照

感谢你在 Draft 正文里坦诚记录了当前状态和收敛方向。底层问题是真实的:旧版 Local Runtime Host 可能因为驻留任务跨 compatibility epoch 继续运行,导致新版 CLI 无法继续。精确 epoch fencing、Host activity 诊断、remote/service/npx 隔离,以及 Restart / Wait / Cancel 的交互词汇都值得保留。

但当前实现已经不再属于正确的 owner。它把 replacement policy 放进 TUI → CLI context → 普通 connectOrSpawn election,并使用安装路径、版本和 development UUID 近似 deployment identity。现在 main 已经有 durable owner、handoff 和 owner transaction;继续保留这条路径会形成第二套生命周期 authority。普通连接选举应只返回 typed compatibility facts,真正的 retirement、replacement 和 candidate launch 应由 verified owner transaction 完成。

因此,不建议把这 1294 行分支继续修成可合并 PR。应迁移 exact-epoch 和真实 Host 证据,然后删除或重写 branch-local replacement policy、TUI 自己维护的 retry state machine、代理 identity、只验证字段映射的 fake connector 测试,以及约 754 行重复架构草稿;#3709 保持唯一目标架构 authority。

当前 head 另外还存在重复 import、ASF header、退役测试字段和格式问题,并且与 main 冲突、没有 CI。这些都说明保持 Draft 是正确的,但不值得为了修这些表面问题继续保留旧架构。正确下一步是基于当前 owner/handoff seam 重建一个最小完整切片,只迁移有价值的 qualification 证据。


AI-assisted review notice: Codex coordinated independent review lanes; I verified the exact-head diff, current-main owner seams, reachability, and severity before publication. This does not replace the repository's required independent human approval.

protocol: ProtocolRange;
compositionId: string;
generation?: string;
candidateGeneration?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This makes ordinary connection election carry replacement policy. A non-npx path, package version, or development UUID is not verified deployment ownership, yet the TUI can turn those proxy facts into a generation takeover request. Current main has a durable owner/handoff transaction that is the natural authority for retirement and successor launch. Please keep connectOrSpawn as a compatibility-fact/admission seam and move this replacement action behind the verified owner transaction; otherwise the repository retains two lifecycle authorities.

const activity = error.conflict.handshake?.activity;
return error.conflict.kind === 'upgrade_required'
? error.conflict.restartable
: activity !== undefined && activity.connections === 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2 · category ①] connections === 0 is weaker than the Host's actual takeover condition, which also requires zero active operations and residencies. A normal scheduled-task residency can therefore make the TUI offer Restart, only for the Kernel to reject it and return the user to the same prompt. This is recoverable through Wait/Cancel, so P2 is the calibrated level. The thin adapter should consume an authoritative replacement disposition rather than re-derive idleness here.

import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { deriveMakaDataRoots, resolveMakaDataRoots } from './workspace-root.js';
import { join } from 'node:path';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This exact head imports join twice, so the CLI module fails to parse (Identifier 'join' has already been declared). The branch also retains unused imports around this edit. Please delete the duplicate/dead imports; if this code is rewritten behind the owner seam, avoid carrying this stale composition forward.

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

Labels

effort/XLOver 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@me2seeks@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(cli): reconcile local Runtime Host generations by me2seeks · Pull Request #3254 · apache/maka · GitHub
Skip to content

feat(cli): reconcile local Runtime Host generations - #3254

Draft
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff
Draft

feat(cli): reconcile local Runtime Host generations#3254
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff

Conversation

@me2seeks

@me2seeksme2seeks commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Current status

This Draft is paused as implementation and qualification evidence while #3709 and the #3228 reconciliation gates stabilize. It is not the target owner architecture and should not be marked Ready in its current form. The retained value is its generation/epoch diagnostics, Restart/Wait/Cancel UX, exact-epoch fencing, released-Host takeover adapter, and real PTY evidence. After the gates close, the implementation should be split or rewritten so replacement policy no longer lives in ordinary connectOrSpawn election.

简体中文

本 Draft 暂停实现,用作 #3709#3228 reconciliation gate 稳定前的实现和 qualification 证据。它不是目标 owner 架构,当前形态不应转为 Ready。需要保留的是 generation/epoch 诊断、Restart/Wait/Cancel UX、exact-epoch fencing、已发布 Host takeover adapter 与真实 PTY 证据。Gate 闭合后应拆分或重写实现,使 replacement policy 不再位于普通 connectOrSpawn election 中。

Convergence disposition

The branch has now been audited against the owner/transfer rules in #3709. When work resumes, it should be split or rewritten according to this inventory; the current Draft must not be merged as one lifecycle implementation.

Retain as evidence

  • real PTY Restart / Wait / Cancel scenarios across released compatibility epochs;
  • exact observed-HostEpoch fencing and stale-takeover rejection;
  • same-epoch compatibility evidence showing that build/deployment skew does not require replacement;
  • remote-profile and service-mode isolation;
  • bounded Host activity/residency diagnostics and explicit interruption warning;
  • invocation and cache-disappearance scenarios, rewritten against the selected npx contract.

Migrate behind the owner/reconciler seam

  • TUI conflict wording and decision parsing become a thin presentation adapter over typed connect | owner_transfer_required | wait | cancel | operator_required outcomes;
  • the handshake takeover path becomes a bounded released-Host capability adapter with an explicit removal condition;
  • package/provenance resolution becomes an input adapter that returns verified DeploymentIdentity; it does not decide authority;
  • candidate launch keeps exact deployment identity, but it is invoked by the owner transaction rather than ordinary connection election;
  • _npx detection remains a negative provenance guard shared with managed setup, never positive owner proof.

Delete or rewrite

  • replacement-policy fields and the extra exact-generation probe carried through ordinary connectOrSpawn;
  • installationScope === 'persistent' as replacement authority;
  • package version or a per-process development UUID as verified deployment identity;
  • the TUI-owned retry/replacement loop as a lifecycle state machine;
  • any last-launch-wins behavior or implication that a successful connection, package path, PID, version, or compatible epoch transfers ownership;
  • the branch-local architecture drafts in their current form once their durable decisions and qualification evidence are captured by architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709; they should not become a second target-architecture authority.

Simplification result

  • P0: none.
  • P1 — remove lifecycle authority from ordinary connection election.localGenerationRequest, candidateGeneration, and the TUI-owned retry loop currently form a parallel replacement path. Migrating the released-Host takeover mechanism behind one owner transaction lets these connection-level policy representations and the Surface state machine disappear while preserving compatibility admission and exact-epoch fencing.
  • P2 — remove proxy identities and proxy authority.installationScope === 'persistent' and version/development-UUID generation are maintained only to approximate facts now owned by the durable owner record and verified DeploymentIdentity. The shared _npx detector remains because managed setup and invocation policy still consume its negative provenance fact.
  • P2 — remove duplicate target-architecture documents from the eventual implementation PR.architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 is now the target architecture and decision authority. The PR should retain links, tests, and implementation-specific documentation, not another full lifecycle design whose Current/Planned status can drift.
  • Decision gate — legacy adapter removal. The handshake takeover path remains until the minimum supported released Host set exposes the stable owner-side lifecycle capability; the decisive evidence is the released-version support/qualification matrix.
  • Decision gate — rollback qualification. Previous-artifact retry cannot be simplified into unconditional rollback until fix(storage): retire completed legacy migration metadata #3227 proves the relevant storage transitions safe.

Audit coverage

SliceStatusDisposition
installation/provenance contextReviewedretain resolution seam and shared _npx guard; replace authority and identity inference
ordinary local connection/electionReviewedremove replacement policy; preserve compatibility admission
TUI conflict adapterReviewedretain presentation and decision vocabulary; migrate lifecycle ownership
Host handshake takeoverReviewedretain only as bounded legacy adapter
remote/service isolationReviewedretain unchanged operator boundary
unit/integration/PTY qualificationReviewedmigrate invariant and released-artifact evidence, not branch structure
branch architecture documentsReviewedconsolidate target authority in #3709; rewrite or remove duplicated Current claims
storage downgrade/recoveryPartialretain fail-closed boundary; exact qualification remains owned by #3227
简体中文

收敛处置清单

该分支已经按 #3709 的 owner/transfer 规则完成审计。恢复工作后,应依据以下清单拆分或重写;当前 Draft 不能作为一整套 lifecycle implementation 合并。

作为证据保留

  • 跨已发布 compatibility epoch 的真实 PTY Restart / Wait / Cancel 场景;
  • 绑定 observed HostEpoch 的精确 fencing 与 stale takeover rejection;
  • 证明 same-epoch build/deployment skew 不要求 replacement 的兼容性证据;
  • remote profile 与 service-mode 隔离;
  • 有界 Host activity/residency 诊断和明确 interruption warning;
  • invocation 与 cache disappearance 场景,但要按已选 npx contract 重写。

迁移到 owner/reconciler seam 后面

  • TUI conflict 文案与 decision parsing 变成 typed connect | owner_transfer_required | wait | cancel | operator_required outcome 的薄 presentation adapter;
  • handshake takeover 变成有明确删除条件的 bounded released-Host capability adapter;
  • package/provenance resolution 变成返回 verified DeploymentIdentity 的 input adapter,不再决定 authority;
  • candidate launch 保留 exact deployment identity,但由 owner transaction 调用,不再由普通 connection election 调用;
  • _npx detection 保留为与 managed setup 共享的负向 provenance guard,永远不是正向 owner proof。

删除或重写

  • 普通 connectOrSpawn 中携带的 replacement-policy 字段与额外 exact-generation probe;
  • installationScope === 'persistent' 当作 replacement authority;
  • 把 package version 或 process-scoped development UUID 当作 verified deployment identity;
  • 把 TUI-owned retry/replacement loop 当作 lifecycle state machine;
  • 任何 last-launch-wins 行为,以及“成功连接、package path、PID、version 或 compatible epoch 会转移 ownership”的暗示;
  • 当前形态的 branch-local architecture draft:其中长期有效的决定和 qualification 证据进入 architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 后,不应再形成第二个 target-architecture authority。

简化审计结果

  • P0: 无。
  • P1——从普通 connection election 删除 lifecycle authority。localGenerationRequestcandidateGeneration 与 TUI-owned retry loop 当前形成一条平行 replacement path。把 released-Host takeover mechanism 迁移到唯一 owner transaction 后,可以删除这些 connection-level policy representation 与 Surface state machine,同时保留 compatibility admission 和 exact-epoch fencing。
  • P2——删除代理 identity 与代理 authority。installationScope === 'persistent' 和 version/development-UUID generation 只是近似 durable owner record 与 verified DeploymentIdentity 应拥有的事实。共享 _npx detector 仍保留,因为 managed setup 与 invocation policy 真实消费它提供的负向 provenance fact。
  • P2——从最终 implementation PR 删除重复 target-architecture document。architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 已是目标架构与决策 authority。PR 应保留链接、测试和 implementation-specific 文档,而不是再维护一份 Current/Planned 状态可能漂移的完整 lifecycle design。
  • Decision gate——legacy adapter 删除时机。 在最低支持的 released Host 集合提供稳定 owner-side lifecycle capability 前,handshake takeover path 仍要保留;决定性证据是 released-version support/qualification matrix。
  • Decision gate——rollback qualification。fix(storage): retire completed legacy migration metadata #3227 证明相关 storage transition 安全前,previous-artifact retry 不能简化成无条件 rollback。

审计覆盖

Slice状态处置
installation/provenance contextReviewed保留 resolution seam 与共享 _npx guard;替换 authority/identity inference
普通 local connection/electionReviewed删除 replacement policy;保留 compatibility admission
TUI conflict adapterReviewed保留 presentation/decision vocabulary;迁移 lifecycle ownership
Host handshake takeoverReviewed仅作为 bounded legacy adapter 保留
remote/service isolationReviewed保持 operator boundary 不变
unit/integration/PTY qualificationReviewed迁移 invariant 与 released-artifact evidence,不迁移 branch structure
branch architecture documentsReviewedtarget authority 收敛到 #3709;重写或删除重复的 Current claim
storage downgrade/recoveryPartial保留 fail-closed boundary;精确 qualification 仍由 #3227 负责

Summary

Teach the local CLI/TUI to identify the installation that supplied its Runtime Host candidate and negotiate that candidate generation explicitly.

Compatible same-epoch Clients continue using the active Host even when builds differ. For a local cross-epoch conflict, TUI presents Restart, Wait, or Cancel using authoritative Host activity; Restart is fenced to the observed Host epoch. Remote profiles never receive local replacement authority, and transient npx launches cannot request takeover.

This is the first bounded slice of the installation lifecycle design. Artifact staging/switching, a public update command, same-epoch replacement, managed remote updates, and durable npx ownership remain out of scope.

Refs #3231
Refs #3243
Refs #3244
Refs #3245
Refs #3709

Verification

  • Biome check passed for the changed code and tests.
  • @maka/core, @maka/storage, @maka/mcp, @maka/runtime, @maka/runtime-host, and maka-agent builds passed.
  • Runtime Host and CLI typechecks passed.
  • Focused CLI/context, service guard, and Host candidate-generation tests passed (19/19).
  • Real PTY epoch 24 → 26 checks covered Restart, Wait, and Cancel while a Scheduled Task retained the old Host.
  • git diff --check passed.

Not run: full repository test suite or Desktop UI tests.

Draft scope

  • Resolve installation scope and artifact generation once per CLI launch
  • Admit compatible same-epoch Clients without replacing the Host
  • Fence explicit local takeover to the observed Host epoch
  • Keep remote and transient npx callers outside local replacement authority
  • Document Current, Planned, and Exploratory lifecycle boundaries
  • Review product wording and protocol ownership with maintainers
  • Add release-package and platform qualification before marking ready

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex assisted with architecture analysis, implementation, documentation, tests, and local review. The human contributor will review the Draft before it is submitted for merge.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@me2seeks
me2seeksforce-pushed the feat/cli-runtime-host-generation-handoff branch from f3c93a9 to d59f548CompareAugust 23, 2026 10:19
Main retired the client surface identity; the replayed generation-rejection
and election tests still passed it, breaking typecheck.
Generated-by: maka

@Astro-HanAstro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for keeping this Draft's status and convergence notes honest. I reviewed exact head 8a197b08ae50445b88ea5d671b977c821d072131 (14 files, +1294/-50).

The underlying problem is demonstrated: an older local Runtime Host can remain resident across a compatibility-epoch change, leaving a newer CLI unable to make progress. Exact observed-epoch fencing, authoritative activity diagnostics, remote/service/npx isolation, and the Restart / Wait / Cancel vocabulary are useful evidence worth preserving.

The current implementation, however, is no longer the right solution owner. It carries replacement policy through the ordinary TUI → CLI context → connectOrSpawn election path, using installation path/version/development UUID as proxy deployment identity. Current main now has durable deployment ownership, handoff, and owner-transaction seams; keeping this path would create a second lifecycle authority. By first principles, ordinary connection election should report typed compatibility facts, while the verified owner transaction performs retirement, replacement, and candidate launch.

So the correct disposition is not to repair this 1,294-line branch into a mergeable PR. Keep/migrate the exact-epoch and real-Host evidence, then delete or rewrite the branch-local replacement policy, TUI-owned retry state machine, proxy identity, fake-connector wiring tests, and roughly 754 lines of duplicate architecture drafts. #3709 should remain the single target-architecture authority.

I left the most concrete code findings inline:

  • P1:candidateGeneration / takeoverHostEpoch put replacement authority in ordinary connectOrSpawn;
  • P2: Restart is offered when connections === 0, although the Host also requires zero active operations/residencies, producing a recoverable conflict loop;
  • P1: the current head does not parse because join is imported twice.

There are additional current-head delivery failures: six new source/docs files lack ASF headers; tests still pass the retired surface field; and changed-file formatting fails. The exact head has no hosted checks and conflicts with current main. These reinforce the Draft status, but they are not a reason to preserve the obsolete architecture.

Next step: keep this Draft paused. Rebuild the smallest coherent slice behind the current owner/handoff seam, migrate only the valuable Host-kernel and released-artifact/PTTY evidence, remove duplicate architecture documents, then refresh exact-head CI and qualification. Do not simply rebase this branch and mark it Ready.

中文对照

感谢你在 Draft 正文里坦诚记录了当前状态和收敛方向。底层问题是真实的:旧版 Local Runtime Host 可能因为驻留任务跨 compatibility epoch 继续运行,导致新版 CLI 无法继续。精确 epoch fencing、Host activity 诊断、remote/service/npx 隔离,以及 Restart / Wait / Cancel 的交互词汇都值得保留。

但当前实现已经不再属于正确的 owner。它把 replacement policy 放进 TUI → CLI context → 普通 connectOrSpawn election,并使用安装路径、版本和 development UUID 近似 deployment identity。现在 main 已经有 durable owner、handoff 和 owner transaction;继续保留这条路径会形成第二套生命周期 authority。普通连接选举应只返回 typed compatibility facts,真正的 retirement、replacement 和 candidate launch 应由 verified owner transaction 完成。

因此,不建议把这 1294 行分支继续修成可合并 PR。应迁移 exact-epoch 和真实 Host 证据,然后删除或重写 branch-local replacement policy、TUI 自己维护的 retry state machine、代理 identity、只验证字段映射的 fake connector 测试,以及约 754 行重复架构草稿;#3709 保持唯一目标架构 authority。

当前 head 另外还存在重复 import、ASF header、退役测试字段和格式问题,并且与 main 冲突、没有 CI。这些都说明保持 Draft 是正确的,但不值得为了修这些表面问题继续保留旧架构。正确下一步是基于当前 owner/handoff seam 重建一个最小完整切片,只迁移有价值的 qualification 证据。


AI-assisted review notice: Codex coordinated independent review lanes; I verified the exact-head diff, current-main owner seams, reachability, and severity before publication. This does not replace the repository's required independent human approval.

protocol: ProtocolRange;
compositionId: string;
generation?: string;
candidateGeneration?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This makes ordinary connection election carry replacement policy. A non-npx path, package version, or development UUID is not verified deployment ownership, yet the TUI can turn those proxy facts into a generation takeover request. Current main has a durable owner/handoff transaction that is the natural authority for retirement and successor launch. Please keep connectOrSpawn as a compatibility-fact/admission seam and move this replacement action behind the verified owner transaction; otherwise the repository retains two lifecycle authorities.

const activity = error.conflict.handshake?.activity;
return error.conflict.kind === 'upgrade_required'
? error.conflict.restartable
: activity !== undefined && activity.connections === 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2 · category ①] connections === 0 is weaker than the Host's actual takeover condition, which also requires zero active operations and residencies. A normal scheduled-task residency can therefore make the TUI offer Restart, only for the Kernel to reject it and return the user to the same prompt. This is recoverable through Wait/Cancel, so P2 is the calibrated level. The thin adapter should consume an authoritative replacement disposition rather than re-derive idleness here.

import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { deriveMakaDataRoots, resolveMakaDataRoots } from './workspace-root.js';
import { join } from 'node:path';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This exact head imports join twice, so the CLI module fails to parse (Identifier 'join' has already been declared). The branch also retains unused imports around this edit. Please delete the duplicate/dead imports; if this code is rewritten behind the owner seam, avoid carrying this stale composition forward.

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

Labels

effort/XLOver 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@me2seeks@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(cli): reconcile local Runtime Host generations by me2seeks · Pull Request #3254 · apache/maka · GitHub
Skip to content

feat(cli): reconcile local Runtime Host generations - #3254

Draft
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff
Draft

feat(cli): reconcile local Runtime Host generations#3254
me2seeks wants to merge 3 commits into
apache:mainfrom
me2seeks:feat/cli-runtime-host-generation-handoff

Conversation

@me2seeks

@me2seeksme2seeks commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Current status

This Draft is paused as implementation and qualification evidence while #3709 and the #3228 reconciliation gates stabilize. It is not the target owner architecture and should not be marked Ready in its current form. The retained value is its generation/epoch diagnostics, Restart/Wait/Cancel UX, exact-epoch fencing, released-Host takeover adapter, and real PTY evidence. After the gates close, the implementation should be split or rewritten so replacement policy no longer lives in ordinary connectOrSpawn election.

简体中文

本 Draft 暂停实现,用作 #3709#3228 reconciliation gate 稳定前的实现和 qualification 证据。它不是目标 owner 架构,当前形态不应转为 Ready。需要保留的是 generation/epoch 诊断、Restart/Wait/Cancel UX、exact-epoch fencing、已发布 Host takeover adapter 与真实 PTY 证据。Gate 闭合后应拆分或重写实现,使 replacement policy 不再位于普通 connectOrSpawn election 中。

Convergence disposition

The branch has now been audited against the owner/transfer rules in #3709. When work resumes, it should be split or rewritten according to this inventory; the current Draft must not be merged as one lifecycle implementation.

Retain as evidence

  • real PTY Restart / Wait / Cancel scenarios across released compatibility epochs;
  • exact observed-HostEpoch fencing and stale-takeover rejection;
  • same-epoch compatibility evidence showing that build/deployment skew does not require replacement;
  • remote-profile and service-mode isolation;
  • bounded Host activity/residency diagnostics and explicit interruption warning;
  • invocation and cache-disappearance scenarios, rewritten against the selected npx contract.

Migrate behind the owner/reconciler seam

  • TUI conflict wording and decision parsing become a thin presentation adapter over typed connect | owner_transfer_required | wait | cancel | operator_required outcomes;
  • the handshake takeover path becomes a bounded released-Host capability adapter with an explicit removal condition;
  • package/provenance resolution becomes an input adapter that returns verified DeploymentIdentity; it does not decide authority;
  • candidate launch keeps exact deployment identity, but it is invoked by the owner transaction rather than ordinary connection election;
  • _npx detection remains a negative provenance guard shared with managed setup, never positive owner proof.

Delete or rewrite

  • replacement-policy fields and the extra exact-generation probe carried through ordinary connectOrSpawn;
  • installationScope === 'persistent' as replacement authority;
  • package version or a per-process development UUID as verified deployment identity;
  • the TUI-owned retry/replacement loop as a lifecycle state machine;
  • any last-launch-wins behavior or implication that a successful connection, package path, PID, version, or compatible epoch transfers ownership;
  • the branch-local architecture drafts in their current form once their durable decisions and qualification evidence are captured by architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709; they should not become a second target-architecture authority.

Simplification result

  • P0: none.
  • P1 — remove lifecycle authority from ordinary connection election.localGenerationRequest, candidateGeneration, and the TUI-owned retry loop currently form a parallel replacement path. Migrating the released-Host takeover mechanism behind one owner transaction lets these connection-level policy representations and the Surface state machine disappear while preserving compatibility admission and exact-epoch fencing.
  • P2 — remove proxy identities and proxy authority.installationScope === 'persistent' and version/development-UUID generation are maintained only to approximate facts now owned by the durable owner record and verified DeploymentIdentity. The shared _npx detector remains because managed setup and invocation policy still consume its negative provenance fact.
  • P2 — remove duplicate target-architecture documents from the eventual implementation PR.architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 is now the target architecture and decision authority. The PR should retain links, tests, and implementation-specific documentation, not another full lifecycle design whose Current/Planned status can drift.
  • Decision gate — legacy adapter removal. The handshake takeover path remains until the minimum supported released Host set exposes the stable owner-side lifecycle capability; the decisive evidence is the released-version support/qualification matrix.
  • Decision gate — rollback qualification. Previous-artifact retry cannot be simplified into unconditional rollback until fix(storage): retire completed legacy migration metadata #3227 proves the relevant storage transitions safe.

Audit coverage

SliceStatusDisposition
installation/provenance contextReviewedretain resolution seam and shared _npx guard; replace authority and identity inference
ordinary local connection/electionReviewedremove replacement policy; preserve compatibility admission
TUI conflict adapterReviewedretain presentation and decision vocabulary; migrate lifecycle ownership
Host handshake takeoverReviewedretain only as bounded legacy adapter
remote/service isolationReviewedretain unchanged operator boundary
unit/integration/PTY qualificationReviewedmigrate invariant and released-artifact evidence, not branch structure
branch architecture documentsReviewedconsolidate target authority in #3709; rewrite or remove duplicated Current claims
storage downgrade/recoveryPartialretain fail-closed boundary; exact qualification remains owned by #3227
简体中文

收敛处置清单

该分支已经按 #3709 的 owner/transfer 规则完成审计。恢复工作后,应依据以下清单拆分或重写;当前 Draft 不能作为一整套 lifecycle implementation 合并。

作为证据保留

  • 跨已发布 compatibility epoch 的真实 PTY Restart / Wait / Cancel 场景;
  • 绑定 observed HostEpoch 的精确 fencing 与 stale takeover rejection;
  • 证明 same-epoch build/deployment skew 不要求 replacement 的兼容性证据;
  • remote profile 与 service-mode 隔离;
  • 有界 Host activity/residency 诊断和明确 interruption warning;
  • invocation 与 cache disappearance 场景,但要按已选 npx contract 重写。

迁移到 owner/reconciler seam 后面

  • TUI conflict 文案与 decision parsing 变成 typed connect | owner_transfer_required | wait | cancel | operator_required outcome 的薄 presentation adapter;
  • handshake takeover 变成有明确删除条件的 bounded released-Host capability adapter;
  • package/provenance resolution 变成返回 verified DeploymentIdentity 的 input adapter,不再决定 authority;
  • candidate launch 保留 exact deployment identity,但由 owner transaction 调用,不再由普通 connection election 调用;
  • _npx detection 保留为与 managed setup 共享的负向 provenance guard,永远不是正向 owner proof。

删除或重写

  • 普通 connectOrSpawn 中携带的 replacement-policy 字段与额外 exact-generation probe;
  • installationScope === 'persistent' 当作 replacement authority;
  • 把 package version 或 process-scoped development UUID 当作 verified deployment identity;
  • 把 TUI-owned retry/replacement loop 当作 lifecycle state machine;
  • 任何 last-launch-wins 行为,以及“成功连接、package path、PID、version 或 compatible epoch 会转移 ownership”的暗示;
  • 当前形态的 branch-local architecture draft:其中长期有效的决定和 qualification 证据进入 architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 后,不应再形成第二个 target-architecture authority。

简化审计结果

  • P0: 无。
  • P1——从普通 connection election 删除 lifecycle authority。localGenerationRequestcandidateGeneration 与 TUI-owned retry loop 当前形成一条平行 replacement path。把 released-Host takeover mechanism 迁移到唯一 owner transaction 后,可以删除这些 connection-level policy representation 与 Surface state machine,同时保留 compatibility admission 和 exact-epoch fencing。
  • P2——删除代理 identity 与代理 authority。installationScope === 'persistent' 和 version/development-UUID generation 只是近似 durable owner record 与 verified DeploymentIdentity 应拥有的事实。共享 _npx detector 仍保留,因为 managed setup 与 invocation policy 真实消费它提供的负向 provenance fact。
  • P2——从最终 implementation PR 删除重复 target-architecture document。architecture(runtime-host): converge local Host lifecycle through owner-scoped reconciliation #3709 已是目标架构与决策 authority。PR 应保留链接、测试和 implementation-specific 文档,而不是再维护一份 Current/Planned 状态可能漂移的完整 lifecycle design。
  • Decision gate——legacy adapter 删除时机。 在最低支持的 released Host 集合提供稳定 owner-side lifecycle capability 前,handshake takeover path 仍要保留;决定性证据是 released-version support/qualification matrix。
  • Decision gate——rollback qualification。fix(storage): retire completed legacy migration metadata #3227 证明相关 storage transition 安全前,previous-artifact retry 不能简化成无条件 rollback。

审计覆盖

Slice状态处置
installation/provenance contextReviewed保留 resolution seam 与共享 _npx guard;替换 authority/identity inference
普通 local connection/electionReviewed删除 replacement policy;保留 compatibility admission
TUI conflict adapterReviewed保留 presentation/decision vocabulary;迁移 lifecycle ownership
Host handshake takeoverReviewed仅作为 bounded legacy adapter 保留
remote/service isolationReviewed保持 operator boundary 不变
unit/integration/PTY qualificationReviewed迁移 invariant 与 released-artifact evidence,不迁移 branch structure
branch architecture documentsReviewedtarget authority 收敛到 #3709;重写或删除重复的 Current claim
storage downgrade/recoveryPartial保留 fail-closed boundary;精确 qualification 仍由 #3227 负责

Summary

Teach the local CLI/TUI to identify the installation that supplied its Runtime Host candidate and negotiate that candidate generation explicitly.

Compatible same-epoch Clients continue using the active Host even when builds differ. For a local cross-epoch conflict, TUI presents Restart, Wait, or Cancel using authoritative Host activity; Restart is fenced to the observed Host epoch. Remote profiles never receive local replacement authority, and transient npx launches cannot request takeover.

This is the first bounded slice of the installation lifecycle design. Artifact staging/switching, a public update command, same-epoch replacement, managed remote updates, and durable npx ownership remain out of scope.

Refs #3231
Refs #3243
Refs #3244
Refs #3245
Refs #3709

Verification

  • Biome check passed for the changed code and tests.
  • @maka/core, @maka/storage, @maka/mcp, @maka/runtime, @maka/runtime-host, and maka-agent builds passed.
  • Runtime Host and CLI typechecks passed.
  • Focused CLI/context, service guard, and Host candidate-generation tests passed (19/19).
  • Real PTY epoch 24 → 26 checks covered Restart, Wait, and Cancel while a Scheduled Task retained the old Host.
  • git diff --check passed.

Not run: full repository test suite or Desktop UI tests.

Draft scope

  • Resolve installation scope and artifact generation once per CLI launch
  • Admit compatible same-epoch Clients without replacing the Host
  • Fence explicit local takeover to the observed Host epoch
  • Keep remote and transient npx callers outside local replacement authority
  • Document Current, Planned, and Exploratory lifecycle boundaries
  • Review product wording and protocol ownership with maintainers
  • Add release-package and platform qualification before marking ready

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex assisted with architecture analysis, implementation, documentation, tests, and local review. The human contributor will review the Draft before it is submitted for merge.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@me2seeks
me2seeksforce-pushed the feat/cli-runtime-host-generation-handoff branch from f3c93a9 to d59f548CompareAugust 23, 2026 10:19
Main retired the client surface identity; the replayed generation-rejection
and election tests still passed it, breaking typecheck.
Generated-by: maka

@Astro-HanAstro-Han left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for keeping this Draft's status and convergence notes honest. I reviewed exact head 8a197b08ae50445b88ea5d671b977c821d072131 (14 files, +1294/-50).

The underlying problem is demonstrated: an older local Runtime Host can remain resident across a compatibility-epoch change, leaving a newer CLI unable to make progress. Exact observed-epoch fencing, authoritative activity diagnostics, remote/service/npx isolation, and the Restart / Wait / Cancel vocabulary are useful evidence worth preserving.

The current implementation, however, is no longer the right solution owner. It carries replacement policy through the ordinary TUI → CLI context → connectOrSpawn election path, using installation path/version/development UUID as proxy deployment identity. Current main now has durable deployment ownership, handoff, and owner-transaction seams; keeping this path would create a second lifecycle authority. By first principles, ordinary connection election should report typed compatibility facts, while the verified owner transaction performs retirement, replacement, and candidate launch.

So the correct disposition is not to repair this 1,294-line branch into a mergeable PR. Keep/migrate the exact-epoch and real-Host evidence, then delete or rewrite the branch-local replacement policy, TUI-owned retry state machine, proxy identity, fake-connector wiring tests, and roughly 754 lines of duplicate architecture drafts. #3709 should remain the single target-architecture authority.

I left the most concrete code findings inline:

  • P1:candidateGeneration / takeoverHostEpoch put replacement authority in ordinary connectOrSpawn;
  • P2: Restart is offered when connections === 0, although the Host also requires zero active operations/residencies, producing a recoverable conflict loop;
  • P1: the current head does not parse because join is imported twice.

There are additional current-head delivery failures: six new source/docs files lack ASF headers; tests still pass the retired surface field; and changed-file formatting fails. The exact head has no hosted checks and conflicts with current main. These reinforce the Draft status, but they are not a reason to preserve the obsolete architecture.

Next step: keep this Draft paused. Rebuild the smallest coherent slice behind the current owner/handoff seam, migrate only the valuable Host-kernel and released-artifact/PTTY evidence, remove duplicate architecture documents, then refresh exact-head CI and qualification. Do not simply rebase this branch and mark it Ready.

中文对照

感谢你在 Draft 正文里坦诚记录了当前状态和收敛方向。底层问题是真实的:旧版 Local Runtime Host 可能因为驻留任务跨 compatibility epoch 继续运行,导致新版 CLI 无法继续。精确 epoch fencing、Host activity 诊断、remote/service/npx 隔离,以及 Restart / Wait / Cancel 的交互词汇都值得保留。

但当前实现已经不再属于正确的 owner。它把 replacement policy 放进 TUI → CLI context → 普通 connectOrSpawn election,并使用安装路径、版本和 development UUID 近似 deployment identity。现在 main 已经有 durable owner、handoff 和 owner transaction;继续保留这条路径会形成第二套生命周期 authority。普通连接选举应只返回 typed compatibility facts,真正的 retirement、replacement 和 candidate launch 应由 verified owner transaction 完成。

因此,不建议把这 1294 行分支继续修成可合并 PR。应迁移 exact-epoch 和真实 Host 证据,然后删除或重写 branch-local replacement policy、TUI 自己维护的 retry state machine、代理 identity、只验证字段映射的 fake connector 测试,以及约 754 行重复架构草稿;#3709 保持唯一目标架构 authority。

当前 head 另外还存在重复 import、ASF header、退役测试字段和格式问题,并且与 main 冲突、没有 CI。这些都说明保持 Draft 是正确的,但不值得为了修这些表面问题继续保留旧架构。正确下一步是基于当前 owner/handoff seam 重建一个最小完整切片,只迁移有价值的 qualification 证据。


AI-assisted review notice: Codex coordinated independent review lanes; I verified the exact-head diff, current-main owner seams, reachability, and severity before publication. This does not replace the repository's required independent human approval.

protocol: ProtocolRange;
compositionId: string;
generation?: string;
candidateGeneration?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This makes ordinary connection election carry replacement policy. A non-npx path, package version, or development UUID is not verified deployment ownership, yet the TUI can turn those proxy facts into a generation takeover request. Current main has a durable owner/handoff transaction that is the natural authority for retirement and successor launch. Please keep connectOrSpawn as a compatibility-fact/admission seam and move this replacement action behind the verified owner transaction; otherwise the repository retains two lifecycle authorities.

const activity = error.conflict.handshake?.activity;
return error.conflict.kind === 'upgrade_required'
? error.conflict.restartable
: activity !== undefined && activity.connections === 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2 · category ①] connections === 0 is weaker than the Host's actual takeover condition, which also requires zero active operations and residencies. A normal scheduled-task residency can therefore make the TUI offer Restart, only for the Kernel to reject it and return the user to the same prompt. This is recoverable through Wait/Cancel, so P2 is the calibrated level. The thin adapter should consume an authoritative replacement disposition rather than re-derive idleness here.

import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { deriveMakaDataRoots, resolveMakaDataRoots } from './workspace-root.js';
import { join } from 'node:path';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1 · category ①] This exact head imports join twice, so the CLI module fails to parse (Identifier 'join' has already been declared). The branch also retains unused imports around this edit. Please delete the duplicate/dead imports; if this code is rewritten behind the owner seam, avoid carrying this stale composition forward.

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

Labels

effort/XLOver 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@me2seeks@Astro-Han