Skip to content

feat(cli): coordinate npm-global Runtime Host updates - #3925

Open
me2seeks wants to merge 4 commits into
apache:mainfrom
me2seeks:feat/cli-installed-runtime-host-update
Open

feat(cli): coordinate npm-global Runtime Host updates#3925
me2seeks wants to merge 4 commits into
apache:mainfrom
me2seeks:feat/cli-installed-runtime-host-update

Conversation

@me2seeks

Copy link
Copy Markdown
Contributor

Summary

  • add an explicit maka update --target <next|latest|version> path for an npm-global CLI and its local Runtime Host
  • acquire and revalidate the exact official npm archive, stage the target immutably, retire the current Host with the current protocol, and activate the target with the target protocol
  • serialize target Ready verification, npm-global package switching, and owner commit in the existing deployment-authority transaction
  • keep the existing authority lease inherited by activation and package-switch children so a coordinator crash cannot admit a competing owner mutation

User-visible behavior

The command is deliberately explicit: direct npx/development launches, downgrades, remote Hosts, and operator-managed services fail closed. Active work is refused by default; --allow-interrupt-active-tasks is required to authorize interruption.

This preserves the existing ownership boundary: local npm-global deployments can be coordinated by the installed CLI, while remote and service-managed Hosts remain operator-updated.

Why this is one vertical PR

The shared registry-artifact seam and deployment-source finalization now each have a concrete production consumer. Splitting them before the caller would leave speculative abstractions or an incomplete transaction. The implementation still keeps three small process roles because each has a distinct compatibility constraint:

  1. a native-free bootstrap survives Windows npm self-replacement;
  2. a copied current-package coordinator speaks to and retires the current Host;
  3. a staged target-package activator speaks the target epoch and proves exact Ready.

There remains one durable owner record, one handoff transaction, and one authority lock. No scheduler, second deployment journal, or parallel ownership state is introduced.

Failure and recovery

  • activation, package switching, or post-install verification failures leave durable handoff truth for the existing recovery path
  • the inherited authority lease keeps the transaction serialized if the coordinator exits while a child still owns the in-flight operation
  • the npm install uses the exact verified local archive, offline mode, ignored scripts, and an isolated cache, then verifies the same global owner slot and exact target version before commit

Validation

  • built @maka/core, @maka/storage, @maka/mcp, @maka/runtime, @maka/runtime-host, @maka/eval, @maka/computer-use, and maka-agent
  • typechecked storage, Runtime Host, and CLI
  • focused changed-path tests: 37/37 passed
  • scoped CLI release-policy tests: 38/38 passed
  • scoped Biome: 23 files passed
  • native-free cli-core process probe passed
  • git diff --check passed
  • exact published-package probe installed a packed maka-agent@next tarball into an isolated npm-global prefix with offline/script-disabled settings and verified the installed version and binary

The full check:release command was not used as evidence because its repository-wide stale-dist preflight requires unrelated UI/Desktop build outputs; the scoped release-policy tests above pass.

Follow-ups outside this slice

  • reconcile external npm mutations beyond the existing deployment-owner recovery path
  • direct npx ownership and lifecycle
  • broader Desktop/TUI presentation
  • released-version persisted-root qualification across migration/epoch combinations

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

中文说明

本 PR 为 npm 全局安装的 CLI 增加显式 maka update --target <next|latest|version>:复用现有 owner authority、handoff 事务和锁,依次完成旧 Host 退场、目标版本精确 Ready、npm 全局包切换与 owner 提交。

默认拒绝中断活跃工作;只有用户显式传入 --allow-interrupt-active-tasks 才允许。直接 npx、开发环境、降级、remote Host 和由服务管理器托管的 Host 都会 fail closed,继续由用户或运维方主动更新。

三进程并非重复设计:native-free bootstrap 解决 Windows 自替换;当前包 coordinator 负责当前协议;目标包 activator 负责跨 epoch 的目标协议。系统仍只有一份持久 owner 状态、一条 handoff 事务和一把 authority 锁,没有新增 scheduler 或第二套恢复日志。

终审已按 simplify-audit 与第一性原理/奥卡姆剃刀完成,结论为 GO。

Generated-by: Codex

@Astro-Han Astro-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.

I reviewed this head and found no blocking issues.

Implements npm-global Host update coordination via bootstrap→coordinator→activator with verified archive, integrity-checked local npm install, prepare-then-reconcile transaction checks, lease FD heredity and triple identity verification; hosted test/windows_recovery/audit/owner checks SUCCESS.

No P0-P3.

简体中文该头无阻断。

Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

@jackwener jackwener left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I reviewed exact head c68327b27ead94469cbf2b47fc98aaf7042417a2 and found one blocking issue.

P2 — The verified archive has no extracted-size or file-count budget

validateArchive() limits only the compressed .tgz to 256 MiB. The same archive is then passed to npm install once for staging (packages/cli/src/runtime-host-update-package.ts:141-168) and again for the npm-global switch (packages/cli/src/runtime-host-installed-update-coordinator.ts:259-300) without any bound on extracted bytes, entry count, or filesystem consumption.

SHA-512 integrity proves that the archive matches the registry metadata; it does not make the archive's expansion safe. A broken or compromised official publish can therefore use a small valid archive to exhaust the user's disk during the explicit update. If this happens during the final global switch, the target Host has already been activated and the durable handoff remains incomplete while the installed CLI switch has failed.

Please enforce a total uncompressed-byte and entry-count budget before or during extraction, apply the same bound to the final npm-global installation, and add a regression using a small compressed archive with excessive expansion. The exact-head hosted checks succeeded, but the package tests cover archive integrity and release identity rather than this resource boundary.


Posted by an automated review agent operated by @WAWQAQ. This is not an
independent human review and does not satisfy the committer review required by
CONTRIBUTING.md. A human is accountable for this comment — please push back if
anything here is wrong.

简体中文

本条评论由 @WAWQAQ 运行的自动化审查程序发出。它不构成 CONTRIBUTING.md
所要求的独立人类审查,也不能替代人类审查。有人类对本条评论负责,如有错误请直接指出。

@github-actions github-actions Bot added the effort/XL Over 1000 readable lines label Aug 27, 2026
@me2seeks
me2seeks force-pushed the feat/cli-installed-runtime-host-update branch from c68327b to e583c5b Compare August 27, 2026 10:31
Registry integrity binds the downloaded .tgz to its metadata but says
nothing about how far it expands: a small valid archive could exhaust the
user's disk during staging or the final npm-global switch. Scan the tar
headers (one pass over the compressed stream, nothing written) and refuse
archives whose entries exceed a 2 GiB / 100k-entry budget before npm
install consumes them, at both the verified-artifact seam and the global
switch itself. Regression tests pin over-budget, over-crowded, non-gzip,
and truncated archives.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/XL Over 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants