Add production ZCode runtime - #2377
Conversation
Add a first-class ZCode runtime with an exact zcode-app-cli@3.10.2-18 pin, host-local provider-owned login, supervised one-process turns, strict one-object JSON parsing, bounded output, session resume, capability probing, shared catalog/config validation, and web selection UI.\n\nWindows and MCP delegation fail closed. Retry custody stays with ProviderAttempt, and runtime approval modes exclude unchecked permissions.
yuezengwu
left a comment
There was a problem hiding this comment.
Reviewed exact head fa268e899c008130f6ab739241c69b0a0b7e76ee. This production runtime is not ready to ship: the inline findings leave process/output custody, clean-host authentication recovery, the pinned wrapper compatibility boundary, and model selection without the fail-closed guarantees required for managed runtimes. The current CLI suite also fails deterministically after adding the provider.
Validation on this exact head:
pnpm --filter @first-tree/client typecheck— passpnpm --filter @first-tree/client exec vitest run src/providers/zcode/__tests__— 10/10 pass, but only two handler tests and none cover the lifecycle/failure paths belowpnpm --filter first-tree-dev exec vitest run src/__tests__/capability-refresh.test.ts— 3 failed, 19 passed- Biome over all 26 changed TS/TSX/JSON files — pass
git diff --check— pass
The PR also cites Context Tree commit 82be900117b58a6f55e73aa3fd04c711c8fec812, but that object is not reachable from the canonical first-tree-ai/opentag-context-tree master fetched during this review (current 81a3f8986f79c43020954e75b2b89507936619a3). Please correct the exact evidence and revalidate the runtime custody/ACK contracts against the canonical tree.
Because this is an external contribution introducing an unofficial wrapper and a browser/tool-capable runtime into production, final acceptance and merge also require an explicit human supply-chain/privilege review after the technical blockers are resolved. I did not modify the branch, approve, or merge it.
|
Reviewed fixes are pushed at exact head ZCode now fails closed on exact wrapper/runtime version The PR body now points to |
|
All contributors are covered by the First Tree CLA. |
9c7be8e to
8f51d31
Compare
|
Updated at exact head |
yuezengwu
left a comment
There was a problem hiding this comment.
Reviewed exact head 858f458e07d107be301400f7f0ce559ee7dc45fd from scratch. Requesting changes for the following release blockers.
-
[P1] Clean-host authentication recovery points to a command First Tree never installs. The catalog advertises
zcode login, butensureOfficialZcodeRuntimeextracts only./opt/ZCode/resources/glm/zcode.cjs, moves that one file into the cache, and launches it throughprocess.execPath; it never installs the package launcher or creates azcodeshim. I independently downloaded the pinned public.deb(146,822,580 bytes, SHA-256b618cfa7...bf0c0) and confirmed that the package'spostinstis what creates/usr/bin/zcode -> /opt/ZCode/zcode; that script is not run by this implementation. In a task-scoped empty home, the extracted runtime itself exits 1 withModel config is missing..., while the recovery surface tells the user to execute the absent bare command. This leaves the advertised clean-host flow unrecoverable after capability admission. Expose a real managed-runtime login/configuration path (or a First Tree-owned shim/driver) and validate it from an empty task-scoped home. -
[P1] The shared runtime cache is race-destructive. On every cache miss,
ensureOfficialZcodeRuntimerecursively removescacheRootbefore staging, and its outer catch recursively removes the same shared root again. Concurrent capability/session preparations therefore allow one resolver to delete a valid runtime installed by another; an unrelated failed download can also erase the winner after its atomic rename. TreatingEEXIST/ENOTEMPTYas a rename race does not fix the unconditional loser cleanup. Use a single-flight/lock or generation-owned staging scheme, and never delete a cache installation this invocation did not own. -
[P1] Artifact acquisition has no deadline or cancellation custody.
downloadExactArtifactcallsfetch(..., { redirect: "error" })without anAbortSignalor timeout, then awaits the body indefinitely. This path runs during both capability probing and session preparation, so a CDN connection/body stall can hang probe aggregation or an Agent start forever. The function then classifies every acquisition failure astransient: false. Add bounded connect/body deadlines and a correctly classified retryable acquisition result. -
[P1] The required client checks are not platform-isolated. On this exact head,
pnpm --filter @first-tree/client exec vitest run src/providers/zcode/__tests__ ...fails 3 tests inofficial-runtime.test.tson the supported macOS/arm64 development host: the success, digest-mismatch, and missing-member cases all hit the host platform gate because they do not injectplatform: "linux"/arch: "x64". The combined run finished with 317 passing and 3 failing tests.pnpm typecheck, the shared catalog tests (9/9), CLI capability-refresh tests (22/22), andgit diff --checkpass.
QA status is BLOCKED, tier full-isolated, for the real provider-backed turn/auth/resume claim: no task-scoped ZCode credential was available, and I did not borrow an operator/provider home or session. The public-artifact integrity/extraction/version smoke passed (zcode.cjs is a regular 12,557,830-byte member with SHA-256 35971604...cbabc, runtime 0.16.5), but that is not real-turn evidence. Case disposition: candidate-new-case; this provider/auth/cross-surface change has no matching ZCode case under packages/qa/cases/.
|
All four release blockers are addressed at exact head
Targeted validation includes 32 ZCode client tests, the full shared suite (954 tests), web sources (2,426 tests), CLI capability refresh (22 tests), typechecks, Biome, extraction smoke checks, and |
yuezengwu
left a comment
There was a problem hiding this comment.
Reviewed exact head a5c0c92e5151a268472079ca1322aec024b358fd from scratch. The cache lock, download deadlines, platform-isolated tests, and in-turn dynamic login command address the prior blockers, but one clean-host recovery blocker remains.
[P1] The shared setup command is still not bound to the admitted managed runtime. packages/shared/src/schemas/runtime-provider-catalog.ts:42 publishes node "$HOME/.cache/.../zcode.cjs" login as the copy-pasteable host login step. The resolver in official-runtime.ts:364-371 can instead install under FIRST_TREE_ZCODE_RUNTIME_CACHE or XDG_CACHE_HOME, so those supported hosts are directed to a nonexistent file. The supported portable First Tree install is also launched with its bundled Node by absolute path (apps/cli/src/core/portable-install-context.ts:23-32) and does not establish that a compatible bare node exists in the user shell. A capability probe can therefore admit the exact managed runtime while Computers/setup recovery tells the user to run a different path or runtime. Please surface the resolved command (including process.execPath and the actual cache root) or add a First Tree-owned login driver/shim rather than freezing $HOME/.cache plus bare node in the shared catalog.
Exact-head validation passed: full client suite 2,879 tests (7 skipped), full shared suite 954 tests, pnpm check, monorepo typecheck/build graph, and git diff --check. GitHub CI is green. The live head was refreshed immediately before this review and remained exact; the PR is currently also conflicting with main. I did not claim real credential-backed provider turn/resume QA.
The shared catalog's copy-pasteable login command hardcoded $HOME/.cache and bare node, so hosts using FIRST_TREE_ZCODE_RUNTIME_CACHE or XDG_CACHE_HOME were pointed at a file that was never extracted there. Mirror ensureOfficialZcodeRuntime's cache-root precedence with a shell fallback expression so the printed command resolves to the file the client actually prepared on any of the three configurations, and note the Node version requirement inline.
# Conflicts: # packages/client/src/__tests__/capability-probes.test.ts # packages/client/src/__tests__/capability-reprobe.test.ts # packages/shared/src/__tests__/runtime-provider-catalog.test.ts # packages/shared/src/schemas/agent-runtime-config.ts
SessionContext gained a required noteTurnStart callback on main (merged above); the zcode and antigravity handler test fixtures predated that and failed typecheck after the merge.
|
Fixed the remaining P1 and resolved the Shared setup command bound to the admitted managed runtime. I verified the nested parameter expansion resolves identically to the TS resolver in bash and dash across all three configurations (unset,
Full validation at this head: monorepo typecheck and |
yuezengwu
left a comment
There was a problem hiding this comment.
Reviewed exact head 221b7b5 from scratch. The cache-root precedence now matches runtime extraction, the main conflict is resolved, and the focused ZCode custody tests remain green. One clean-host recovery blocker from the prior review is still unresolved.
ZCODE_OFFICIAL_DEFAULT_LOGIN_COMMAND still begins with bare node. The author comment explicitly leaves that assumption in place and only adds a requires-Node note. Supported portable First Tree installs run through their bundled Node executable by absolute path and do not establish a compatible node command in the user shell. A clean host can therefore pass ZCode capability admission and have the digest-pinned runtime extracted successfully, yet the Computers/setup recovery command fails before opening provider login because node is absent or below 22.19.0. A comment stating the prerequisite does not make the advertised recovery executable.
Please add a First Tree-owned login command/driver or another recovery surface that invokes the admitted runtime with the same absolute Node executable First Tree resolved. The dynamic in-turn hint already has that exact command; the static Computers/setup path needs the same executable custody rather than bare node.
Exact-head validation: 32 focused ZCode tests, Client typecheck, pnpm check, GitHub CI, and git diff --check pass. I did not claim credential-backed live provider QA.
ensureOfficialZcodeRuntime acquired the runtime lock with a non-recursive mkdir before ever creating its parent directory, so the very first admission on a truly clean host (no ~/.cache/first-tree/zcode/official/ tree yet) failed closed with a bare ENOENT instead of preparing the runtime. Found via a manual empty-HOME smoke test of the new zcode login driver. Ensure the lock's parent directory exists up front.
The shared catalog's copy-pasteable host login step could not be both a runnable command and correct: the exact cache root and absolute Node executable are only knowable to the running Client, and depend on env-var overrides and install mode (portable bundled Node vs. system node). Replace the raw `node <path> login` guess with `first-tree zcode login`, a new CLI command that re-resolves the managed runtime the same way a provider turn does and hands the terminal to it via the exact process.execPath First Tree admitted. Computers/setup additionally threads the connected Computer's own channel-aware CLI binary name (already reported per-client) through RuntimeProviderRow -> RuntimeInstallBox so the live surface shows the binary that actually exists on that host's PATH, while the shared catalog keeps the channel-generic 'first-tree' reference form used throughout docs/cli-reference.md.
|
Addressed the remaining P1 with the driver you asked for, plus a real clean-host bug it surfaced. Exact head is now First Tree-owned Bonus: found and fixed a real clean-host bug while smoke-testing the driver. Full validation at this head: monorepo typecheck and One thing to flag: this run's CI shows |
yuezengwu
left a comment
There was a problem hiding this comment.
Exact-head technical review completed at e33d28ae11ee2f6e3769e867916ecceec07aeba0 against base 38752415320c97c0bd122aa4afb13c3ff60b1b06.
The First Tree-owned zcode login driver closes the prior clean-host recovery blocker: it re-resolves the pinned managed runtime, launches the exact admitted command and arguments through the First Tree-resolved Node executable, forwards provider login arguments, and connected-Computer surfaces use the actual channel binary name. The clean-host cache-lock parent fix is also covered. I found no new technical blocker.
Validation on this exact head:
- ZCode client tests: 33/33 pass
- CLI login and capability-refresh tests: 27/27 pass
pnpm checkandgit diff --check: pass- GitHub lint/typecheck, Client/Web, CLI, portable/release smoke, and final CI summary: pass
- The initial Server failure was two timing-sensitive durable-ack/lost-wake tests in files untouched by this PR. Across six focused local exact-head runs, five passed 59/59 and one reproduced the same race; the failed GitHub job rerun passed.
I am not approving this head yet because the remaining decision is not a code repair. This external contribution adds a pinned third-party browser/tool-capable runtime, and no credential-backed live turn/resume QA was available. I verified the canonical Context Tree at first-tree-ai/opentag-context-tree@ffa582067aa56a6d499a4f96ef89cbb1a76fc0ff: its zero-token-custody and provider-owned host-auth constraints are directionally compatible, but it does not yet adopt ZCode, while the PR description still cites the frozen old first-tree-context repository. A maintainer must explicitly accept the supply-chain/privilege and canonical-context boundary, or request the missing evidence, before approval or merge.
Extract the official ZCode runtime
Summary
First Tree now supports ZCode as a first-class managed runtime without a third-party npm wrapper. On admission, it obtains the official Linux x64 Desktop package directly from Z.AI's release CDN, verifies both the downloaded artifact and the extracted runtime against pinned SHA-256 and byte-size contracts, caches the runtime atomically, and launches the official
zcode.cjsdirectly with First Tree's Node process.https://cdn-zcode.z.ai/zcode/electron/releases/3.10.2/linux-x64/ZCode-3.10.2-linux-x64.debb618cfa70c8f7c8a1a6e2950565cc441c298b801bb2389c292eb0d3add6bf0c0, exactly 146,822,580 bytes./opt/ZCode/resources/glm/zcode.cjs3597160465b67da248fa3fb919920ca30d4e093003a4d70cde2a2e33903cbabc, exactly 12,557,830 bytes0.16.5, Linux x64, and Node.js22.19.0+Artifact acquisition is bounded and cancellable: redirects and unexpected sizes are rejected before retention, while connect, idle-body, and overall deadlines abort stalled CDN transfers. Network, timeout, stall, and retryable HTTP responses remain retryable; digest and contract mismatches stay terminal. Runtime preparation is serialized by an invocation-scoped single-flight plus a cross-process cache lock and generation-safe installation; an unsuccessful candidate cannot delete a valid cache owned by another invocation. Extraction is first-tree-owned, validates the
.deb/tar structure and exact runtime member, verifies the extracted runtime digest, and installs it by atomic rename with a contract manifest. Unsupported platforms and missing, malformed, digest-mismatched, incomplete, or wrong-version runtimes fail closed before capability admission or turn execution.process.execPath [cached zcode.cjs] --json --no-color --mode <build|edit|plan> --cwd <workspace> --prompt <prompt>. Continuation adds--resume <provider-session-id>.sess_session prefix, and rejects trailing or contaminated output.zcode.cjs login) rather than a package launcher First Tree does not install. Credentials remain provider-owned and host-local; First Tree does not read, store, or proxy them.ProviderAttempt. A synthetic pending session can never resume until the provider returns a valid native session id.Validation
zcode.cjs --versionreports0.16.5;login --no-browser --no-coloremits the provider OAuth URL@first-tree/clienttypecheck: pass@first-tree/sharedsuites: 954 tests in 79 files passedgit diff --check: passContext Tree review
Reviewed against the bound Context Tree at repository
first-tree-ai/first-tree-context, branchmain, exact commit82be900117b58a6f55e73aa3fd04c711c8fec812:first-tree/system/cloud/runtime/runtime-auth.mdfirst-tree/system/cloud/runtime/client-runtime.mdThe direct official-runtime extraction and provider-owned, host-local authentication follow the runtime-auth and client-runtime custody architecture.