Skip to content

feat(windows): add native maka.cu/2 executor - #8

Open
sunheyi6 wants to merge 2 commits into
maka-agent:maka/basefrom
sunheyi6:codex/windows-native-maka-cu2
Open

feat(windows): add native maka.cu/2 executor#8
sunheyi6 wants to merge 2 commits into
maka-agent:maka/basefrom
sunheyi6:codex/windows-native-maka-cu2

Conversation

@sunheyi6

@sunheyi6 sunheyi6 commented Sep 2, 2026

Copy link
Copy Markdown

Summary

  • Enforce the shared maka.cu/2 snapshot lifecycle: TTL, one-use spending, supersede/evict states, session cleanup, and distinct refusal codes.
  • Track session-owned images, delete them on every terminal snapshot state, expire unattached captures, enforce the 256 MiB image budget, and refuse unsafe writes.
  • Keep serialized observation responses within the declared 1 MiB limit by applying deterministic tree/text reduction before the fixed error fallback.
  • Remove the unused compatibility-input authorization subsystem and add focused lifecycle, image-budget, and oversized-observation tests.
  • Add Windows/Linux CI gates for format, clippy, tests, release build, and Windows artifact digest recording. distributionReady remains false.

Validation

  • cargo fmt -- --check
  • cargo test --locked --all-targets — 10 passed
  • cargo clippy --locked --all-targets -- -D warnings
  • cargo build --locked --release

Clean-machine validation, Authenticode signing, and packaged conversation E2E are intentionally not claimed by this PR; they must qualify the exact immutable artifact in a later release pipeline.

中文翻译

摘要

  • 强制执行共享的 maka.cu/2 snapshot 生命周期:TTL、一次性消费、替换/驱逐状态、session 清理和区分明确的拒绝码。
  • 跟踪 session 所有的图片,在 snapshot 进入任一终止状态时删除图片;清理过期的未关联截图,执行 256 MiB 图片预算,并拒绝不安全的写入。
  • 通过确定性的树/文本降级,在固定错误兜底前将序列化 observation 响应控制在声明的 1 MiB 限制内。
  • 删除未使用的兼容输入授权子系统,并增加生命周期、图片预算和超大 observation 的专项测试。
  • 增加 Windows/Linux CI 门禁,覆盖格式、clippy、测试、release build 和 Windows artifact digest 记录。distributionReady 保持 false。

验证

  • cargo fmt -- --check
  • cargo test --locked --all-targets —— 10 个通过
  • cargo clippy --locked --all-targets -- -D warnings
  • cargo build --locked --release

本 PR 不声称已经完成 clean-machine 验证、Authenticode 签名或 packaged conversation E2E;这些工作必须在后续发布流水线中针对同一个 immutable artifact 完成资格验证。

@hqhq1025 hqhq1025 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review of d722afda8517cd3f7557b895b2603cb6087c4278

This is the correct architectural direction: a Windows direct-COM executor behind the existing maka.cu/2 protocol, with no second model-facing schema or supervisor. The current revision is not merge-ready yet.

Blocking findings:

  1. The advertised snapshot/image lifecycle is not implemented. The handshake promises a 120-second snapshot TTL and a 256 MiB image-directory budget, but snapshots have no timestamp, no expiry/eviction path exists, and image files are not tracked or deleted when a snapshot is spent, superseded, expired, evicted, or released by session.end. After 64 unspent observations the executor permanently returns snapshot_registry_full, and image files accumulate until the host restarts. This violates the shared protocol's resource and stale-image guarantees.
  2. limits.maxResponseBytes is advertised as 6 MiB while the shared maka.cu/2 contract fixes this limit at 1 MiB. The implementation also replaces an oversized response with an RPC error instead of reducing/truncating the observation to the declared bound. Please use the shared 1 MiB limit and add conformance coverage for bounded observations.
  3. The stated local validation is not reproducible on this revision: cargo test --all-targets passes 7 tests, not 8, and cargo clippy --all-targets -- -D warnings fails on the current checkout. This repository currently has no GitHub checks for the PR. Please make fmt/clippy/test green on both the normal Windows build and the non-Windows CI analysis target, then add the checks as an actual merge gate.

The implementation is otherwise aligned with the agreed boundary: semantic element actions use UIA patterns, keyboard dispatch is observation/focus-bound, and dispatch.point is fail-closed. I recommend fixing the lifecycle contract first, then rerunning the real Windows matrix against the new head.

Production code that can be removed or simplified: the #[cfg(test)] compatibility authorization/input subsystem is historical experiment code and does not exercise the production maka.cu/2 path. Move any useful vectors into protocol tests and delete the inactive production-file implementation.

Test quality: keep lifecycle and real-application tests, but make the authoritative tests run against this repository revision and report the exact head/artifact digest. Current downstream reports alone cannot replace repository CI.

Verdict: not ready to merge. A deeper architectural rewrite is not required; focused lifecycle/resource accounting, protocol-limit conformance, test cleanup, and CI are required.

.extract_if(|_, snapshot| snapshot.session == session)
.count();
Ok(
json!({"ok":true,"session":session,"released":{"snapshots":released,"images":0,"streams":0}}),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

session.end reports zero released images and only removes snapshot records. The shared protocol requires it to delete every image owned by the session and report the real count. Because Snapshot stores no image path and store_capture is untracked, spent/expired/session-ended snapshots leak files. Please add executor-owned image accounting and cleanup for every snapshot lifecycle transition.

},
"limits": {
"snapshotsPerSession": MAX_SNAPSHOTS,
"snapshotTtlMs": 120000,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The executor advertises snapshotTtlMs: 120000, but snapshots contain no creation/expiry time and registry admission only checks len() >= 64. Sixty-four observe-only calls therefore make the process permanently refuse further observations until sessions are explicitly ended. Implement TTL expiry and bounded eviction before advertising this limit.

"snapshotTtlMs": 120000,
"maxElements": MAX_ELEMENTS,
"maxDepth": 64,
"maxTextChars": 500,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The shared maka.cu/2 contract fixes maxResponseBytes at 1 MiB; this executor advertises and enforces 6 MiB. Please align to the shared limit and truncate/reduce observation payloads to fit instead of returning an oversized-response RPC error.

@hqhq1025 hqhq1025 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review of 47972926c8c938f4ccaa6563d8241849d1d161a1

The revision makes substantial progress on the previous findings: it adds explicit live/spent/superseded/expired/evicted states, 120-second cleanup, eight-live-snapshot enforcement, image accounting, the 1 MiB advertised limit, focused lifecycle tests, removal of the compatibility experiment, and a CI workflow. The current revision is still not merge-ready.

Blocking findings:

  1. Snapshot IDs are still deterministic process-local counters (s000...) and contain no 128-bit per-process nonce. A restarted executor will mint the same IDs again, so a stale request from the previous generation can resolve to a fresh snapshot instead of returning snapshot_unknown. This violates the explicit restart-isolation requirement in HOST_PROTOCOL.md section 4.1.
  2. Terminal snapshots retain their full elements maps indefinitely until session.end. The eight-snapshot limit counts only live entries, so a long session can accumulate an unbounded number of spent, superseded, expired, and evicted snapshots, each retaining up to 512 element records. Keep only compact, bounded tombstones for terminal error classification and release the heavy snapshot payload immediately.
  3. Oversized responses are made to fit by recursively truncating every JSON string and then dropping elements/tree nodes. The protocol requires retrying observation with a reduced maxElements and, if it still does not fit, returning response_too_large with {bytes, limit}; it explicitly says fields must not be dropped to fit. The current transformation can also change element text after its digest was computed and does not mark each changed field in element.truncated, so the returned snapshot is not a faithful dispatch authority.
  4. The new merge gate is not green on this exact head. I reran cargo clippy --locked --all-targets --manifest-path apps/OpenComputerUseWindows/native/Cargo.toml -- -D warnings on the Linux analysis target and it fails with 16 errors (unused Once, Windows-only constants and fields, readback symbols, and the non-Windows worker stub). GitHub currently reports no checks for this fork head, while the README and execution plan claim clippy passed. cargo fmt --check, cargo test (10/10), and the release build do pass locally.

The previous lifecycle/image-leak and 6 MiB declaration findings are directionally addressed. The architecture remains appropriate: one shared maka.cu/2 contract and a native Windows executor, with no new model-facing schema. No deeper product-side rewrite is required, but the executor still needs protocol-conformant response generation, bounded tombstones, nonce-based IDs, and a genuinely green Windows/Linux gate.

Recommended next revision:

  • Add one random 128-bit generation nonce at process startup and include it in every snapshot ID; add a two-generation collision test.
  • Split live snapshot payloads from compact terminal tombstones and bound/prune both explicitly.
  • Enforce the response budget while constructing/retrying the observation, preserving the protocol's truncation semantics and exact digests.
  • Fix cfg scoping/dead-code warnings, make the fork workflow run on the PR head, and attach the exact Windows artifact digest.

Verdict: not ready to merge. After these focused fixes and a green exact-head Windows/Linux run, the next review can move to real Windows application and packaged Maka qualification.

.next
.fetch_add((MAX_ELEMENTS as u64) + 1, Ordering::Relaxed)
.wrapping_add(1);
let snapshot_id = format!("s{:016x}", token_seed);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P1] Add a per-process generation nonce to snapshot IDs. This counter restarts from zero, so a new executor generation can mint the same s000... identifier as the previous process. A delayed stale request can then bind to a fresh snapshot instead of failing snapshot_unknown, contrary to HOST_PROTOCOL.md section 4.1. Generate one random 128-bit nonce at startup, prefix every snapshot ID with it, and test two independently initialized registries/generations for non-collision.


fn reap_expired(&mut self, now: Instant) {
let mut retired_images = Vec::new();
for snapshot in self.snapshots.values_mut() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P1] Terminal snapshots still retain the complete elements map. This loop changes only the state and image path; spent, superseded, expired, and evicted entries are excluded from the eight-live-snapshot limit but remain in registry.snapshots until session.end. A long conversation can therefore retain an unbounded number of up-to-512-element snapshots. Move terminal classification into compact bounded tombstones and drop the heavy element payload as soon as a snapshot leaves Live.

}

fn shrink_oversized_observation(response: &mut Value) {
truncate_json_strings(response, 256);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P1] Do not mutate arbitrary response strings to satisfy the byte limit. HOST_PROTOCOL.md section 7.5 requires reducing maxElements and rebuilding/retrying the observation, then returning response_too_large with byte/limit detail if it still cannot fit; it explicitly forbids dropping fields to fit. This pass can truncate title/value text after element digests were computed, without updating per-field element.truncated, leaving the wire snapshot inconsistent with its dispatch authority.

Comment thread .github/workflows/ci.yml
run: cargo fmt --check

- name: Run clippy
run: cargo clippy --locked --all-targets -- -D warnings

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P1] This exact command is not green on the Ubuntu analysis target at 4797292. It fails with 16 -D warnings errors from Windows-only imports/constants/fields and non-Windows stubs. GitHub also currently reports zero check runs for this fork head, so the workflow has not established a merge gate yet. Please fix the cfg boundaries and show a successful exact-head Windows and Ubuntu run before describing clippy/CI as passed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants