M07 Stage 2: official ZCode CLI execution source — authorized workspace, evidenced edit mode, routable plan lane (D-063, #92) #161
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
P1
P2
P3
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Creatidy/scarcity-router!161
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/92-zcode-stage2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes the implementation of #92 when merged (issue stays open until human review completes; agents never merge). Decision record D-063 (amended 2026-09-29). Status:
READY_FOR_OWNER_MERGE— integrated head green, real ZCode router-path acceptance passing on the exact head.Synchronization with current
develop(2026-09-29, late)developadvanced substantially (D-062 protocol-v3 continuation machinery, reasoning-output semantics, docs — PRs #159/#160/#163), so this PR was synchronized by merging canonicaldevelopinto the branch (normal merge commit; the reviewed task commits are untouched, no rebase):b795ec63ea5319c15d62a8b15a8ab3f7f3499bf3develop8d6d59e0a4e1d60759dd829b81474140212bcc91a89975f024b0eba4e9c901b3db21b06f8c4aafa9Treated as a semantic integration pass: one textual conflict (
docs/decisions.md— resolved keeping both records, D-061 → D-062 → D-063) and one semantic fix the auto-merge could not express — develop'sLocalAdapter.invokeprotocol gained the optional D-062tool_bridgechannel thatrun_allowlistednow always passes, soZCodeLocalAdapter.invokeaccepts it and deliberately never engages it (the plan lane carries no client-tool round trip on any session version; tool-bearing requests are typed rejections before execution). The three remaining overlapping files (execution_sources.py,worker_client.py,worker_endpoint.py) were verified to coexist semantically: codextool_calls: True(D-062) vs ZCODEtool_calls: Falsevia the per-kind maps; the v3 continuation machinery alongside the--zcode-source/--zcode-workspaceflags and theAUTH_UNPROBEABLE_KINDSexemption.Exact-head adversarial review of
a89975f: APPROVED, 0 MERGE_BLOCKER (focused on integration regressions; all eight integration questions verified with file:line evidence — v1/v2/v3 signature compatibility, every D-063 invariant intact, per-kind isolation, zcode can never enter the continuation state machine, plain-request path behaviorally identical to pre-D-062, resolution quality with an empty combined diff on the auto-merged files, scope = exactly 2 reviewed commits + 1 merge). Two DEFER-level nits confirmed pre-existing atb795ec6, recorded below for owner selection.Live router-path acceptance re-run on the merged head: PASS — fresh disposable Git repo, complete standalone CLI (
/home/adrian/workspace/zcode/apps/zcode-cli/packages/cli/dist/zcode.cjs, 0.16.9), plainmodel: "plan-managed"request through normal routing → HTTP 200 → real sentinel edit (sample.txt== sentinel;git statusonlyM sample.txt); captured argv--prompt <task> --cwd <repo> --mode edit --output-format stream-json --no-browserwith subprocess cwd = the repo; auditcompletedagainstzai-plan-1:plan-managed; credential scan clean. Cancellation covered by the deterministic composed acceptance at this head.Gates on the exact head
a89975f:make check— 2424 tests OK;uv run basedpyright0 errors / 0 warnings / 0 notes;git diff --checkclean; focused suites 315 OK (including the composed ZCode router-path e2e through the new v3 worker path).Original implementation summary (
b0bf858+b795ec6, unchanged in substance)One worker-side ZCode execution source behind the EXISTING architecture — no second runtime, no new execution channel:
zcode --prompt <text> --cwd <authorized workspace> --mode edit --output-format stream-json --no-browser.--mode editis ALWAYS explicit and is the LEAST-AUTHORITY officially supported mode that permits the coding workflow (first-party evidence:permission/service.tsat the D-061-pinned commit29628c9, identical in the shipped 0.16.9 bundle — edit mode explicitly allows workspace-scoped file edits,mode.edit.fileEdit; every other side-effecting or high/critical-risk tool still requires anaska headless run cannot answer, so the vendor's default broker denies it, fail closed). The headless yolo default is never relied on. The prompt is argv data bounded at 64 KiB encoded; larger inputs are a typed rejection, never a truncation.--zcode-workspace <dir>is a REQUIRED worker flag with--zcode-source— ONE administrator-authorized project workspace, realpath-canonicalized at construction, re-validated fresh before every run, passed as BOTH--cwdand the subprocess cwd. Request content can never supply, alter or select a path; the per-attempt scratch machinery was removed (state/workspace separation is structural).zai/plantrack inmodel-tracks.json(plan_managed: true, minimum-of-scale floor, plan-family continuity 1M in / 128K out) makes the effort-lessplan-managedlane adopt as ONE variant-less resource with ONE effort-less catalog entry (variantplan,reasoning_effortnull,supports_reasoning_modefalse). A plainmodel: "plan-managed"request routes through the NORMAL selector; an effort-bearing request is a typed 400unsupported_reasoning_effort; physical slugs (glm-5.3) classify nowhere onzai— exact-identity untouched for enforceable resources.--version,doctor --json); a healthy CLI reportsunverified— the lane's honest steady state; adoption-from-healthy-unverified and probe-health snapshots are scoped viaAUTH_UNPROBEABLE_KINDS; codex semantics unchanged.zcode login zaistays the owner's only sign-in path (never wrapped).type:"result"line AND a proven exit 0; every other ending is a typed failure or an explicitunknownobservation. Exactly one invocation per call — no retry. stderr is bounded-counted and never read. Usage stays unmapped (no evidenced field names) — unknown stays unknown.zcode_worker_evidence.py); owner-registered lane ceilings 1M/128k (the codex-272k registration-fact precedent).Deferred items (owner selection; none merge-blocking)
build_run_argvdocstring wording still says "--mode build" while the code (correctly) passesedit— comment-only._WORKSPACE_MODE_OK_MASKdead constant left by the scratch removal.observe_inventoryprobes run with the ambient cwd (invoke-path probes run inside the workspace) — behavior differs only if the worker's cwd is deleted.--zcode-workspaceworker-client glue lacks a directbuild_registryunit test intests/test_worker_client.py(covered indirectly).derived_catalog_entriesdocstring vs continuity tokens wording.authenticated— zcode lane registrations persist until config removal (safe; routing is health-gated).Per repository governance: PR left open for human review; workers never merge.
Independent adversarial review — exact head
b0bf858— APPROVED (no MERGE_BLOCKER)Reviewer: independent agent instance (GLM-5.3-Flash via the Start Plan account — substitution disclosed: the task's preferred GPT-5.6 Sol High is reachable only through the
new-providerpinned endpoint that D-061's evidence records as currently failing TLS validation, and per governance no unavailable preferred reviewer blocks the deterministic record). The implementation agent did not review its own work; the reviewer verified the exact head SHA and ran the focused suites itself (171 tests OK + the HTTP adapter suite).Coverage: architecture (reuse/parallel-system/boundary/kind-consistency), security (shell injection, credential and ZCode-config access, workspace authority incl. symlink/pre-planted attacks, permission mode, multi-user surface), lifecycle (cancellation ×3 phases, timeouts, ambiguity honesty, leak probes — 40 real subprocess runs with fd/thread counting), protocol (evidenced-surface parsing, budget bounds, terminal contract), semantics (identity/auth/evidence honesty), scope (diff hygiene, minimal flags, docs-vs-code cross-check), UX (mandatory dimension:
UX impact: minor, non-blocking).Findings: 8 × DEFER, 0 × MERGE_BLOCKER (recorded verbatim in the review; headline items):
--versionparse unanchored (firstx.y.zwins); codex precedent anchors on an evidenced prefix.stream=Trueis the one dimension without a direct-call backstop (unreachable via composition —streaming: Falsegates selection; refuse-not-drop symmetry nit).finallycloses neither pipe explicitly (stdout is closed by the shared reader; measured leak-free over 40 runs)._SURFACE_CAPABILITIES_BY_KIND.get(kind, CODEX_…)defaults a future unmapped kind to codex facts instead of failing closed.observe_inventory()in foursetUpbodies.No remediation round was triggered (only a MERGE_BLOCKER can trigger the single remediation per the bounded review lifecycle); the reviewed head remains the PR head
b0bf858and the DEFERs stay recorded for follow-up selection by the owner.M07 Stage 2: official ZCode CLI execution source behind the D-053 source architecture (D-063, #92)to M07 Stage 2: official ZCode CLI execution source — authorized workspace, evidenced edit mode, routable plan lane (D-063, #92)Independent exact-head review —
b795ec6— APPROVED (0 MERGE_BLOCKER, 6 DEFER + 2 INFO)Reviewer: independent agent instance (GLM-5.3-Flash via the Start Plan account — substitution disclosed: the preferred GPT-5.6 Sol High remains reachable only through the
new-providerpinned endpoint that currently fails the CLI's TLS validation, and per governance no unavailable preferred reviewer blocks the deterministic record). The implementation agent did not review its own work; the reviewer verified the exact SHA, ran the focused suites AND the full repo gate itself, and independently re-fetched the officialpermission/service.tsat the pinned commit to re-verify the mode-evidence chain.All eight review questions answered YES with file:line evidence (authorized workspace on the real request path;
editgenuinely the least-authority editing-capable headless mode with the deny broker intact; normal routing to the lane with no physical-model claim and triple rejection of effort-bearing requests; codex exact-identity untouched; no request-controlled route to filesystem authority — the dispatch protocol structurally has no path field; no credential exposure; cancellation/timeout/bounds/no-retry intact after the scratch removal through every path; the composed e2e is the real router path and non-vacuous —wait_for_lanecan only pass because the snapshot-drop exemption works).Findings (await owner selection; no remediation round triggered — only a MERGE_BLOCKER can):
build_run_argvdocstring still says "--mode build" while the code passesedit(doc-vs-code wording on the mode claim)._WORKSPACE_MODE_OK_MASKleft behind by the scratch removal.observe_inventoryprobes run with the ambient cwd while invoke-path probes run inside the workspace (contradicts the "no ambient cwd" wording; behavior differs only if the worker's cwd is deleted).--zcode-workspaceworker-client glue lacks a directbuild_registryunit test intests/test_worker_client.py.b0bf858) —derived_catalog_entriesdocstring says hard properties "stay UNKNOWN", contradicted by both floor-entry implementations' continuity tokens.authenticatedmeans a zcode lane registration persists until config removal (safe: routing is gated by snapshot health + the drop rule); comment or gate onhealthyoptionally.track.plan_managedgates adoption;AUTH_UNPROBEABLE_KINDSgates the snapshot-drop exemption); optional wording fix.UX: no material regression — the required flag fails with an actionable, flag-naming config error; an unsigned-in lane yields a typed failure rather than a hang and its honest sign-in state stays visible.
No remediation round was triggered; the reviewed head remains the PR head
b795ec6.Final live acceptance: PASS — PR #161 is READY_FOR_OWNER_MERGE
The M07 Stage 2 final acceptance ran on the unchanged reviewed head
b795ec63ea5319c15d62a8b15a8ab3f7f3499bf3through the normal Scarcity Router path (plainmodel: "plan-managed"request → normal selector → thezai-plan-1:plan-managedplan-managed lane → worker execution → official ZCode CLI → authorized disposable Git repository), and produced a real, mechanically verified file edit:finish_reason: "stop"), the CLI's own answer confirming the edit;sample.txtreads exactlyZCODE_ROUTER_LIVE_ACCEPTANCE_OK(wasbefore);git diff --stat:sample.txt | 2 +-only;git status --short:M sample.txtonly; no new or changed paths outside the workspace (rglob before/after comparison);result_status: "completed",executed_target = {"resource_id": "zai-plan-1:plan-managed", "provider": "zai", "model": "plan-managed", "variant": "plan"}— the provenance IS the plan-managed lane;--prompt <task> --cwd <disposable repo> --mode edit --output-format stream-json --no-browser, with the subprocess cwd equal to the authorized repo (wrapper-captured);/home/adrian/workspace/zcode/apps/zcode-cli/packages/cli/dist/zcode.cjs(the host bundle was not used); the official Z.ai Coding Plan path completed the run (the removednew-providerendpoint could not have);b795ec6, PR worktree clean;timed_outaudit + child reaped), not repeated live per the economy rule.Full evidence table on issue #92. All acceptance criteria of the remediation task are now met, including the previously-blocked live condition.
Task conclusion:
READY_FOR_OWNER_MERGE. PR #161 stays open for the manual human merge; agents never merge.Synchronized with current
develop— merged head green, live acceptance re-PASSED — READY_FOR_OWNER_MERGEPR #161 no longer points at the stale reviewed head. History is preserved exactly as directed: the two reviewed task commits (
b0bf858,b795ec6) are untouched, and current canonicaldevelopwas merged in (normal merge commit, no rebase, no rewrite).b795ec63ea5319c15d62a8b15a8ab3f7f3499bf3develop8d6d59e0a4e1d60759dd829b81474140212bcc91a89975f024b0eba4e9c901b3db21b06f8c4aafa9Conflicts and resolutions (one textual, one semantic):
docs/decisions.md(textual): both branches appended at the tail — resolved by keeping BOTH records in numbering order (D-061 → D-062 from develop → the amended D-063); no content lost on either side.execution_sources.py,worker_client.py,worker_endpoint.py: auto-merged textually, then verified semantically — develop's codextool_calls: True(D-062 evidence) coexists with the ZCODE surface facts (tool_callsUNSUPPORTED for the lane) via the per-kind maps; the v3 continuation machinery coexists with the--zcode-source/--zcode-workspaceflags and theAUTH_UNPROBEABLE_KINDSsnapshot-drop exemption.LocalAdapter.invokeprotocol gained the optional D-062tool_bridgechannel andrun_allowlistednow always passes it — without a signature fix every zcode dispatch would have raised TypeError.ZCodeLocalAdapter.invoke(merged head) accepts the channel and deliberately never engages it: the plan lane carries no client-tool round trip on any session version (ZCODE cells marktool_callsUNSUPPORTED; tool-bearing requests are typed rejections before execution).Focused suites (315): ZCode adapter, execution sources, the composed ZCode router-path e2e through the new v3 worker path, worker endpoint/protocol/bridge/client, routing — all OK. Full gate:
make check2424 tests OK;uv run basedpyright0 errors / 0 warnings / 0 notes;git diff --checkclean. The #143-family flake did not fire.Live router-path acceptance re-run on the merged head: PASS. Fresh disposable Git repo; complete standalone CLI (
/home/adrian/workspace/zcode/apps/zcode-cli/packages/cli/dist/zcode.cjs, 0.16.9; the host bundle NOT used); plainmodel: "plan-managed"request through normal routing → HTTP 200; captured invocation argv--prompt <task> --cwd <repo> --mode edit --output-format stream-json --no-browserwith the subprocess cwd = the authorized repo;sample.txtreads exactlyZCODE_MERGE_ACCEPTANCE_OK;git diff --stat=sample.txt | 2 +-only,git status --short=M sample.txtonly; auditcompletedwithexecuted_target = {"resource_id": "zai-plan-1:plan-managed", "provider": "zai", "model": "plan-managed", "variant": "plan"}; credential scan clean. Cancellation not repeated live (the deterministic composed acceptance at this head covers the same path).Exact-head adversarial review of
a89975f: APPROVED — 0 MERGE_BLOCKER. The reviewer verified all eight integration questions with file:line evidence (v1/v2/v3 signature compatibility; every D-063 invariant intact on the merged head; per-kind capability isolation; zcode can never enter the continuation state machine; the snapshot-drop exemption survived the endpoint restructure; the plain-request path is behaviorally the pre-D-062 path; resolution quality incl. an empty combined diff on the three auto-merged files; scope = exactly 2 reviewed commits + 1 merge). Two DEFER-level nits were confirmed PRE-EXISTING atb795ec6(thebuild_run_argvdocstring wording; the unreachable codex-default in the kind map) — already recorded on the PR for owner selection, not merge regressions.Status:
READY_FOR_OWNER_MERGE— integrated head green, live router-path acceptance passing. PR #161 stays open; owner merge is manual.