diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ff125e613..04d3f7b48 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -72,6 +72,11 @@ jobs: # with faulthandler on for the whole process: a crash after pytest has # finished (interpreter shutdown) otherwise leaves nothing but # "Segmentation fault" in the log. -v so a crash mid-suite names its test. + # dev_requirements.txt lists je_auto_control_dev, a PyPI snapshot that lacks + # subpackages such as utils/agent_runtime. Installed here it overwrote the + # image's complete je_auto_control (built from this checkout), and helpers + # started with `python -I` skip the mounted checkout and import that copy, + # so they died with ModuleNotFoundError. Install everything else instead. - name: Run headless tests under Xvfb run: | docker run --rm \ @@ -79,7 +84,8 @@ jobs: -v "$PWD:/work" -w /work \ --entrypoint /bin/sh \ autocontrol:ci -c " - pip install --no-cache-dir -r dev_requirements.txt && + grep -v '^je_auto_control_dev' dev_requirements.txt > /tmp/dev_requirements.txt && + pip install --no-cache-dir -r /tmp/dev_requirements.txt && apt-get update && apt-get install -y --no-install-recommends gdb && xvfb-run -a -s '-screen 0 1280x800x24' \ python scripts/ci_native_diagnostics.py --artifact-dir /tmp/autocontrol-native --native -- \ diff --git a/CHANGELOG.md b/CHANGELOG.md index fcfc3da99..1e483531e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,50 @@ ## [Unreleased] +- Host-reviewed service profiles now bind a fixed worker to pinned configuration, + an ASCII service key and bounded START/STOP permissions. Registration, reload + and probe remain passive; native service acceptance is still pending. + +- Internal service helpers now pin bootstrap and evidence to the same retained + owner, preserve typed query failures and refuse desktop input during requests + and retirement. ASCII service-name aliases share ownership across configurations + under the same lock root. No production host configuration is changed. + +- Managed task criteria accept `service_state` for a host-selected in-process + service adapter. START/running and STOP/stopped require confirmed acceptance + and fresh SCM readback from the same retained owner. This does not expose + global service commands or register a native service profile. Existing semantic + revision requirements remain unchanged. + +- External tasks may now declare an empty tool scope when they have no planned + actions. Completion criteria remain required; empty plans do not prove completion. + The new host-managed `uia_fixture` profile uses this zero-action contract, a + fixed isolated worker and pinned configuration/image bytes. Both IPC endpoints + reject commands. Registration/probe remain inert; native UI acceptance is pending. + +- The build-only UI fixture now wraps its startup result in an exact `id`/`result` + envelope, correlated by launch challenge. Rebuild earlier UI artifacts for the + new receive-only internal launcher; the memory fixture protocol is unchanged. + +- The native fixture builder adds `--kind uia` for a separate owned hidden-window + artifact and schema-2 static manifest. The default memory artifact is unchanged. + This builds only; native deployment trust and acceptance remain pending. + +- Managed fixture observations now return a version-three multi-source report instead of a flat + memory snapshot. Read `sources.process_memory.snapshot` only after requiring a complete report; + partial reads and source conflicts remain diagnostic data. Both host and worker require the + report capability, and commands/completion require agreement with the owned IPC snapshot. + Report constructors and parsers now require explicit host field scopes. Bootstrap requires + matching semantic_fields and report version 3; version-one and version-two reports/helpers are rejected. + Tagged partial sources retain valid fields separately from fixed per-field failures. + Fields missing from all sources remain partial. Native acceptance remains pending. + +- Added an internal scoped UIA reader and read-only managed observation adapter. Host-selected + fields stay beneath the original HWND/PID and pinned root runtime ID, with bounded traversal, + ancestry checks and password protection. Partial fields and complete best-effort captures + grant no action or completion authority. Injected COM and hidden-helper tests cover this path; + native deployment trust and all desktop acceptance remain pending. + - Image search and OCR (`find_image` and everything on `cv2_utils.template_detection`, `visual_match`, `color_match`, `edge_match`, `rotated_match`, self-healing frame locators, device-frame matching, `find_text_matches`, `read_text_in_region` and the commands built on them): inside a stoppable run or a cancellation scope diff --git a/Progress.md b/Progress.md index 4542f235a..573182315 100644 --- a/Progress.md +++ b/Progress.md @@ -18,12 +18,30 @@ ## 輸入、視窗與擷取修正:還沒在真的桌面與 Jeffrey_RPA 上驗過 +### 自有 UI 觀察 fixture 的限定範圍讀取 + +`TODO` — `test/fixtures/native_memory/uia_fixture.c` 的原生執行仍暫緩。 +尚須核實固定 UIA worker 的可信交付、Python/COM/DLL 相依與原生啟動環境。 +部署 pin、零動作 profile 與受管 worker 已有注入/隱藏 Python helper 證據,不能據此宣告原生信任成立。 +指定 HWND 的 root/祖先核實、逐欄報告與受管唯讀 adapter 目前只有注入呼叫驗證; +隱藏 Python helper 的阻塞退休測試不能證明原生 COM、HWND 與 provider 行為。 +解除暫緩後才驗證 hidden controls 的 UIA 暴露與 AutomationId、空值/停用/密碼/重複 selector、 +EOF 清理及前景視窗/滑鼠不受影響。建置與靜態匯入檢查不算上述驗收。 + ### 行程記憶體自有 fixture 原生驗收 `TODO` — 原生執行仍暫緩。須先完成 Windows provider 的可信應用身分核對、自有 fixture 與受管權限整合, 再驗證 ASLR、32/64 位配置、跨區段/guard/不可讀頁、程序退出、PID 重用、權限拒絕、 取消及 handle 回收。以 fixture 的已知狀態比對語意結果,獨立觀測前景、焦點、滑鼠與輸入事件。 目前 injected-provider 測試不算原生通過;設計見 [記憶體觀察契約](docs/process_memory_contract.md)。 +已有 `test/fixtures/native_memory/acceptance.py` 的靜態預檢與明確選用的 smoke 執行路徑, +但原生執行尚未啟用;頁面故障、權限、PID 重用、背景不干擾及長時間資源驗收仍待完成。 +原生 fixture 已有固定 split/guard/noaccess/decommitted 頁面配置的建置前置能力; +頁面 runner 已接上同一 handle 的 payload 邊界查詢、前半段實際讀回與封閉頁面屬性證據, +並拒絕其他來源的相同錯誤;目前僅有注入測試,原生頁面配置與完整故障矩陣仍未驗收。 +解除暫緩前,`agent_runtime/native_channel.py` 的 `OwnedChannel` 要改成以 `CREATE_SUSPENDED` 啟動、 +指派 Job 後再恢復執行:目前 Job 在 `Popen` 之後才指派,子行程在那之前已開始執行, +可在加入 Job 前產生不受 kill-on-close 約束的子行程(pinned 映像位置與最小環境已於 U-20261118-36 完成)。 ### 桌面行為驗收 @@ -574,7 +592,7 @@ F 還缺: ## 下一步擴充:以記憶體觀察支援 UI、作業系統與應用程式背景操控 -`TODO / 規劃` — 2026-11-01 使用者要求。此節只制定擴充順序,尚未實作或完成驗收; +`WIP` — 2026-11-01 使用者要求。已有內部 reader、fixture 解碼與語意 runtime 接點,完整交付及驗收尚未完成; 不解除下列既有原生/真機/24 小時驗收暫緩,也不啟動服務、改動正式環境或讀取現有應用程式記憶體。 ### 目標與可交付範圍 @@ -595,7 +613,7 @@ UIA 僅作必要唯讀觀測,不以 Invoke、SetValue、選單或焦點切換 ### 現有架構與擴充位置 -下表的程式路徑均相對於 `je_auto_control/`;新模組名稱為提案,尚不存在。 +下表的程式路徑均相對於 `je_auto_control/`;各項實作狀態以後方 M0–M6 進度為準。 | 責任 | 現況/預計接點 | 擴充內容 | | --- | --- | --- | @@ -627,6 +645,13 @@ proof = await target.verify(receipt, CompletionQuery("export_file_matches")) 另外兩個使用情境:OS adapter 讀取指定服務狀態後執行該服務支援的管理操作,並重新查詢; browser adapter 從受管頁面取得欄位、透過 DOM 提交,再驗證新回應或產物。 兩者都不必知道記憶體位址,也不能只靠命令回傳成功判定完成。 +服務已有內部 SCM query-only reader、共用 session 的啟停 controller,以及程序內受管觀察與 +service_state 完成判定、自有 helper IPC 與固定服務 profile;正式可信部署及 Unicode 服務名稱的 +鎖識別仍待實作。同一使用者/鎖目錄下的 ASCII 名稱已可跨 target/設定/資料庫協調, +不同 Windows 帳號與外部 SCM client 不在此鎖範圍內。 +不能視為 os.service 已支援。管理操作使用同一 retained handle +重新查詢,回條只表示接受;未知效果保留且禁止自動重送。服務相依項的影響範圍、背景不干擾及 +原生相容性仍未驗收,正式服務未操作。 - `TargetIdentity`:主機/登入 session、PID、程序建立時間、執行檔身分與架構;視窗/文件/瀏覽器 context 另帶各自身分。PID 或 HWND 相同不能單獨證明還是同一目標。 @@ -655,6 +680,65 @@ resolver 已能透過保留 handle 取得主映像基址與大小並做有預算 fixture 的原生身分核對(標頭挑戰已有,U-20261115-18,只在本行程內驗過)與頁面故障注入、runtime grant/helper 生命週期及公開入口;M2 也仍缺實際應用版本 adapter。原生驗收固定列於本檔上方。 +M2 的自有 fixture schema-one adapter 已有嚴格版本/布局驗證、不可變 challenge binding、 +標準補零狀態解碼及共用 72-byte 讀取上限;僅驗證 injected provider,並未完成應用 attestation 或原生驗收。 +成功的序號觀察保留 `revision`,供後續 runtime grounding 區分相同欄位值但已更新的狀態; +best-effort 觀察沒有 revision,也不承諾後續操作具原子性。原生語意閉環驗收仍待完成。 +多來源報告與 runtime/helper 契約已有合成來源驗證,可保留部分缺失及型別化衝突, +且拒絕以不完整資料執行或確認完成。自有 fixture 已接合 memory+IPC 擷取及提交前雙來源核對, +目前以注入原生呼叫、真實 reader 邏輯與隱藏 Python helper 驗證,仍非原生驗收; +UIA 的實際部署信任與原生驗收仍待完成;限定 root/祖先、逐欄失敗、受保護欄位及唯一 selector +目前只有注入測試,helper 阻塞退休只有隱藏 Python 程序證據,仍須核實原生 COM 行為。 +DOM 的來源身分與逐欄報告正規化仍待接合。UIA best-effort 不提供原子 revision。 + +M3 已加入內部受信任 `SemanticTarget` runtime 接點:封閉語意快照驗證、排除擷取時間的狀態比較、 +傳遞原始快照及 journal action ID 的提交介面、具 atomic/non_atomic 標記的回條,以及未知效果的 +uncertain 紀錄。現有 target 保留完整觀察比對;task/觀察 JSON 不能自行啟用語意模式。 +已有 owned helper 語意協定,主機與 worker 雙端拒絕桌面輸入,cleanup/EOF 也保留輸入及命令守衛; +實際背景 IPC fixture 已驗證有界操作、回覆遺失、命令進入後取消及 helper 回收。 +此 fixture 只操作自有 counter,不是跨行程記憶體或桌面原生驗收。 +已有 `semantic` 完成條件,以新讀回核對 journal 中實際 target 的身分、版本、來源及 revision, +再按型別比較期望欄位。每次擷取區間須在當次主機單調時鐘讀取請求內;操作前快取不能證明完成。 +IPC fixture 已驗證成功回條但未生效及 helper 重啟;程序內 target 測試驗證快取回放拒絕。 +未知效果仍須審閱,未自動確認。 +自有 memory fixture 已有 launch-bound compare_set 與有界、不淘汰的重送回條紀錄; +只有序列管線命令內的比較/提交原子性。FixtureCommands 已將內部命令接到 compare_set, +嚴格比對回條身分、版本與欄位;以自有緩衝區及真實 reader 邏輯驗證 runtime 閉環, +OwnedFixtureControl 已接上有界背景 RPC、取消與回收;OwnedChannelLauncher 已將映像檔核對 +接到同一受管 channel 的啟動 handle,並拒絕 bootstrap PID/位元寬度不符(只有注入測試)。 +可信來源交付、載入映像綁定的原生相容性與 attestation 驗收尚未完成。 +另有 `test/fixtures/native_memory/` 的 x64 靜態 CRT fixture 原始碼與僅建置工具; +已編譯、靜態盤點直接 OS DLL 匯入並記錄來源/產物雜湊,未執行該原生產物。 +原生程式行為、DLL 解析信任、載入位元組核對與故障驗收仍未驗證。 +已有從固定雜湊 PE32+ x64 產物推導完整可執行區段的 planner 與 reader guard; +拒絕可寫入/重定位程式碼,核對原啟動 pin,且不擴大 probe 預算。測試僅使用合成映像及靜態產物; +區段 padding 的原生相容性、實際頁面保護與 DLL 信任仍未驗證,不能當成完整 runtime attestation。 +內部 OwnedFixtureTarget 已組裝啟動、映像核對、fixture 命令與受管語意讀取; +擁有者在啟動前保留,失敗回收可重試,終止後不得發布晚到的 target。 +`ready()` 已能在受管 scope 內先綁定固定 task/owner 再延遲取得資源, +並防止另一個 session 在啟動發布與內部 owner 綁定之間接管。隱藏 Python helper +已串起真實 reader 邏輯、既有語意 IPC、完成判定、失敗代碼與回收;原生呼叫及 buffer 仍為注入資料。 +已有專用 fixture profile,沿用既有主機管理 API/GUI JSON 編輯器、不可變 digest 及即時停用。 +只允許固定 fixture 命令,主機核對 bootstrap,worker 在修改 scope 前核對部署及 task pin。 +目前僅有注入測試;沒有註冊實際主機部署,原生信任與驗收仍待完成。 +自訂語意 worker 已在請求、讀取 checkpoint、命令守衛與發布前重新核對原帳號/角色/store 來源, +並拒絕回呼替換 operation 或 worker 綁定;目前以真實暫存帳號檔及注入 buffer 驗證。 +取消與即時 profile 停用仍由主機 RPC 輪詢及 helper 退場處理,不能把 checkpoint 當成原子撤權或 syscall 中斷。 +語意 helper 已使用既有非顯示路由,Linux 有主機 binding 時只走精確 argv 的 owner service, +政策缺失或服務失敗不得退回本機。此項僅有注入路由測試,尚未證明 Linux 原生隔離。 +套件已有私有 `fixture_worker` 入口,使用主機提供的固定設定及獨立 config SHA; +先核對封閉 schema、映像 pin 與 PE 範圍,再交由受管 readiness 啟動。此路徑僅以靜態/注入測試驗證。 +Python/helper 來源及 DLL 的可信交付、服務獨立身分/空環境下的套件與帳號檔存取, +以及子 fixture 的 nested grant 仍待接合;Windows fixture 入口不支援 Linux 原生讀取。 +原生 smoke 工具已有初始讀值、操作回條、新讀回、runtime 完成及回收的分項報告; +目前只跑過靜態產物預檢與注入測試,不代表原生驗收或完整故障矩陣通過。 +Windows venv 啟動器可能另開解譯器,不能直接把 channel PID 當成 fixture 出生身分。 +內部 MemorySemanticTarget 已組合固定 reader binding、受管 scope 與背景命令 owner, +並以 injected provider 驗證 runtime 讀取、操作與獨立完成判定;cleanup 終止使用並保留失敗 handle 重試。 +fixture 的受管 profile/helper 及有時限的靜態診斷已接合;可信交付及真實原生閉環仍待完成。 +不提供任意 PID/位址記憶體入口; +記憶體失敗原因已透過封閉錯誤封包跨 helper 保留型別;未知原因與混合封包拒絕且不回顯內容。 + 1. **M0:能力盤點與範圍契約。**(已完成:profile/路由規則 U-20261116-12;維護者 2026-11-17 決定第一個目標只用自有 fixture,真實應用待 M1 原生驗收跑通後再選,U-20261117-01)先列 Windows 的 UI/OS/應用操作矩陣,每項記錄 讀取來源、執行介面、權限、是否全背景、支援版本、驗證方式與不支援原因。 第一個目標採自有 fixture 程序,之後選一個提供正式背景介面的應用;不能先承諾任意軟體。 diff --git a/README.md b/README.md index ba4e7f7c3..044c3924f 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,8 @@ Wayland NORMAL input runs libei and portal calls in an owned helper process. Tim Managed agent tasks and cross-host transfers include experimental features. See the implementation notes and project progress before relying on them in production. +Host-selected semantic targets support a `semantic` completion condition that compares fresh state with the recorded target identity and expected fields. It does not grant memory access or enable a native target. See [semantic completion](docs/process_memory_contract.md#semantic-completion). + ## Documentation - [Installation, platform support and configuration](docs/guides/en/setup.md) @@ -87,10 +89,55 @@ REST host-data reads now follow the matching MCP authority: jobs, remote session Host read-only mode applies the same restrictions to explicitly supplied registries and later registrations. Both admission and refreshed invocation check mixed arguments. Configured MCP failure screenshots require a writable tool and a refreshed caller with drive authority; readonly calls and viewers never trigger them. This does not promise that every dependency or diagnostic read has no initialization side effects. -Internal Windows process-memory preparation can now measure a selected process image file through retained read-only handles, with bounded hashing and retryable cleanup. This is observed file evidence, not loaded-code or fixture attestation; native acceptance and public memory tools remain unavailable. See [the contract](docs/process_memory_contract.md). +Internal Windows process-memory preparation can now measure a selected process image file through retained read-only handles, with bounded hashing and retryable cleanup. This is observed file evidence, not loaded-code or fixture attestation; native acceptance remains incomplete and arbitrary-address memory tools remain unavailable. See [the contract](docs/process_memory_contract.md). + +A host-managed fixture profile binds a fixed packaged worker to a reviewed config path and digest through the existing target-management API and GUI JSON editor. Registration is inert; bootstrap and configure both verify the deployment binding. The explicit probe checks static artifacts in a bounded background helper and reports `static_artifacts_ready`, `fixture_execution=not_run` and `native_evidence=not_recorded`. Runtime shutdown retains ownership until inspection helpers retire. The fixture is acquired only during managed readiness. Config/image checks do not attest Python source or DLLs. Native execution remains paused; the private delivery format and limits are documented in the same contract. WebRTC peers also retain failed media constructors and children, observe live disable completion, and bind deferred renegotiation to its original peer. Media producer shutdown now reports pending or uncertain cleanup and retains original resources. Audio and recorder failures are never turned into success by unsafe close or flush replay. LAN close supports explicit retry; application caretaker and GUI integration remain pending. See [the retirement contract](docs/media_retirement_contract.md). HostBrowser also rejects late publications and retains unfinished thread/close ownership; dialog integration remains pending. MultiViewerHost can return an owned offer or capture an original-session retirement receipt, so delayed cleanup cannot stop a replacement peer or screen source. GUI adoption remains pending. + +Host-selected semantic adapters can return multi-source reports through the existing observation API. The fixture combines reviewed memory reads with its owned read-only IPC snapshot and rechecks both before commit. Report version 3 fixes the required fields in host code and preserves valid fields separately from per-field failures. Missing sources, conflicts and best-effort captures cannot authorize actions or completion. Versions 1 and 2 are rejected. + +A separate owned UI observation fixture can be built with `test/fixtures/native_memory/build_fixture.py --kind uia`; its static manifest remains schema 2. The internal launcher binds startup to the retained process and window owner. The scoped UIA reader checks that window, process and root identity, limits tree traversal, and protects password fields. Its read-only managed adapter creates COM lazily and preserves partial fields through the shared observation API. + +Injected calls and hidden Python helpers cover scoped reads, reporting and timeout retirement. Native deployment trust, DOM integration and desktop acceptance remain pending. No native UI fixture execution or desktop noninterference is claimed. + +The internal owned UI target retains its launcher and both image leases before +attestation, attempts every owner during cleanup, and retains failed cleanup for +retry. A publication lock prevents late source installation after shutdown. The +native factory only constructs owners; native deployment trust +and native acceptance remain pending. + +Host management can register a `uia_fixture` profile with empty `allowed_tools`, +`roots` and `apps`, and only `config_path`/`config_sha256` settings. It uses a fixed +isolated worker and validates deployment, profile and target pins before acquisition. +Both endpoints refuse commands. External tasks may use an empty tool scope only +without planned actions; completion criteria remain required and an empty plan +cannot prove completion. UI partial/best-effort reports remain diagnostic. +Registration and probe acquire nothing; probe reports `not_supported` and +`native_evidence=not_recorded`. The existing target API, CLI and GUI JSON editor +carry this profile. Injected and hidden-helper tests do not establish native trust. + +Host-selected in-process service adapters can use the closed `service_state` criterion: +`{"kind":"service_state","tool":"AC_service_start","state":"running"}` or STOP/stopped. +It requires the matching confirmed acceptance and a new SCM report from the same +retained owner after acceptance. A passing result reports SCM state, not atomic +completion, health or desktop noninterference. These tool names are adapter-scoped, +not global executor commands. Existing task APIs and the GUI JSON editor carry the +criterion. The host-reviewed `service` profile pins `config_path`, `config_sha256` +and an ASCII `service_key`. Its fixed worker checks the deployment's service and +operation ceiling before accepting task scope. Registration, reload and probe do +not read the deployment or access SCM; native acceptance remains pending. +Every pinned path (each profile's `config_path` and the image a deployment names) must be +a local drive path: UNC shares, `\\.\pipe\` names, `\\?\` device paths and `..` segments are +refused, so registering a profile cannot make the host send its credentials to another machine. +Before a fixture image runs, its lease also refuses a location another account could change: +every directory from the drive root down must be a real directory (no junction or symlink) that +only SYSTEM, Administrators, TrustedInstaller and the running user may rename, delete, re-ACL or +add files to, and the leased file's final path must be the configured one. Deploy fixtures under +a protected directory such as `%LOCALAPPDATA%`; a drive root that grants Authenticated Users Modify +(common on secondary drives) or a shared `%TEMP%` is refused. The fixture starts in its own +directory with a minimal environment: a system-only `PATH` and none of the host's tokens or keys. diff --git a/README/README_zh-CN.md b/README/README_zh-CN.md index 3b4b96679..dd50b0680 100644 --- a/README/README_zh-CN.md +++ b/README/README_zh-CN.md @@ -57,6 +57,8 @@ Wayland NORMAL 输入通过受管理的子进程执行 libei 与 portal 调用 受管理的 Agent 任务与跨主机传输包含实验性功能;采用前请查看实现记录与项目进度中的验收状态。 +主机选定的语义 target 支持 `semantic` 完成条件,用新读回核对已记录的目标身份及期望字段。此条件不授予内存访问权,也不启用原生 target。详见[语义完成验证](../docs/process_memory_contract.md#semantic-completion)。 + ## 文件 - [安装、平台支持与配置](../docs/guides/zh-CN/setup.md) @@ -87,10 +89,45 @@ REST 主机数据读取与对应 MCP 权限一致:调度、远程 session、US 主机只读模式对外部提供的目录及后续注册应用相同限制,接收请求及重新核对身份后的调用都检查混合用途参数。MCP 配置的失败截图需要可写入的工具及重新核对后具输入操作权限的调用者;只读调用与 viewer 不会触发截图。这不表示所有依赖包或诊断读取均无初始化副作用。 -内部 Windows 进程内存准备工作新增映像文件测量,通过保留的只读 handle 执行有界哈希并保留失败清理供重试。这只是观察到的文件证据,不是已加载代码或 fixture 的身份证明;原生验收及公开内存工具仍未提供。详见[契约](../docs/process_memory_contract.md)。 +内部 Windows 进程内存准备工作新增映像文件测量,通过保留的只读 handle 执行有界哈希并保留失败清理供重试。这只是观察到的文件证据,不是已加载代码或 fixture 的身份证明;原生验收尚未完成,且不提供任意地址内存工具。详见[契约](../docs/process_memory_contract.md)。 + +主机管理的 fixture profile 通过既有目标管理 API 与 GUI JSON 编辑器,将固定 worker 绑定到已审阅的配置路径和摘要。注册不会取得资源;bootstrap 与 configure 都核对部署绑定。明确调用 probe 时,会由有时限的后台 helper 检查静态产物,报告 `static_artifacts_ready`、`fixture_execution=not_run` 与 `native_evidence=not_recorded`。runtime 关闭时,会保留所有权直到诊断 helper 完成回收。fixture 仅在受管 readiness 中取得。配置与映像检查不证明 Python 源码或 DLL 可信。原生执行仍暂停;私有交付格式与限制记载于同一契约。 WebRTC peer 也会保留媒体构造与清理失败的原始资源,观测即时停用完成,并将延后协商绑定原 peer。媒体 producer 关闭会报告待完成或不确定的清理结果,并保留原始资源。音频与录影不会通过不安全的 close/flush 重播宣称成功;LAN close 可明确重试。应用程序 caretaker 与 GUI 整合仍待完成。详见[清理契约](../docs/media_retirement_contract.md)。 HostBrowser 也会拒绝晚到发布,并保留未完成的线程与关闭所有权;对话框整合仍待完成。 MultiViewerHost 可返回含原始 session 清理对象的 offer,延后清理不会停止替换后的连接或画面来源;GUI 接入仍待完成。 + +主机选定的语义 adapter 可通过既有观察 API 返回多来源报告。fixture 结合经审阅的内存读取与自有只读 IPC snapshot,并在提交前重新核对两者。报告版本 3 由主机程序固定必要字段,分别保留有效字段与各字段的失败原因。缺失来源、冲突与 best-effort 读取不能授权操作或确认完成。版本 1 与 2 会被拒绝。 + +独立自有 UI 观察 fixture 可通过 `test/fixtures/native_memory/build_fixture.py --kind uia` 构建,静态 manifest 维持 schema 2。内部 launcher 将启动消息绑定保留进程与窗口所有者。限定范围的 UIA reader 核对该窗口、进程与根节点身份,限制树遍历并保护密码字段。只读受管 adapter 延迟创建 COM,通过共用观察 API 保留部分字段结果。 + +注入调用与隐藏 Python helper 已覆盖限定范围读取、报告与超时回收。原生部署信任、DOM 整合与桌面验收仍待完成,尚未执行原生 UI fixture,也未证明不干扰桌面。 + +内部自有 UI target 在 attestation 前保留启动器及两个独立映像租约拥有者; +清理会尝试全部资源并保留失败项目供重试。发布锁防止关闭后存入晚到的来源。 +原生 factory 仅建立拥有者;原生部署信任及原生验收仍待完成。 + +主机管理可注册 `uia_fixture` profile,`allowed_tools`、`roots`、`apps` 都为空, +配置只接受 `config_path`/`config_sha256`。固定隔离 worker 在取得资源前核对部署、profile +与目标 pin,两端都拒绝命令。外部任务只有在没有预排动作时可使用空工具集合; +仍须提供完成条件,空计划不能证明完成,UI partial/best-effort 报告仍只供诊断。 +注册与 probe 不取得资源;probe 返回 `not_supported` 与 `native_evidence=not_recorded`。 +既有目标 API、CLI 与 GUI JSON 编辑器可传递此 profile。注入及隐藏 helper 测试不代表原生信任成立。 + +主机选定的进程内服务 adapter 可使用封闭的 `service_state` 完成条件: +`{"kind":"service_state","tool":"AC_service_start","state":"running"}`,或 STOP/stopped。 +判定须有对应操作的确认回执,以及同一资源所有者在接受后取得的新 SCM 查询。 +通过只表示 SCM 报告该状态,不证明原子完成、健康或桌面无干扰。这些工具名称仅属于 +adapter 范围,不是全局 executor 指令。现有任务 API 与 GUI JSON 编辑器可传递此条件。 +主机审阅的 `service` profile 固定 `config_path`、`config_sha256` 及 ASCII `service_key`。 +固定 worker 核对部署的服务与操作上限后才接受任务范围。注册、重载与 probe 不读取部署文件 +或访问 SCM;原生验收仍待完成。 +所有固定路径(各 profile 的 `config_path` 及部署指定的映像文件)都必须是本机磁盘路径: +UNC 共享、`\\.\pipe\` 名称、`\\?\` 设备路径与 `..` 片段一律拒绝,注册 profile 不能让主机把凭据发送到其他机器。 +fixture 映像执行前,租约还会拒绝其他账户能更改的位置:从磁盘根目录往下的每一层都必须是实体目录 +(不能是 junction 或 symlink),且只有 SYSTEM、Administrators、TrustedInstaller 与当前用户能改名、删除、 +改 ACL 或新增文件;租约文件的最终路径也必须等于配置的路径。请把 fixture 部署在 `%LOCALAPPDATA%` 这类受保护目录; +授予 Authenticated Users 修改权限的磁盘根目录(次要磁盘常见)或共享的 `%TEMP%` 会被拒绝。 +fixture 在自己的目录启动,只带最小环境变量:仅含系统目录的 `PATH`,不带主机的任何 token 或密钥。 diff --git a/README/README_zh-TW.md b/README/README_zh-TW.md index 6930c3856..bc41866d6 100644 --- a/README/README_zh-TW.md +++ b/README/README_zh-TW.md @@ -57,6 +57,8 @@ Wayland NORMAL 輸入透過受管理的子程序執行 libei 與 portal 呼叫 受管理的 Agent 任務與跨主機傳輸包含實驗性功能;採用前請查看實作紀錄與專案進度中的驗收狀態。 +主機選定的語意 target 支援 `semantic` 完成條件,以新讀回核對已記錄的目標身分及期望欄位。此條件不授予記憶體存取權,也不啟用原生 target。詳見[語意完成驗證](../docs/process_memory_contract.md#semantic-completion)。 + ## 文件 - [安裝、平台支援與設定](../docs/guides/zh-TW/setup.md) @@ -87,10 +89,45 @@ REST 主機資料讀取與對應 MCP 權限一致:排程、遠端 session、US 主機唯讀模式對外部提供的目錄及後續註冊套用相同限制,接收請求及重新核對身分後的呼叫都檢查混合用途參數。MCP 設定的失敗截圖需要可寫入的工具及重新核對後具輸入操作權限的呼叫者;唯讀呼叫與 viewer 不會觸發截圖。這不表示所有相依套件或診斷讀取均無初始化副作用。 -內部 Windows 行程記憶體準備工作新增映像檔量測,透過保留的唯讀 handle 執行有界雜湊並保留失敗清理供重試。這只是觀測到的檔案證據,不是已載入程式碼或 fixture 的身分證明;原生驗收及公開記憶體工具仍未提供。詳見[契約](../docs/process_memory_contract.md)。 +內部 Windows 行程記憶體準備工作新增映像檔量測,透過保留的唯讀 handle 執行有界雜湊並保留失敗清理供重試。這只是觀測到的檔案證據,不是已載入程式碼或 fixture 的身分證明;原生驗收尚未完成,且不提供任意位址記憶體工具。詳見[契約](../docs/process_memory_contract.md)。 + +主機管理的 fixture profile 透過既有目標管理 API 與 GUI JSON 編輯器,將固定 worker 綁定到已審閱的設定路徑與摘要。註冊不會取得資源;bootstrap 與 configure 都核對部署綁定。明確呼叫 probe 時,會由有時限的背景 helper 檢查靜態產物,回報 `static_artifacts_ready`、`fixture_execution=not_run` 與 `native_evidence=not_recorded`。runtime 關閉時,會保留所有權直到診斷 helper 完成回收。fixture 僅在受管 readiness 中取得。設定與映像檢查不證明 Python 原始碼或 DLL 可信。原生執行仍暫停;私有交付格式與限制記載於同一契約。 WebRTC peer 也會保留媒體建構與清理失敗的原始資源,觀測即時停用完成,並將延後協商綁定原 peer。媒體 producer 關閉會回報待完成或不確定的清理結果,並保留原始資源。音訊與錄影不會透過不安全的 close/flush 重播宣稱成功;LAN close 可明確重試。應用程式 caretaker 與 GUI 整合仍待完成。詳見[清理契約](../docs/media_retirement_contract.md)。 HostBrowser 亦會拒絕晚到發布,並保留未完成的執行緒與關閉所有權;對話框整合仍待完成。 MultiViewerHost 可回傳含原始 session 清理物件的 offer,延後清理不會停止替換後的連線或畫面來源;GUI 接入仍待完成。 + +主機選定的語意 adapter 可透過既有觀察 API 回傳多來源報告。fixture 結合受審閱的記憶體讀取與自有唯讀 IPC snapshot,並在提交前重新核對兩者。報告版本 3 由主機程式固定必要欄位,分別保留有效欄位與各欄位的失敗原因。缺失來源、衝突與 best-effort 擷取不能授權操作或確認完成。版本 1 與 2 會被拒絕。 + +獨立自有 UI 觀察 fixture 可透過 `test/fixtures/native_memory/build_fixture.py --kind uia` 建置,靜態 manifest 維持 schema 2。內部 launcher 將啟動訊息綁定保留程序與視窗擁有者。限定範圍的 UIA reader 核對該視窗、程序與根節點身分,限制樹狀走訪並保護密碼欄位。唯讀受管 adapter 延遲建立 COM,透過共用觀察 API 保留部分欄位結果。 + +注入呼叫與隱藏 Python helper 已涵蓋限定範圍讀取、報告與逾時回收。原生部署信任、DOM 整合與桌面驗收仍待完成,尚未執行原生 UI fixture,也未證明不干擾桌面。 + +內部自有 UI target 在 attestation 前保留啟動器及兩個獨立映像租約擁有者; +清理會嘗試全部資源並保留失敗項目供重試。發布鎖防止關閉後存入晚到的來源。 +原生 factory 僅建立擁有者;原生部署信任及原生驗收仍待完成。 + +主機管理可註冊 `uia_fixture` profile,`allowed_tools`、`roots`、`apps` 都為空, +設定只接受 `config_path`/`config_sha256`。固定隔離 worker 在取得資源前核對部署、profile +與目標 pin,兩端都拒絕命令。外部任務只有在沒有預排動作時可使用空工具集合; +仍須提供完成條件,空計畫不能證明完成,UI partial/best-effort 報告仍只供診斷。 +註冊與 probe 不取得資源;probe 回傳 `not_supported` 與 `native_evidence=not_recorded`。 +既有目標 API、CLI 與 GUI JSON 編輯器可傳遞此 profile。注入及隱藏 helper 測試不代表原生信任成立。 + +主機選定的程序內服務 adapter 可使用封閉的 `service_state` 完成條件: +`{"kind":"service_state","tool":"AC_service_start","state":"running"}`,或 STOP/stopped。 +判定須有對應操作的確認回條,以及同一資源擁有者在接受後取得的新 SCM 查詢。 +通過只表示 SCM 回報該狀態,不證明原子完成、健康或桌面不干擾。這些工具名稱只屬於 +adapter 範圍,不是全域 executor 指令。既有任務 API 與 GUI JSON 編輯器可傳遞此條件。 +主機審閱的 `service` profile 固定 `config_path`、`config_sha256` 及 ASCII `service_key`。 +固定 worker 核對部署的服務與操作上限後才接受任務範圍。註冊、重載與 probe 不讀取部署檔 +或存取 SCM;原生驗收仍待完成。 +所有固定路徑(各 profile 的 `config_path` 及部署指定的映像檔)都必須是本機磁碟路徑: +UNC 共用、`\\.\pipe\` 名稱、`\\?\` 裝置路徑與 `..` 片段一律拒絕,註冊 profile 不能讓主機把認證送到其他機器。 +fixture 映像執行前,租約還會拒絕其他帳號能變更的位置:從磁碟根目錄往下的每一層都必須是實體目錄 +(不能是 junction 或 symlink),且只有 SYSTEM、Administrators、TrustedInstaller 與目前使用者能改名、刪除、 +改 ACL 或新增檔案;租約檔案的最終路徑也必須等於設定的路徑。請把 fixture 部署在 `%LOCALAPPDATA%` 這類受保護目錄; +授予 Authenticated Users 修改權限的磁碟根目錄(次要磁碟常見)或共用的 `%TEMP%` 會被拒絕。 +fixture 在自己的目錄啟動,只帶最小環境變數:僅含系統目錄的 `PATH`,不帶主機的任何 token 或金鑰。 diff --git a/architecture.md b/architecture.md index 8556c0734..102471a30 100644 --- a/architecture.md +++ b/architecture.md @@ -1,5 +1,29 @@ # AutoControl Architecture +Process-memory fixture decoding owns schema-one layout and challenge binding in +`utils/process_memory/fixture_probe.py`. The fixture's resolver delegates to this +adapter. Bootstrap locations remain private and require separate executable +attestation; this adapter does not grant read authority or establish native acceptance. + +Managed runtime semantic adapters opt into `SemanticTarget` through trusted host +code. Its closed snapshot keeps provenance and revision in grounding while +excluding only capture metadata. Grounded dispatch passes the original snapshot +and journal action ID; only an operation-bound `SemanticReceipt` confirms a reply. +Multi-source adapters pin the common required field scope in host code. Report v2 +checks that scope at capture, helper bootstrap and completion against the saved +journal witness; shared omissions cannot authorize commands. +Ordinary targets keep their existing full-payload comparison and dispatch path. + +`NativeSemanticTarget` transports the same contract through the existing owned +helper channel and resource lock. It requires a semantic handshake before target +configuration. The worker rechecks tool scope; both peers refuse input events. +Semantic cleanup keeps input and executor guards active through EOF retirement. + +Semantic completion stores the original validated snapshot in action grounding. +Fresh readback must match its target provenance and checked revision before +comparing expected fields. Every semantic capture interval must lie inside the +current host-monotonic read request, including pre-dispatch grounding reads. + WebRTC statistics owns one submitted polling future. Start does not wait for the event loop; stop closes admission, cancels pending submission and drops the callback owner without acquiring a bridge. Late awaited samples are discarded. @@ -42,6 +66,42 @@ The process-memory test fixture owns fixed payload and sequence buffers in a hid child process. Bounded inherited pipes expose expected state and validated fixture updates. Bootstrap facts remain unverified until a native provider independently matches the retained process identity. This tooling adds no public memory API. +The internal MemorySemanticTarget composes a fixed host reader binding and a +reviewed background command owner. Managed scope checks gate reads and commands; +cleanup makes the target terminal and retains failed handle retirement for retry. +Injected-provider tests exercise this path through AgentRuntime completion. +FixtureCommands translates the one internal fixture operation into compare_set, +binds strict receipts to the original revision and operation ID, and retires its +command owner after an unknown reply. The reader remains read-only. +OwnedFixtureControl reuses OwnedChannel for bounded fixture RPC, validates private +bootstrap data, and retires failed exchanges while retaining failed cleanup ownership. +Hidden IPC tests establish transport behavior only, not native memory identity. +OwnedChannelLauncher lets the pinned-image launch flow measure the retained IPC +process handle, then refuses bootstrap PID/architecture disagreement. This seam +has injected-call tests; loaded-code/runtime trust and native execution remain pending. +The native_memory test fixture is an x64 C build with static CRT and a bounded RPC +parser. Its build tool records source/image/tool hashes and static DLL imports; +it never executes the artifact. This does not register a supported native target. +The PE planner derives all executable ranges from the pinned x64 baseline and +rejects writable or relocated code. Its reader guard requires the launch image +hash, checks headers/code and mapping continuity within unchanged probe budgets. +Evidence covers matching bytes only, not live protection flags or runtime integrity. +OwnedFixtureTarget assembles those checks with fixture commands and managed semantic +reads. It owns the launcher and image observers before startup, rejects late startup +publication after retirement, and retains every failed cleanup owner for retry. +Managed readiness claims the exact task and owner before lazy acquisition and +rechecks the original operation after callbacks. Competing readiness cannot bind +the inner target between startup publication and owner configuration. +It remains internal and unregistered pending native trust and acceptance evidence. +The native fixture acceptance CLI defaults to static inventory matching. Its +explicit smoke path uses this assembly and reports selected checks separately +from full native acceptance, dependency trust and foreground noninterference. +The C fixture also prepares four fixed diagnostic page layouts in a separate +allocation. Those modes expose bootstrap only. The diagnostic runner attributes +reads/refusals using private bootstrap-bound query evidence from one handle, +including a successful prefix read; actual native page validation remains pending. +The helper error codec preserves fixed memory failure reasons across IPC without +serializing exception text; malformed or mixed memory error packets are refused. The internal Windows provider owns read/query handles and measures native process facts before asking an explicit reviewed attestor for application identity. Its bindings are tested through injected calls; trusted attestation and native acceptance @@ -1517,3 +1577,82 @@ desktop tasks remain unavailable. This transport is not full Linux application o Installed wheel and source distributions include the REST Dashboard and Swagger HTML, CSS and JavaScript resources. The same localhost REST routes and authentication rules apply to an installed package; serving static pages grants no task or desktop input authority. + +The owned memory fixture supports launch-bound `compare_set` with a bounded, +non-evicting receipt ledger. Runtime adapter integration remains in `Progress.md`; +this fixture protocol does not establish native memory acceptance. + +`test/fixtures/native_memory/uia_fixture.c` owns a separate hidden-window test +artifact. The build script selects a closed memory/UIA source and dependency set; +UIA manifests are distinct from memory acceptance inputs. No runtime owner or +scoped UIA acquisition is registered by building it. + +`owned_channel_launch.py` centralizes pinned child measurement and retryable +channel retirement for memory and UI fixture launchers. `uia_channel.py` receives +only one correlated startup; `uia_launch.py` binds its HWND to retained launch +facts and `windows_window.py` supplies the single typed owner query. The binding +borrows the launcher and image leases; it cannot grant UIA action authority. + +`scoped_uia.py` reads fixed host selectors beneath that binding, verifies bounded +ancestry around field reads and retains the first verified root runtime identity. +`capture_metadata.py` shares capture validation with complete snapshots and +`partial_observation.py`; report version 3 preserves successful fields beside +closed per-field failures. Best-effort UIA observations cannot ground actions. +`uia_target.py` binds the reader to managed scope with lazy COM acquisition and +retryable cleanup. Native deployment trust and acceptance remain in `Progress.md`; +hidden Python helper tests establish IPC retirement, not native COM acceptance. + +`uia_owner.py` retains the launcher and two independent image owners before +attestation starts. A private owner bundle supplies the managed adapter callbacks; +the adapter remains the sole lifecycle owner. Its publication lock excludes source +installation after cleanup. The native factory constructs inert owners only; +fixed worker deployment and zero-action profile registration are described below. + +`pinned_deployment.py` checks bounded configuration bytes before any artifact path +is followed; memory and UI loaders retain their distinct closed schemas. +`uia_deployment.py` checks the UI image hash and bounds before owner construction. +`uia_worker.py` validates the original deployment/profile/target before scope +mutation and refuses effects. `uia_native_target.py` fixes the worker argv and +binds its bootstrap to the configuration digest, target and UI report contract. +The `uia_fixture` profile grants no tools, roots or desktop applications and uses +the existing host management and task editor surfaces. Empty tool scopes require +external mode and no planned actions. They do not make an empty plan complete. +Native execution and trusted Python/COM/DLL delivery remain unverified. + +`service_status.py` models the latest SCM report as diagnostic best-effort data. +`windows_service.py` exposes separate query-only and explicitly scoped control +façades. `windows_service_session.py` owns their retained handles, serialized +admission, retirement and pending operation state; `windows_service_native.py` +binds only the native functions their host scope needs. Failed closes remain +owned for retry. Query failures retire the session. Unknown control outcomes +block further controls while allowing diagnostic reads. +`service_operations.py` validates exact requests and retains bounded acceptance +receipts without replaying effects. Accepted commands await an independent read +of their desired state before another command is admitted; unknown outcomes +cannot be cleared by a matching read. Status comparison is non-atomic and a +receipt proves only acceptance. Timeouts bound admission and reject late output, +but cannot interrupt native calls or cleanup. Trusted native deployment, +dependency effect review and native service acceptance remain pending. + +`service_observation.py` defines closed service provenance, capture and acceptance +schemas. `service_target.py` pins the retained controller to one managed spec and +authority source, preserves original acceptance times and retires publication +before cleanup. `target_dispatch.py` selects this explicit service contract and +delegates all other targets to the existing semantic dispatch helpers. +`service_verification.py` checks a confirmed journal attempt against a new report +from the same binding after acceptance. Its `service_state` criterion describes +reported SCM state only. The ordinary semantic revision gates are unchanged. +`service_worker.py` preflights the closed service configuration and routes a +separate observed-service operation. NativeWorker shares input/authority/retirement +guards across explicit semantic and service targets, preserving their separate +bootstrap and evidence contracts. `service_native_target.py` pins helper evidence +to the original bootstrap binding and uses the existing non-display owned channel. +`service_scope.py` derives a same-user resource lock from printable ASCII service +keys, independent of target/configuration/database names. Typed service errors +cross IPC before event interpretation. The service profile carries its ASCII key +so registration/reload can remain independent of deployment-file availability. +`service_deployment.py` validates bounded pinned config and the operation ceiling; +`service_entrypoint.py` validates profile/task/deployment identity before the shared +worker accepts scope. The config digest and task profile digest remain distinct. +Native deployment, Unicode key canonicalization and cross-account coordination +remain pending. diff --git a/architecture_explore.md b/architecture_explore.md index c9fcdaad6..e5a5fd59c 100644 --- a/architecture_explore.md +++ b/architecture_explore.md @@ -11,7 +11,7 @@ CI 以 `python scripts/generate_facade_exports.py --check` 檢查一致性。六 > 擷取每個模組的 docstring 與頂層公開名稱;統計數字取自實際檔案,非估算。 > 指令數與公開 API 數以 `executor.known_commands()` 與 `je_auto_control.__all__` 在工作樹上實測取得。 > -> **掃描時間**:2026-11-12 **版本**:`pyproject.toml` version `1.2.0` **分支**:`dev` +> **掃描時間**:2026-11-18 **版本**:`pyproject.toml` version `1.2.0` **分支**:`dev` --- @@ -27,8 +27,8 @@ iOS(WebDriverAgent)。核心能力是滑鼠/鍵盤控制、影像辨識、 | 指標 | 數值 | | --- | ---: | -| Python 模組總數(含周邊子專案) | 1,548 | -| 程式碼總行數 | 239,071 | +| Python 模組總數(含周邊子專案) | 1,596 | +| 程式碼總行數 | 244,443 | | `je_auto_control/utils/` 子套件數 | 313 | | `AC_*` 動作指令數(`known_commands()` 實測) | 911 | | 套件門面 `__all__` 公開名稱數 | 1504 | @@ -202,7 +202,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 ### 5.3 平台後端 -#### Windows(`windows/`,24 檔/2,363 行) +#### Windows(`windows/`,24 檔/2,366 行) | 模組 | 行數 | 職責 | | --- | ---: | --- | @@ -214,7 +214,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `record/win32_input_hook.py` | 258 | 單一一組低階鍵鼠 hook(`WH_KEYBOARD_LL`/`WH_MOUSE_LL`)+訊息迴圈,產生帶時間戳的事件時間軸;停止時以 `PostThreadMessageW(WM_QUIT)` 收掉執行緒,不會每錄一次就漏一條。 | | `record/win32_record.py` | 41 | 把 `win32_input_hook` 的時間軸轉成 action list(含按鍵放開、滾輪與間隔);整形本體與 macOS 共用 `utils/input_macro/recorder_base.py`。 | | `screen/win32_screen.py` | 171 | 螢幕尺寸與像素讀取。**每支 Win32 函式都明寫 argtypes/restype**(HDC 是指標寬度,走預設的 c_int 會截斷,錯誤會沉默地擴散到 GetPixel/ReleaseDC),並持有自己的 user32/gdi32 handle。import 時呼叫 `SetProcessDPIAware()`——**行程層級且不可還原**,實體↔邏輯座標換算請走 `utils/monitor_layout`。 | -| `window/windows_window_manage.py` | 566 | 視窗列舉/聚焦/關閉/最小化/幾何/所屬行程 PID/投遞式輸入(`auto_control_window` 的實作)。**每支 Win32 函式都明寫 argtypes/restype**,並持有自己的 user32 handle,避免把原型外溢到別的模組;hwnd 一律是 int。 | +| `window/windows_window_manage.py` | 569 | 視窗列舉/聚焦/關閉/最小化/幾何/所屬行程 PID/投遞式輸入(`auto_control_window` 的實作)。**每支 Win32 函式都明寫 argtypes/restype**,並持有自己的 user32 handle,避免把原型外溢到別的模組;hwnd 一律是 int。 | | `message/window_message.py` | 97 | 直接對視窗送 `WM_*` 訊息(背景輸入)。 | | `interception/_dll.py` | 232 | `interception.dll` 的延遲 ctypes 載入與結構定義。 | | `interception/keyboard.py` | 70 | 經 Interception 驅動的鍵盤輸入(繞過部分反自動化偵測)。 | @@ -324,7 +324,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 ### 5.4.2 框架基礎設施 -> 15 個套件、約 5,433 行。 +> 15 個套件、約 6,115 行。 | 模組 | 行數 | 職責 | | --- | ---: | --- | @@ -340,7 +340,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `utils/package_manager/` | 198 | 動態載入套件並把 executor 注入其中;載入前先過套件閘門(允許清單加上只能從 Python 呼叫的開關,工作區 X-12) | | `utils/path_guard/` | 267 | 命令列及伺服器的路徑邊界、客戶端根目錄隔離與受管任務來源政策紀錄 | | `utils/platform_id/` | 62 | 作業系統家族的單一判定點。`sys.platform` 原本在一百多處跟字面清單比對,而那些清單都沒有 BSD;`is_x11_unix()` 問的是「這是不是 X11 unix」,這才是守衛一直想問的問題 | -| `utils/process_memory/` | 1,590 | 內部受審 probe 的有界語意觀察、typed Windows provider、獨立映像檔觀測、自有啟動加釘選雜湊的 attestor 與失敗 handle 回收;檔案證據不等於載入程式碼身分,原生驗收及 runtime 整合待完成 | +| `utils/process_memory/` | 2,272 | 內部受審 probe 的有界語意觀察、typed Windows provider、獨立映像檔觀測、自有啟動加釘選雜湊的 attestor 與失敗 handle 回收;檔案證據不等於載入程式碼身分,原生驗收及 runtime 整合待完成 | | `utils/shell_process/` | 312 | `ShellManager`:以 argv list 執行外部命令(禁用 `shell=True`) | | `utils/start_exe/` | 36 | 啟動另一個執行檔行程 | @@ -516,13 +516,13 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 ### 5.4.9 AI / Agent / LLM -> 14 個套件、約 53,186 行。 +> 14 個套件、約 57,836 行。 | 模組 | 行數 | 職責 | | --- | ---: | --- | | `utils/a2a/` | 92 | A2A(agent-to-agent)agent card 產生 | | `utils/agent/` | 2,254 | 閉環 Computer-Use Agent 主迴圈 + Anthropic/OpenAI/Computer-Use 三後端 | -| `utils/agent_runtime/` | 26,101 | 受管任務、服務、控制權世代、結果驗證與本機推論;所有入口共用執行層。 | +| `utils/agent_runtime/` | 30,751 | 受管任務、服務、控制權世代、結果驗證與本機推論;所有入口共用執行層。 | | `utils/agent_memory/` | 166 | agent 的持久化情節記憶(goal → trajectory → outcome) | | `utils/agent_replay/` | 67 | 可攜的 agent 軌跡追蹤(記錄 observation→action 並重播) | | `utils/agent_trace/` | 172 | agent 可觀測性:OpenTelemetry GenAI 慣例的 LLM span | @@ -537,14 +537,14 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 ### 5.4.10 遠端桌面與 USB -> 6 個套件、約 32,298 行。 +> 6 個套件、約 32,325 行。 | 模組 | 行數 | 職責 | | --- | ---: | --- | | `utils/admin/` | 473 | 多主機管理主控台:平行輪詢 N 個 AutoControl REST 端點 | | `utils/config_sync/` | 8,577 | 持久化設定與條件交易:`contract.py` 管理有限 JSON 與協定例外;`store.py` 以 SQLite 原子比較版本/記錄重送收據;`routes.py` 提供第二版 HTTP 與明確盲寫相容;`commands.py` 共用 AC/MCP/Builder;`client.py` 條件提交,另有因果模型、peer ledger 與本機 SQLite outbox;第三版 /causal 交易已接上確認/退休/回收與刪除憑證;client/outbox 已接上原請求重送、有界 CAS 重合併及原子快照確認;持久化控制、原子本機 full-resync/舊待送退役與歷史收據已接上。本機資產工具另提供 manifest、整版雜湊驗證與不可變目錄發布;七種來源 adapters 保存可攜因果 profiles;workspace INI 與 GUI 共用偏好正規化。來源/outbox 與原子 full-resync 基準已由 SyncWorkspace 協調;引用資產以不可變分塊/完整 hash 收據、具驗證 HTTP 與完整 profile 串流發布接上;Sync UI 仍屬 C3。 | | `utils/device_matrix/` | 201 | 行動裝置矩陣:同一 action list 於多台裝置平行執行 | -| `utils/remote_desktop/` | 16,970 | **遠端桌面子系統**:TCP/WebSocket/WebRTC 三條傳輸路徑、主機與檢視端、訊令伺服器、TURN/中繼、多檢視者、錄影、信任清單、TOTP、稽核鏈;私有選用功能模組保留整組匯入結果。 | +| `utils/remote_desktop/` | 16,997 | **遠端桌面子系統**:TCP/WebSocket/WebRTC 三條傳輸路徑、主機與檢視端、訊令伺服器、TURN/中繼、多檢視者、錄影、信任清單、TOTP、稽核鏈;私有選用功能模組保留整組匯入結果。 | | `utils/usb/` | 5,069 | 跨平台 USB 列舉/熱插拔/裝置直通(WinUSB、IOKit、libusb 後端 + ACL + WebRTC DataChannel 通道) | | `utils/usbip/` | 1,008 | USB/IP 線路協定主機端(協定封包、TCP 伺服器、libusb URB 後端) | @@ -562,7 +562,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 ### 5.4.11 伺服器、網路協定與外部整合 -> 24 個套件、約 7,803 行。 +> 24 個套件、約 7,805 行。 | 模組 | 行數 | 職責 | | --- | ---: | --- | @@ -572,7 +572,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `utils/email_send/` | 118 | SMTP 寄信(email 觸發器的發送端搭檔) | | `utils/events/` | 106 | 對外 CloudEvents 發送(執行生命週期事件) | | `utils/http_cassette/` | 200 | 錄製/重播 HTTP 互動,做離線決定性 API 測試 | -| `utils/http_client/` | 469 | 零依賴 HTTP(S) 用戶端,供 action 步驟呼叫 API | +| `utils/http_client/` | 471 | 零依賴 HTTP(S) 用戶端,供 action 步驟呼叫 API | | `utils/http_conditional/` | 148 | 條件式 HTTP 請求與快取驗證器 | | `utils/http_content/` | 158 | HTTP 內容協商與回應解壓縮 | | `utils/http_problem/` | 122 | RFC 9457 problem+json 解析 | @@ -665,7 +665,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 ### 5.4.14 安全、機密與合規 -> 13 個套件、約 4,763 行。 +> 13 個套件、約 4,765 行。 | 模組 | 行數 | 職責 | | --- | ---: | --- | @@ -674,7 +674,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `utils/governance/` | 263 | 治理:maker-checker 核准閘門與即時憑證租約 | | `utils/license_policy/` | 240 | 以 SBOM 元件評估 SPDX 授權允許/拒絕政策 | | `utils/provenance/` | 126 | SLSA 建置來源證明(in-toto v1) | -| `utils/rbac/` | 1,991 | 角色型存取控制:使用者與權杖驗證、REST/MCP/executor 的能力政策,`deferred.py` 將背景工作綁定註冊者並在觸發時重新驗證來源 store;不保存 bearer token。;MCP 的 tool_classification.py 擁有明確畫面/呼叫者資料清單、標準別名與混合參數權限;未知唯讀提示要求 read_data;command_review.py 記錄 `COMMAND_CAPABILITIES` 以外每個 `AC_*` 指令的審查(只需提交入口的 drive_input),新指令未分類時 CI 失敗 | +| `utils/rbac/` | 1,993 | 角色型存取控制:使用者與權杖驗證、REST/MCP/executor 的能力政策,`deferred.py` 將背景工作綁定註冊者並在觸發時重新驗證來源 store;不保存 bearer token。;MCP 的 tool_classification.py 擁有明確畫面/呼叫者資料清單、標準別名與混合參數權限;未知唯讀提示要求 read_data;command_review.py 記錄 `COMMAND_CAPABILITIES` 以外每個 `AC_*` 指令的審查(只需提交入口的 drive_input),新指令未分類時 CI 失敗 | | `utils/redaction/` | 508 | 截圖遮蔽層:規則偵測 + 政策 + 協調器(上傳 VLM 前先遮) | | `utils/sbom/` | 170 | SBOM(CycloneDX)產生 | | `utils/secret_ref/` | 242 | URI scheme 形式的值參照解析 | @@ -731,19 +731,24 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 上表以子套件為單位;以下把行數最大的幾個子系統展開到檔案層。 -#### `utils/process_memory/`(1,590 行/10 檔) +#### `utils/process_memory/`(2,272 行/15 檔) | 檔案 | 行數 | 職責 | | --- | ---: | --- | | `__init__.py` | 1 | Internal reviewed process observations; no native provider or public command registration. | | `background_profile.py` | 119 | Reviewable M0 routing profile: which background channel serves an operation, never desktop input. | -| `models.py` | 203 | Closed identities, reviewed probes and safe semantic observation results. | -| `reader.py` | 310 | Adapter-owned semantic observations with bounded reads and retained cleanup ownership. | +| `models.py` | 204 | Closed identities, reviewed probes and safe semantic observation results. | +| `pe_image.py` | 214 | Derive complete executable-range checks from a pinned, supported PE32+ baseline. | +| `image_guard.py` | 43 | Check pinned executable bytes through the same bounded resolver view as semantic data. | +| `fixture_probe.py` | 92 | Version-one fixture decoding and challenge-bound resolution for reviewed launches. | +| `reader.py` | 312 | Adapter-owned semantic observations with bounded reads and retained cleanup ownership. | | `windows.py` | 194 | Owned Windows read handles with measured native facts and reviewed application attestation. | | `windows_facts.py` | 55 | Measure native birth, session and architecture through a retained process handle. | -| `windows_image.py` | 308 | Observe an image file while retaining its process and deny-write/delete file leases. | +| `windows_image.py` | 326 | Observe an image file while retaining its process and deny-write/delete file leases. | | `windows_image_native.py` | 62 | Typed process-image filename and read-only file acquisition calls. | -| `windows_launch.py` | 225 | Attest a process this host launched itself, from an image file pinned by SHA-256. | +| `windows_image_trust.py` | 257 | Refuse a pinned image another local account could redirect or plant code beside. | +| `windows_launch.py` | 242 | Attest a process this host launched itself, from an image file pinned by SHA-256. | +| `windows_window.py` | 38 | Query a specified HWND's current owner without enumeration, activation or input. | | `windows_native.py` | 113 | Typed Win32 query/read bindings and caller-sized memory information layouts. | #### `utils/executor/`(10,806 行)— 執行核心 @@ -819,7 +824,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `rate_limit.py` | 48 | 工具呼叫的 token bucket 限流。 | | `__main__.py` | 126 | `je_auto_control_mcp` console script 進入點。 | -#### `utils/remote_desktop/`(16,970 行/77 檔) +#### `utils/remote_desktop/`(16,997 行/77 檔) 三條傳輸路徑並存:**TCP**(JPEG 影格)、**WebSocket**(同協定換傳輸)、**WebRTC**(aiortc 視訊 + DataChannel)。 `_export_bindings.py` 保存產生的來源對照;`_optional/` 分別管理 WebRTC、錄影、多檢視者、 @@ -829,10 +834,10 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | 檔案 | 行數 | 職責 | | --- | ---: | --- | | `webrtc_host.py` | 750 | WebRTC 主機:串流螢幕視訊並接受檢視端輸入;session 生命週期、DataChannel 接線、檔案收發。 | -| `webrtc_viewer.py` | 740 | WebRTC 檢視端:接收視訊並送出輸入。 | -| `webrtc_retirement.py` | 186 | 序列化 peer 世代、保留未完成的停止 future,區分待完成與失敗清理。 | +| `webrtc_viewer.py` | 750 | WebRTC 檢視端:接收視訊並送出輸入。 | +| `webrtc_retirement.py` | 191 | 序列化 peer 世代、保留未完成的停止 future,區分待完成與失敗清理。 | | `webrtc_media_owners.py` | 249 | 保留 peer 媒體建構失敗及未完成子資源,提供快取的 slot 清理結果。 | -| `webrtc_peer_cleanup.py` | 166 | 逐項清理 host/viewer 的原始資源,保留失敗項目並等候影格任務結束。 | +| `webrtc_peer_cleanup.py` | 168 | 逐項清理 host/viewer 的原始資源,保留失敗項目並等候影格任務結束。 | | `host.py` | 702 | TCP 主機:接受迴圈、TLS 包裝、連線/認證握手、音訊與剪貼簿廣播、檔案推送、單次 token。 | | `viewer.py` | 748 | TCP 檢視端。 | | `host_service.py` | 561 | 無頭 WebRTC 主機執行器 + 多平台服務安裝器。 | @@ -851,7 +856,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `presence.py` | 240 | 多檢視者的執行緒安全在場註冊表。 | | `jpeg_recorder_encrypted.py` | 239 | AES-GCM 加密版 session 錄影。 | | `address_book.py` | 229 | 檢視端的主機通訊錄。 | -| `audio.py` / `webrtc_audio.py` / `webrtc_mic.py` | 256 / 296 / 195 | 音訊擷取播放、音訊軌、麥克風上行。 | +| `audio.py` / `webrtc_audio.py` / `webrtc_mic.py` | 256 / 303 / 195 | 音訊擷取播放、音訊軌、麥克風上行。 | | `audio_retirement.py` | 132 | 保留單一音訊串流世代、准入中的操作與無法確認的清理結果。 | | `media_retirement.py` | 89 | 區分媒體資源釋放與最終化狀態,傳遞失敗或取消時仍需保留的擁有者。 | | `webrtc_file_commit.py` | 355 | Confirm native file publication with bounded authenticated probes and transfer/hash/size receipt matching. | @@ -863,7 +868,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `webrtc_host_auth.py` | 255 | 檢視端認證與核准:token 檢查、信任清單/IP 白名單自動放行、手動接受/拒絕、SAS、逾時關閉。 | | `lan_discovery.py` | 387 | mDNS/Zeroconf 區網探索。 | | `video_codec.py` | 197 | TCP/WS 路徑的可插拔視訊編解碼。 | -| `webrtc_host_media.py` | 258 | 重新協商與 recvonly 軌管理。aiortc 沒有 `removeTransceiver`,所以開/關不對稱——開是加軌重新 offer,關只能設 inactive 並停掉 receiver。 | +| `webrtc_host_media.py` | 261 | 重新協商與 recvonly 軌管理。aiortc 沒有 `removeTransceiver`,所以開/關不對稱——開是加軌重新 offer,關只能設 inactive 並停掉 receiver。 | | `hw_codec.py` | 207 | 硬體 H.264 編碼偵測與啟用。 | | `webrtc_stats.py` | 226 | 以單一 future 擁有 aiortc 統計輪詢;啟停不等待網路,停止後拒絕晚到樣本並釋放回呼。 | | `connect_coordinator.py` | 158 | 由使用者輸入的目標決定該用哪條傳輸。 | @@ -1047,7 +1052,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `utils/self_healing/frame_locators.py` | 142 | 純影像比對與明確 VLM backend;共用區域、原點與縮放換算。 | | `utils/self_healing/evaluation_io.py` | 188 | 有界且受路徑政策限制的本機資料集、原子 JSON/HTML 報告。 | -#### `utils/agent_runtime/`(26,101 行/182 檔) +#### `utils/agent_runtime/`(30,751 行/225 檔) | 檔案 | 行數 | 職責 | | --- | ---: | --- | @@ -1082,7 +1087,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `commands.py` | 135 | One command catalogue shared by executor, MCP and the visual script editor. | | `completion_contract.py` | 63 | Shared completion evidence and retirement checks without service or DAG transport dependencies. | | `completion_recovery.py` | 672 | Explicit post-effect completion review with private lineage and permanent read-only targets. | -| `context.py` | 74 | Host-owned operation context shared with local workers, never serialized model authority. | +| `context.py` | 79 | Host-owned operation context shared with local workers, never serialized model authority. | | `control_admission.py` | 29 | Closed runtime stop requests share a bounded reserve separate from ordinary HTTP polling. | | `dag_admission.py` | 80 | Trusted local DAG admission records bind original ownership, caller authority and a live attempt. | | `dag_batch_recording.py` | 93 | Durable dispatch claims and independent destination verification for one managed DAG batch. | @@ -1097,7 +1102,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `delegation.py` | 43 | Short-lived, authenticated principal forwarding across the local service boundary. | | `dialog_scope.py` | 54 | Pause managed desktop work at unsaved-content or unrecognized modal windows. | | `document_launch.py` | 46 | Bounded document handoff runs outside the disposable native input helper's process tree. | -| `errors.py` | 23 | Typed failures for managed tasks, observations and control ownership. | +| `errors.py` | 27 | Typed failures for managed tasks, observations and control ownership. | | `evidence.py` | 215 | Service-owned task provenance, redacted artifacts and thirty-day metadata retention. | | `evidence_cache.py` | 92 | Database-bound evidence paths never turn historical journal references into filesystem ownership. | | `evidence_handoff.py` | 376 | Explicit revocable evidence-only grants preserve ordinary task ownership and input isolation. | @@ -1113,14 +1118,15 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `local_evidence.py` | 29 | Bind server-side batch evidence to its owning runtime without global client discovery. | | `manifest_evidence.py` | 51 | Independently re-read archive manifests and their scoped files at task completion. | | `model_tools.py` | 65 | Local-model schemas expose observation references without changing legacy executor signatures. | -| `models.py` | 214 | Detached JSON contracts for managed computer tasks and their evidence. | -| `native_channel.py` | 279 | Bounded JSON IPC to an owned helper, with cancellable writes, replies and retirement. | +| `models.py` | 216 | Detached JSON contracts for managed computer tasks and their evidence. | +| `native_errors.py` | 62 | Encode helper failures without disclosing memory or service details. | +| `native_channel.py` | 284 | Bounded JSON IPC to an owned helper, with cancellable writes, replies and retirement. | | `native_control.py` | 59 | Generation-bound negative-only takeover notices with retained coarse cleanup failure diagnostics. | | `native_job.py` | 170 | Own a Windows helper process tree through a kill-on-close Job Object. | | `native_recovery.py` | 36 | Host-only input recovery checks never replay persisted keys or signal persisted PIDs. | | `native_scope.py` | 111 | Scope native window and control targets before their existing backend performs an action. | -| `native_target.py` | 310 | Native desktop proxy with private IPC, host input ledger and cross-database ownership. | -| `native_worker.py` | 350 | Private native helper entry point; stdout is a bounded owner-only JSON protocol. | +| `native_target.py` | 313 | Native desktop proxy with private IPC, host input ledger and cross-database ownership. | +| `native_worker.py` | 416 | Private native helper entry point; stdout is a bounded owner-only JSON protocol. | | `observation_refs.py` | 155 | Resolve observation-local elements and thumbnail points into host-checked native coordinates. | | `ollama.py` | 82 | Local-only Ollama decisions over bounded HTTP, without an SDK or remote fallback. | | `origin_policy.py` | 193 | Live origin path ceilings remain restrictive across accepted tasks, workers and service processes. | @@ -1132,7 +1138,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `parent_watch.py` | 25 | POSIX helpers retire their own live process group when the owning parent disappears. | | `readiness.py` | 83 | Passive readiness of the desktop, presence source, devices, browser and models; never a grant or evidence. | | `resume_gate.py` | 84 | A task's first action waits until a fresh observation passes every declared resume condition. | -| `policy.py` | 120 | Explicit task scopes, rooted data paths and secret-safe durable payloads. | +| `policy.py` | 132 | Explicit task scopes, rooted data paths and secret-safe durable payloads. | | `presence_channel_linux.py` | 434 | Own authenticated Linux packet channels, bounded leases and protected listeners. | | `presence_endpoint_linux.py` | 226 | Own protected Linux socket paths without stale-path reuse or recursive cleanup. | | `presence_frames.py` | 137 | Closed finite JSON byte frames and exact presence request/result validation. | @@ -1159,7 +1165,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `presence_x11.py` | 185 | X11 physical presence: XInput2 raw events from real devices, never from XTEST, plus logind lock state. | | `presence_worker.py` | 88 | Fixed contained source child; bootstrap and endpoint ownership precede observation. | | `readonly_target.py` | 157 | Fresh isolated completion observations with live scope checks and permanent no-input helper contracts. | -| `readonly_worker.py` | 70 | Permanently read-only owned helper: observation never upgrades to native input or task execution. | +| `readonly_worker.py` | 71 | Permanently read-only owned helper: observation never upgrades to native input or task execution. | | `receipts.py` | 84 | Owner-reviewed uncertain outcomes and per-row workflow reports without blind replay. | | `recovery_authorization.py` | 99 | Review replacement origin ceilings for explicitly reauthorized successor tasks. | | `remote_effect.py` | 75 | Bracket trusted SDK calls with durable host ACKs and explicit remote settlement evidence. | @@ -1173,7 +1179,49 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `retained_browser_runtime.py` | 91 | Connect actual browser retirement to existing runtime leases and private completion bindings. | | `retained_browser_target.py` | 98 | Closed transient read borrowers; the runtime collection owns the original helper lifetime. | | `runtime.py` | 750 | Shared managed-task lifecycle with fenced dispatch and evidence-based completion. | -| `runtime_lock.py` | 75 | Cross-process ownership for one runtime database; imports never acquire locks. | +| `owned_channel_launch.py` | 126 | Retain one pinned process channel through measurement, publication and failed retirement. | +| `uia_channel.py` | 80 | Receive one correlated UI-fixture startup without writing commands or input acknowledgments. | +| `scoped_uia.py` | 258 | Read explicit fields beneath one retained-process window inside its owned helper. | +| `uia_launch.py` | 89 | Bind a private UI-fixture HWND to the independently attested retained launch. | +| `uia_deployment.py` | 41 | Load the fixed UI fixture deployment without granting task-selected launch settings. | +| `uia_owner.py` | 100 | Retain pinned UI fixture resources before acquisition and through failed retirement. | +| `service_status.py` | 106 | Represent the latest SCM service report without granting operation authority. | +| `windows_service.py` | 72 | Expose separate query-only and host-scoped control façades over retained service ownership. | +| `windows_service_native.py` | 118 | Bind the fixed SCM query and selected control functions without acquiring handles. | +| `windows_service_session.py` | 227 | Own one retained service handle, serialized queries and non-replayed control attempts. | +| `service_operations.py` | 80 | Bound service requests and retain acceptance receipts without claiming completion. | +| `service_observation.py` | 121 | Bind best-effort service reports and acceptance receipts to one retained owner. | +| `service_target.py` | 202 | Apply managed task authority to one host-selected retained service controller. | +| `service_verification.py` | 47 | Verify a post-acceptance SCM report without inferring atomicity, health or causality. | +| `target_dispatch.py` | 55 | Dispatch explicit service evidence separately from existing semantic and ordinary targets. | +| `service_native_target.py` | 133 | Pin service helper evidence to one background process and same-user service lease. | +| `service_scope.py` | 19 | Derive same-user service ownership from reviewed printable ASCII service keys. | +| `service_worker.py` | 66 | Validate service-specific bootstrap, configuration and observed helper dispatch. | +| `service_deployment.py` | 66 | Load a closed service deployment while keeping profile construction free of file access. | +| `service_entrypoint.py` | 80 | Serve a pinned service deployment through the fixed background worker lifecycle. | +| `uia_target.py` | 151 | Expose scoped UI fixture observations under managed authority without granting actions. | +| `fixture_launch.py` | 52 | Measure an owned fixture channel's launch handle before binding its private bootstrap. | +| `fixture_target.py` | 287 | Own pinned fixture startup, guarded semantic reads and retryable resource retirement. | +| `pinned_deployment.py` | 90 | Validate bounded host-pinned deployment bytes before following artifact references. | +| `fixture_deployment.py` | 51 | Load a bounded, independently pinned host deployment for the fixed schema-one fixture. | +| `uia_worker.py` | 74 | Serve one pinned UI fixture deployment through a permanently read-only semantic worker. | +| `fixture_worker.py` | 107 | Private host-launched worker for a pinned Windows fixture, with no task-selected launch settings. | +| `uia_native_target.py` | 43 | Bind a zero-action UI profile to its fixed worker and exact deployment bootstrap. | +| `fixture_native_target.py` | 36 | Bind a managed fixture profile to one fixed worker and its pinned deployment bootstrap. | +| `fixture_probe.py` | 151 | Own bounded static fixture inspections through shutdown and failed helper retirement. | +| `fixture_control.py` | 141 | Owned fixture RPC transport with bounded requests and retained process retirement. | +| `fixture_commands.py` | 157 | Ground one owned fixture command in reviewed memory evidence and strict IPC receipts. | +| `fixture_observations.py` | 57 | Corroborate reviewed fixture memory with its retained launch-bound read-only IPC source. | +| `memory_target.py` | 137 | Bind a managed semantic target to one reviewed reader and background command owner. | +| `semantic_target.py` | 136 | Trusted semantic target dispatch with versioned snapshots and stable grounding. | +| `capture_metadata.py` | 65 | Validate source provenance and capture intervals without claiming field completeness. | +| `semantic_snapshot.py` | 100 | Closed complete semantic snapshots shared by single-source and reconciled observations. | +| `partial_observation.py` | 57 | Keep successful scalar fields and explicit per-field failures without action authority. | +| `observation_report.py` | 174 | Preserve bounded source disagreement without granting incomplete observations action authority. | +| `semantic_verification.py` | 92 | Compare fresh semantic readback with a confirmed operation's original target witness. | +| `semantic_native_target.py` | 85 | Owned semantic helper proxy that refuses every desktop input event. | +| `semantic_worker.py` | 83 | Validate grounded helper requests against the worker's immutable task scope. | +| `runtime_lock.py` | 78 | Cross-process ownership for one runtime database; imports never acquire locks. | | `service.py` | 115 | Explicit local runtime service lifecycle over the existing authenticated REST server. | | `skill_completion.py` | 129 | Private read-only evidence for skill recording and publication preserves original workflow identity. | | `skill_execution.py` | 115 | Exact original skill effects across real reviewed recovery, without granting input or replacing trials. | @@ -1182,10 +1230,10 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `skill_recording.py` | 107 | Semantic skill drafts retain verified actions, original scope and independent completion evidence. | | `store.py` | 432 | Transactional task metadata, durable action receipts and input ownership. | | `submission.py` | 40 | Admission witnesses bind tagged DAG requests before live scope normalization, without granting authority. | -| `target_config.py` | 198 | Immutable host-reviewed target configuration, distinct from untrusted task options. | +| `target_config.py` | 213 | Immutable host-reviewed target configuration, distinct from untrusted task options. | | `target_continuity.py` | 16 | Require a live UI target context before trusting a finite skill's verified prefix. | -| `target_factory.py` | 27 | Create inert managed adapters from host profiles; SDKs and native resources stay lazy. | -| `target_profiles.py` | 205 | Durable target profiles, live controls and explicit dependency diagnostics separate from native evidence. | +| `target_factory.py` | 37 | Create inert managed adapters from host profiles; SDKs and native resources stay lazy. | +| `target_profiles.py` | 231 | Durable target profiles, live controls and explicit dependency diagnostics separate from native evidence. | | `targets.py` | 193 | Explicit target adapters; native imports occur only during requested operations. | | `task_authority.py` | 322 | Trusted source-owner recovery admission and live owner/reviewer authority checks. | | `task_handoff.py` | 82 | Real non-DAG source identity for explicit completion evidence, without fabricated admission. | @@ -1218,7 +1266,7 @@ socket server 有 8 MiB 讀取上限與 30 秒 handler timeout。 | `trigger_history.py` | 89 | Renewed trigger lineages share accepted event tombstones and outstanding-task limits. | | `trigger_reauthorization.py` | 150 | Explicitly replace a trigger's unavailable origins while retaining its event history and template. | | `trigger_registration.py` | 21 | Insert normal and explicitly renewed trigger templates through one bounded transaction contract. | -| `verification.py` | 153 | Deterministic completion evidence with explicit passed, failed and unknown states. | +| `verification.py` | 177 | Deterministic completion evidence with explicit passed, failed and unknown states. | | `window_pixels.py` | 118 | Capture only an identified Windows window, with no desktop-pixel fallback. | | `workflow_desktop.py` | 70 | Reviewed semantic control and document operations within the current task's application scope. | | `wire_data.py` | 46 | Resource-free bounded JSON and budget primitives shared by host models and owned transports. | @@ -1327,7 +1375,7 @@ GUI 是**選用 extra**(`pip install je_auto_control[gui]`,只需要 PySide6 | `_screenshot_tab.py` | 180 | 獨立延遲建立的截圖/像素分頁;背景讀取、輸入快照與關閉後結果丟棄。 | | `_image_detect_tab.py` | 158 | 獨立影像偵測分頁,擁有輸入、背景工作與關閉生命週期。 | | `_script_tab.py` | 183 | 獨立腳本執行分頁;背景載入與執行,關閉取消並釋放控制項。 | -| `_record_tab.py` | 167 | 獨立錄製/回放檢視;背景工作與共享錄製器狀態,關閉檢視不停止錄製器。 | +| `_record_tab.py` | 173 | 獨立錄製/回放檢視;背景工作與共享錄製器狀態,關閉檢視不停止錄製器。 | | `_report_tab.py` | 106 | 報表分頁 mixin。 | | `_i18n_helpers.py` | 79 | 需要即時語言切換的分頁共用的翻譯註冊 mixin。 | | `_validators.py` | 29 | `int_validator()`/`double_validator()`:以 C locale 驗證的數字輸入框 validator,接受的正是 `int()`/`float()` 讀得懂的寫法(預設 locale 在法文、德文下只收小數逗號)。所有數字 `QLineEdit` 都用它。 | @@ -1358,7 +1406,7 @@ GUI 是**選用 extra**(`pip install je_auto_control[gui]`,只需要 PySide6 | auto_click | `_auto_click_tab.py` | 321 | 自動點擊:座標、間隔、熱鍵、`write`、捲動。 | | screenshot | `_screenshot_tab.py` | 180 | 截圖、選區、螢幕尺寸、取像素色。 | | image_detect | `_image_detect_tab.py` | 158 | 樣板裁切、定位、定位全部、定位並點擊。 | -| record | `_record_tab.py` | 167 | 錄製/停止/回放/存檔/載入。 | +| record | `_record_tab.py` | 173 | 錄製/停止/回放/存檔/載入。 | | script_builder | `script_builder/` | 6,957 | **視覺化腳本編輯器**:`command_schema.py`(5,551 行 `AC_*` 參數綱要)、`step_model.py`(步驟模型與 AC JSON 序列化)、`step_list_view.py`(含巢狀 body 的樹狀檢視)、`step_form_view.py`(綱要驅動表單)、`builder_tab.py`(含日誌候選預覽與明確匯入,保留來源)。 | | flow_editor | `flow_editor/` | 498 | 節點式流程圖檢視:`layout.py`(純 Python 佈局演算法,可單測)、`scene.py`(Qt 場景繪製)、`tab.py`。 | | script | `_script_tab.py` | 183 | 載入/執行單檔或整個目錄、內建編輯器執行。 | @@ -1552,15 +1600,15 @@ socket 預設綁 `127.0.0.1`;資源一律用 `with`。 | 層/子系統 | 檔案數 | 行數 | | --- | ---: | ---: | -| `gui/` | 167 | 44,024 | +| `gui/` | 167 | 44,030 | | `utils/mcp_server/` | 63 | 22,322 | -| `utils/remote_desktop/` | 77 | 16,970 | +| `utils/remote_desktop/` | 77 | 16,997 | | `utils/executor/` | 11 | 10,806 | | `utils/usb/` | 20 | 5,069 | | `je_auto_control/`(頂層 3 檔) | 5 | 5,168 | | `utils/accessibility/` | 16 | 3,384 | | `wrapper/` | 25 | 6,066 | -| `windows/` | 24 | 2,363 | +| `windows/` | 24 | 2,366 | | `utils/rest_api/` | 8 | 2,236 | | `utils/agent/` | 13 | 2,254 | | `linux_with_x11/` | 19 | 1,382 | @@ -1572,8 +1620,8 @@ socket 預設綁 `127.0.0.1`;資源一律用 `with`。 | `osx/` | 17 | 988 | | `autocontrol-lsp/` | 8 | 744 | | `utils/hotkey/` | 7 | 867 | -| 其餘模組(約 286 個 `utils/` 子套件 + `android/`/`ios/`/周邊小工具) | 1,010 | 104,530 | -| **總計** | **1,536** | **238,326** | +| 其餘模組(約 286 個 `utils/` 子套件 + `android/`/`ios/`/周邊小工具) | 1,058 | 109,866 | +| **總計** | **1,584** | **243,698** | `gui/agent_observation_view.py` provides the bounded read-only agent element table and DPR-1 image selection preview. `gui/agent_tasks_tab.py` owns only request editing and Actions-menu translation; business validation remains in the headless runtime. @@ -1583,3 +1631,27 @@ Diagnostics 內嵌 `gui/mcp_discovery_view.py`:僅透過 Actions 搜尋摘要 Installed wheel and source distributions include the REST Dashboard and Swagger HTML, CSS and JavaScript resources. The same localhost REST routes and authentication rules apply to an installed package; serving static pages grants no task or desktop input authority. + +The owned memory fixture supports launch-bound `compare_set` with a bounded, +non-evicting receipt ledger. Runtime adapter integration remains in `Progress.md`; +this fixture protocol does not establish native memory acceptance. + +`test/fixtures/native_memory/` contains the x64 static-CRT fixture source and a +build-only compiler/import-inventory tool. Its acceptance CLI defaults to static +inventory checks; an explicit execution path assembles the managed smoke roundtrip +and reports independent readback and cleanup separately. The artifact is not +executed by ordinary tests; native behavior and loaded-image trust remain in `Progress.md`. +The C fixture has fixed split, guard, no-access and decommitted diagnostic layouts. +They copy the payload into a separate two-page allocation and expose bootstrap only; +the ordinary static payload and command ledger remain separate. +The acceptance tool can select a read-only page case. A diagnostic provider wrapper +records only existing queries and read boundaries, requiring exact private payload +page metadata on one handle before accepting an expected read or refusal. +`test/fixtures/memory_target_helper.py` serves the owned memory assembly through +the existing semantic worker using injected native calls and buffers. Hidden IPC +tests cover lazy managed startup, semantic completion, typed read failures and +fresh synthetic identity after helper restart; they do not attest a native process. + +Native fixture preparation: `test/fixtures/native_memory/build_fixture.py` selects +`fixture.c` for memory or `uia_fixture.c` for owned hidden UI controls. Each uses +an exact static import inventory; compilation never executes either fixture. diff --git a/docs/API_LIFECYCLE.md b/docs/API_LIFECYCLE.md index efe449561..41340516a 100644 --- a/docs/API_LIFECYCLE.md +++ b/docs/API_LIFECYCLE.md @@ -1,5 +1,27 @@ # Public API lifecycle +Report version 3 requires a host-defined field scope, matching helper bootstrap +and saved completion witness. Tagged partial sources preserve valid fields separately +from fixed per-field failures. Empty strings and false values remain valid results. +Fields omitted by every source remain partial; extra fields and report versions 1 +and 2 are rejected. Within these semantic reports, partial and best-effort captures +grant no action or completion authority. + +Managed task `success_criteria` accepts `semantic` conditions with exactly `tool` +and bounded scalar `fields`. The existing task API and GUI scope editor carry the +same JSON contract. This requires a host-selected semantic target and a recorded +confirmed command witness; it adds no public native-memory registration API. +Completion compares fresh fields and target provenance, while `result_equals` +continues to inspect an earlier result. Semantic captures must fit inside the +current read request on the host monotonic clock; cached captures are rejected. + +Managed fixture observations now use the closed multi-source report shape rather +than a flat memory snapshot. The complete report, including the owned IPC source, +must pass its grounding gate before consumers use the primary snapshot. Safe memory +failures remain partial observations; trust, scope and cleanup failures still raise. +Commands preserve the full report across IPC, and completion checks every source. +Single-source semantic adapters retain their existing snapshot schema. + The root and remote-desktop packages resolve public exports on first attribute access. Export names, order and source-object identities stay unchanged. Required import errors occur when the corresponding export is requested. Optional remote features retain their grouped @@ -1455,3 +1477,44 @@ Graceful close attempts all tracked releases before teardown. An acknowledgement means worker emission, not application delivery; process death/reap does not prove compositor input release. Synthetic IPC tests cover ownership, while native half-open teardown and compositor release acceptance remain unexecuted here. + +The build-only UI fixture uses `build_fixture.py --kind uia` and a distinct +schema-2 manifest. Building it does not register a runtime target; it is not a memory fixture. +Native UIA exposure and desktop noninterference remain unverified. + +The internal UI fixture startup channel is receive-only and one-shot. Its binding +uses retained process facts and an explicit HWND-owner query, with final authority +checks and retry-retained cleanup. The scoped reader verifies HWND/PID, bounded raw-tree +ancestry and a root runtime ID pinned across captures. It preserves per-field failures +and protects password text. COM calls stay on the source owner thread. The internal +read-only managed adapter creates COM lazily during readiness and reports best-effort +UIA captures through the shared task API. Injected COM and hidden-helper tests cover +reporting and timeout retirement. Native deployment trust and all desktop +acceptance remain pending; no native UI fixture execution is claimed. + +The internal owned UI target retains its launcher and both image leases before +attestation, attempts every owner during cleanup, and retains failed cleanup for +retry. A publication lock prevents late source installation after shutdown. The +native factory only constructs owners; native deployment trust +and native acceptance remain pending. + +Host management can register a `uia_fixture` profile with empty `allowed_tools`, +`roots` and `apps`, and only `config_path`/`config_sha256` settings. It uses a fixed +isolated worker and validates deployment, profile and target pins before acquisition. +Both endpoints refuse commands. External tasks may use an empty tool scope only +without planned actions; completion criteria remain required and an empty plan +cannot prove completion. UI partial/best-effort reports remain diagnostic. +Registration and probe acquire nothing; probe reports `not_supported` and +`native_evidence=not_recorded`. The existing target API, CLI and GUI JSON editor +carry this profile. Injected and hidden-helper tests do not establish native trust. + +Host-selected in-process service adapters can use the closed `service_state` criterion: +`{"kind":"service_state","tool":"AC_service_start","state":"running"}` or STOP/stopped. +It requires the matching confirmed acceptance and a new SCM report from the same +retained owner after acceptance. A passing result reports SCM state, not atomic +completion, health or desktop noninterference. These tool names are adapter-scoped, +not global executor commands. Existing task APIs and the GUI JSON editor carry the +criterion. The host-reviewed `service` profile pins `config_path`, `config_sha256` +and an ASCII `service_key`. Its fixed worker checks the deployment's service and +operation ceiling before accepting task scope. Registration, reload and probe do +not read the deployment or access SCM; native acceptance remains pending. diff --git a/docs/CAPABILITY_MATRIX.md b/docs/CAPABILITY_MATRIX.md index 763f86a8c..853098099 100644 --- a/docs/CAPABILITY_MATRIX.md +++ b/docs/CAPABILITY_MATRIX.md @@ -1,5 +1,27 @@ # Capability matrix +Report version 3 requires a host-defined field scope, matching helper bootstrap +and saved completion witness. Tagged partial sources preserve valid fields separately +from fixed per-field failures. Empty strings and false values remain valid results. +Fields omitted by every source remain partial; extra fields and report versions 1 +and 2 are rejected. Within these semantic reports, partial and best-effort captures +grant no action or completion authority. + +Semantic completion compares fresh sequence-checked fields with the recorded +identity, adapter, schema and source of the last effective confirmed command. +Missing witnesses, fields or revisions and changed identities remain unknown. +Typed mismatches fail even if the command returned success; uncertain effects +remain unresolved. Capture intervals outside the current host-monotonic read +request are rejected. Counter-fixture IPC tests cover success without effect, +cached pre-dispatch observations and helper restart. Native memory targets, +cross-clock helpers and desktop noninterference are not established by these tests. + +The managed fixture now corroborates reviewed memory fields with its retained +read-only IPC snapshot. Partial memory reads and differing values/revisions remain +visible but cannot ground actions; submission rechecks both sources before the +fixture's atomic sequence comparison. Injected native calls and hidden Python helper +tests cover this path. UIA/DOM fusion and native acceptance remain unverified. + X11 package import defers display connections, server keycode resolution, RECORD listener startup and uinput device selection until use. Explicit key-table retrieval returns a real mutable dict and requires an X connection. Screen and input operations do not start recording. This startup @@ -1184,3 +1206,44 @@ acceptance. This transport is not full Linux application or native input accepta Installed wheel and source distributions include the REST Dashboard and Swagger HTML, CSS and JavaScript resources. The same localhost REST routes and authentication rules apply to an installed package; serving static pages grants no task or desktop input authority. + +The build-only UI fixture uses `build_fixture.py --kind uia` and a distinct +schema-2 manifest. Building it does not register a runtime target; it is not a memory fixture. +Native UIA exposure and desktop noninterference remain unverified. + +The internal UI fixture startup channel is receive-only and one-shot. Its binding +uses retained process facts and an explicit HWND-owner query, with final authority +checks and retry-retained cleanup. The scoped reader verifies HWND/PID, bounded raw-tree +ancestry and a root runtime ID pinned across captures. It preserves per-field failures +and protects password text. COM calls stay on the source owner thread. The internal +read-only managed adapter creates COM lazily during readiness and reports best-effort +UIA captures through the shared task API. Injected COM and hidden-helper tests cover +reporting and timeout retirement. Native deployment trust and all desktop +acceptance remain pending; no native UI fixture execution is claimed. + +The internal owned UI target retains its launcher and both image leases before +attestation, attempts every owner during cleanup, and retains failed cleanup for +retry. A publication lock prevents late source installation after shutdown. The +native factory only constructs owners; native deployment trust +and native acceptance remain pending. + +Host management can register a `uia_fixture` profile with empty `allowed_tools`, +`roots` and `apps`, and only `config_path`/`config_sha256` settings. It uses a fixed +isolated worker and validates deployment, profile and target pins before acquisition. +Both endpoints refuse commands. External tasks may use an empty tool scope only +without planned actions; completion criteria remain required and an empty plan +cannot prove completion. UI partial/best-effort reports remain diagnostic. +Registration and probe acquire nothing; probe reports `not_supported` and +`native_evidence=not_recorded`. The existing target API, CLI and GUI JSON editor +carry this profile. Injected and hidden-helper tests do not establish native trust. + +Host-selected in-process service adapters can use the closed `service_state` criterion: +`{"kind":"service_state","tool":"AC_service_start","state":"running"}` or STOP/stopped. +It requires the matching confirmed acceptance and a new SCM report from the same +retained owner after acceptance. A passing result reports SCM state, not atomic +completion, health or desktop noninterference. These tool names are adapter-scoped, +not global executor commands. Existing task APIs and the GUI JSON editor carry the +criterion. The host-reviewed `service` profile pins `config_path`, `config_sha256` +and an ASCII `service_key`. Its fixed worker checks the deployment's service and +operation ceiling before accepting task scope. Registration, reload and probe do +not read the deployment or access SCM; native acceptance remains pending. diff --git a/docs/process_memory_contract.md b/docs/process_memory_contract.md index 944d7a2b3..822cb9615 100644 --- a/docs/process_memory_contract.md +++ b/docs/process_memory_contract.md @@ -1,10 +1,11 @@ # Reviewed process-memory observations -This is the internal M0/M1 foundation for the background-operation plan in -[Progress.md](../Progress.md). It supplies a semantic reader and typed Windows -read/query calls tested through injected native functions. It does not supply -trusted executable attestation, runtime authorization wiring, a public memory -command, an application adapter or completed native acceptance. +This documents the background-operation work in [Progress.md](../Progress.md). +It supplies a semantic reader, typed Windows read/query calls, an owned fixture +assembly and a managed fixture profile. Verification uses injected native +functions and buffers. Native acceptance, trusted runtime dependencies and real +application integration remain incomplete. No arbitrary-address memory command +is exposed. ## Ownership and scope @@ -30,7 +31,7 @@ process. Existing desktop foreground and input-presence gates are unchanged. | Operation | Source and scope | Background requirement | Evidence and present state | |---|---|---|---| | Process/session identity | Retained OS handle, creation time, session and architecture; reviewed application attestor | Read/query/synchronize rights only; no privilege escalation | Typed calls and injected tests implemented; executable attestation and native acceptance pending | -| UI state | UIA read-only element properties for an explicitly selected application | No Invoke, SetValue or focus change | Existing UIA implementation; new background adapter integration pending | +| UI state | UIA read-only element properties for an explicitly selected application | No Invoke, SetValue or focus change | Scoped reader and internal read-only managed adapter have injected/helper coverage; native deployment trust and acceptance pending | | Browser state | Existing WebRunner managed DOM session and reviewed origins | Dedicated managed browser; no desktop input fallback | Existing browser path; this reader adds no browser access | | Fixture semantic state | Reviewed schema resolved for the retained fixture process identity | Bounded `VirtualQueryEx` / `ReadProcessMemory` provider; no writes | Typed provider and injected-call tests implemented; trusted resolver and native acceptance pending | | Application command | Each application's official API, CLI or IPC with scoped resources | Must independently prove no foreground/focus/mouse/input interference | Application selection and command adapter pending | @@ -86,7 +87,15 @@ and the SHA-256 of the image bytes (64 lowercase hex digits). `launch_attested` 1. leases the image file with a fresh `WindowsImageObserver.lease(path, ...)`: opened with `GENERIC_READ` and only `FILE_SHARE_READ`, digested from its actual bytes, with - the file facts rechecked around every chunk, and the lease kept open; + the file facts rechecked around every chunk, and the lease kept open. Before any byte + is read, `windows_image_trust.require_trusted_image` refuses the path unless every + directory from the drive root down is a real directory (no reparse point) that no + account outside SYSTEM, Administrators, TrustedInstaller and the running user may + rename, delete, re-link, re-ACL or add files to, and the leased handle's final path is + the requested path. The lease fixes the bytes; this keeps `CreateProcess`, which + resolves the path again by name, and the loader's search of the image's directory on + that same file. An observer built with an injected kernel must inject this check too, + or its lease refuses; 2. requires that digest to equal the pin, in constant time, before anything is started; 3. calls the caller's launcher, which must return a `LaunchRecord` holding the PID and birth it measured from the new process's own handle (the launcher owns the child and @@ -103,7 +112,10 @@ message, and cancellation signals propagate unchanged. What it proves: the bytes on disk, held against writers from before the launch until the observation, are the pinned ones, and the child the host started maps that same -file. It does not prove the code running now (in-memory patching, loaded DLLs), and it +file. The default fixture channels (`pinned_channel`, `pinned_uia_channel`) start the +child in the image's directory with `pinned_child_options`: a minimal environment whose +`PATH` holds only the system directories, so neither the host's working directory nor +its tokens and keys reach the fixture. It does not prove the code running now (in-memory patching, loaded DLLs), and it cannot attest a process the host did not start. `PopenLauncher(arguments, **popen_options)` is the launcher. It starts the image from an @@ -227,6 +239,12 @@ does not implement that protocol. A target without it returns `best_effort`. Repeated equal bytes alone never imply atomicity. This increment performs one attempt; an inconsistent observation fails instead of retrying with a fresh budget. +Successful sequence-checked observations retain the checked counter as `revision`. +Best-effort observations have `revision=None`. Consumers can distinguish equal +semantic values separated by a target update, instead of treating value equality +as evidence that the target has not changed. A revision does not make a subsequent +command atomic; the command adapter must compare it at its own commit boundary. + Failures have closed reasons for unsupported probes, denied scope/access, changed targets, unreadable regions, partial reads, inconsistent snapshots, exhausted budgets/deadlines, decoding and cleanup. Provider adapters should use @@ -239,6 +257,367 @@ instead of becoming ordinary failures. Live checkpoint authority errors also propagate unchanged; only failures raised inside provider/resolver/decoder calls are normalized, not the surrounding runtime authority checks. +## Managed semantic grounding + +The runtime has an internal `SemanticTarget` contract for host-selected adapters. +Every concrete semantic target must implement `cleanup()`. Retirement failures +must raise while retaining resource ownership for retry; adapters without cleanup +cannot be instantiated. The worker uses this same contract when closing after EOF +or revocation. +Task JSON and observation fields cannot opt an ordinary target into it. Existing +targets retain full-payload fingerprinting and their existing `perform` calls. + +`SemanticSnapshot` validates the exact observation schema at runtime ingress. +It preserves target identity, adapter/schema, source, semantic fields, consistency, +completeness and revision in the grounding fingerprint. Only observation ID and +capture timestamps are excluded. The runtime still expires observations after +30 seconds and rejects replaced observation IDs. Invalid, incomplete or unknown +helper fields fail before publication. Semantic values are omitted from repr. + +Grounded dispatch supplies the original snapshot and the prepared journal action +ID to `perform_grounded`. Adapters must recheck state at their commit boundary. +`SemanticReceipt` binds a successful result to that operation ID and declares +`atomic` or `non_atomic` comparison. A receipt confirms the adapter's reply, not +independent task completion or desktop noninterference. A wrong-operation receipt, +untyped reply or `AgentEffectUnknown` follows the existing uncertain journal path; +the consumed observation cannot be replayed. Unknown effects require readback. + +`MemorySemanticTarget` binds a reader to a host-selected `MemoryBinding`: target +ID, measured process identity, reviewed probe and allowed fields. It pins the ready +task specification and authorization owner (user, role and source store), and +requires the matching live managed scope for every read and +command. Read failures retain their sanitized reason; they never become empty +snapshots. Pending handle cleanup prevents further reads. Grounded dispatch checks +policy, reads again and compares provenance/state before forwarding the original +snapshot and operation ID to the separate command owner. Only that owner can +claim atomic comparison at commit. Cleanup permanently retires the target and +raises until pending reader handles are closed; repeated cleanup retries ownership. +The host must create a dedicated target/reader/command owner per resource lifecycle. +This seam has injected-provider runtime tests and is used by the fixture profile +described below. Memory failure reasons retain their type across +the owned helper channel. The worker emits only a closed reason code and fixed +message, never the memory exception text. The host requires the exact error schema +and rejects unknown reasons, extra fields and mixed event/result packets without +echoing their contents. Legacy unstructured memory errors are rejected rather than +parsed from text. This preserves read failure distinctions; an error after command +dispatch still follows the uncertain-effect journal path, not automatic replay. + +`FixtureCommands` implements the internal `AC_fixture_set_state` adapter operation +with exactly `document_id` and `job_status` arguments. It requires the host's +schema-one binding, both fixture fields, a checked memory revision and a private +launch nonce. The owned control transport receives only `compare_set`, under a +one-second exchange ceiling and the live task checkpoint. This ceiling bounds the +fixture exchange; it is not a measured service-level performance claim. +Receipts must match the operation, nonce, requested values, exact scalar types and +expected revision plus two. Unknown replies stop further commands; cleanup retains +transport ownership until closure succeeds. The transport must retire failed +streams to prevent late replies from serving later requests. The runtime never +automatically resends an unknown effect. The internal command is not registered as +a standalone public executor command; it is offered only by a fixture task. +Native launcher and attestation acceptance remain pending. Injected tests combine the actual reader, fixture buffers and +runtime completion; they do not establish native acceptance. + +`OwnedFixtureControl` wraps an already host-owned `OwnedChannel`; construction +performs no launch and transfers ownership only after challenge validation succeeds. +The fixture's optional `--rpc` mode uses correlated request IDs and exposes only +bootstrap, snapshot and compare-set operations; legacy fault-injection `set` is +unavailable over RPC. Bootstrap stores only validated private locations and nonce, +not a measured process identity. Control frames retain the fixture's 1,024-byte +limit and one-second deadline ceiling. Typed state and receipt schemas reject +unrecognized fields before returning data. Failed exchanges or malformed results +retire the channel; failed retirement retains its owner for cleanup retry. +Close can interrupt a waiting request without acquiring its lock. Hidden subprocess +tests cover this behavior without cross-process memory reads. A Windows venv +launcher can spawn a second interpreter, so the channel's launch PID and the +fixture's self-reported PID must not be assumed equal or used as attestation. + +`OwnedFixtureTarget` is an internal, unregistered assembly for the native fixture. +The host constructs it with a `FixtureImage`, an owned launcher, two fresh image +observers and a provider factory. Explicit diagnostic callers use +`start(checkpoint=...)`; managed callers may let `ready()` start it lazily. The +provider factory must return an unopened provider using the supplied launch +attestor. Task JSON cannot supply these objects. Startup parses the pinned baseline, +attests the launch, checks bootstrap identity, and binds the image guard to the +original launch hash before publishing the private semantic target. + +Managed readiness requires the exact current task, fixed target and fixture command +scope. It pins the task and owner key, including the authorization-store path, +before acquisition. Readiness admission is nonblocking and remains exclusive until +the private memory target is bound. A competing caller cannot claim a newly +published inner target. Startup callbacks use the original operation and recheck +that context before readiness succeeds. Failure after the claim retires the +resources; unrelated scope refusals do not retire an existing owner's target. + +The hidden `memory_target_helper.py` test fixture serves this path through the real +semantic worker/proxy with injected launch calls and buffers. It uses a fresh +synthetic identity per helper process, not OS attestation. Tests cover semantic +completion, typed read failures and process retirement. Semantic worker requests +pin task, owner/store provenance, target and profile kind. Dispatch, reader checkpoints, +command guards and result publication refresh the original owner's stored authority. +Any role change, including an upgrade, requires a new host-reviewed session. Missing +or damaged stores fail closed with fixed wire errors. Command guards retain the +original request checkpoint even inside a temporarily replaced operation scope. +Cleanup remains available after revocation. Trusted local and explicit storeless +owners retain the existing deferred-authorization semantics. + +These checks use real temporary user stores and injected memory. They cannot make +revocation atomic with a read or interrupt a blocked syscall. The host still owns +cancellation, live profile checks and helper retirement. + +`NativeSemanticTarget` selects the existing non-display channel route through a +fixed host-class property. Task options cannot select display routing. On Linux, +a configured owner-service binding must list the exact helper argv; policy or +service failures cannot fall back locally. Without a binding, the existing local +route remains available and carries no owner-service containment claim. Desktop +and browser proxies retain their display route. Bootstrap validation and retained +cleanup ownership use the same proxy implementation for both channel types. + +Injected routing tests do not prove Linux containment. Reviewed helper source, +imports and authority-store access under the service's separate identity and empty +environment still need provisioning. A child fixture also needs nested-grant +integration. These remain production prerequisites, with native execution paused. + +The private packaged entry is `je_auto_control.utils.agent_runtime.fixture_worker`. +Only reviewed host code supplies its `--config` absolute path and independent +`--config-sha256` digest. It accepts no launch configuration through ordinary RPC. +The schema-one JSON file has exactly these fields: + +```json +{ + "schema": 1, + "host": "reviewed-host", + "target": "fixture", + "image": "C:\\reviewed\\memory_fixture.exe", + "image_sha256": "", + "read_timeout": 1 +} +``` + +The config digest covers its exact bytes, including whitespace. The loader checks +it before following the image path, rejects duplicate or unknown fields, limits +config bytes to 16 KiB and image bytes to 64 MiB, and validates the pinned PE plan +against the existing 1 MiB observation ceiling. The read timeout must be positive +and at most 60 seconds. Executable/schema labels remain fixture/1; PID, addresses, +argv, session and challenge are not config fields. Each worker creates fresh +session and challenge values. The leased launch rechecks the image pin, so static +preparation does not replace launch-time attestation. + +`load_fixture_image()` performs static preparation only. The native factory accepts +64-bit Windows, and `OwnedFixtureTarget.ready()` remains the process-acquisition +boundary. EOF or a rejected owner/task before readiness starts no fixture. The +entry uses the existing worker protocol and guarded cleanup. Reads are bounded in +bytes, not wall time; opening a replaced special file can block before the regular +file check. The host-owned helper deadline and retirement remain the interruption +boundary. Constructing the worker registers no profile by itself. Config and image pins do not establish +interpreter, imported-source or DLL trust, and native execution remains paused. + +The assembly selects a read budget of the complete image plan plus the fixture's +72 bytes, capped at 1 MiB, with at most 1,024 region checks. The host chooses a +finite read timeout of at most 60 seconds (default 1 second). Startup image +measurement and each bootstrap exchange separately retain their 1-second bounds; +there is no claim of a single wall-time deadline for the whole startup sequence. +The runtime integration test explicitly selects a 5-second read budget to include +policy checkpoints. This is a ceiling, not a measured performance guarantee. + +Cleanup retires the launcher first to interrupt IPC, tries every resource even +when one fails, and retains failed owners for later cleanup calls. Retirement +prevents late startup publication. The public wrapper never exposes its private +semantic target, and runtime completion uses the same cleanup path. Interruption +signals take precedence over ordinary cleanup failures after all owners are tried. +Injected tests prove the assembly contract; DLL trust, native loaded-image +compatibility and desktop noninterference remain unverified. No profile or public +command registration is enabled by this assembly. + +`OwnedChannelLauncher` adapts the existing `PopenLauncher` to the same owned IPC +process. `launch_attested` can lease the pinned executable, start the channel, +measure PID/birth from its retained launch handle and observe the same image file. +The one private process-handle seam is host code only. `bind_control` then requires +bootstrap PID and pointer width to match that measured identity; a launcher shim's +descendant is refused, never silently substituted. This does not prove loaded-code +integrity, trusted interpreter dependencies or source delivery. Keep it unregistered +until those requirements and native acceptance are satisfied. +The caller retains launcher, lease and observer owners during attestation. An +attestation failure after launch leaves the channel with its launcher for explicit +cleanup; failed lease or process retirement remains retryable. Launcher close does +not close the separately owned image leases. Tests inject native calls and channels; +this assembly has not launched a native attested fixture. + +`NativeSemanticTarget` carries the same contract over the existing owned helper +channel. Trusted host code supplies the reviewed helper argv and an explicit +resource lock. The helper must advertise semantic protocol version one before +configuration. Both sides refuse desktop input, including cleanup. Worker cleanup +also denies executor commands, whether requested over IPC or triggered by EOF. +The host accepts only an exact boolean cleanup acknowledgement before retiring a +live helper; an unconfirmed cleanup retains ownership for retry. + +The worker rechecks task tool scope and the closed request schema before calling +the adapter. Existing host checkpoints enforce cancellation and deadlines while +waiting for replies. `AgentEffectUnknown` and `AgentObservationStale` preserve +their types across the shared channel. A blocked fixture command has been +cancelled after entry and its actual helper process retired in a headless test. + +`test/fixtures/semantic_helper.py` tests this IPC path with an owned counter, not +cross-process memory or desktop input. The dedicated fixture profile uses the +same semantic protocol; application attestation and reader-owning native adapter +verification remain required before claiming native readiness. + +## Semantic completion + +### Managed fixture profile + +The existing `manage_agent_target` / `AC_agent_target`, CLI target operation and +GUI Host targets JSON editor accept a dedicated `fixture` kind. Registration +requires `manage_hosts` and is inert. No fixture process starts until an authorized +task reaches managed readiness. An example profile shape is: + +```json +{ + "name": "fixture", + "kind": "fixture", + "allowed_tools": ["AC_fixture_set_state"], + "roots": [], + "apps": [], + "settings": { + "config_path": "C:\\reviewed\\fixture.json", + "config_sha256": "" + } +} +``` + +The profile name must match the deployment's target. Only these two settings are +accepted. Tasks cannot supply them, choose a helper interpreter or argv, grant +filesystem roots or desktop applications, or expand the fixed tool set. The proxy +uses the current interpreter with `-I -u -m` and the packaged fixture worker, so +that interpreter must have the reviewed package installed. Isolation flags are +not source attestation. + +The host verifies a closed bootstrap extension containing fixture contract version +one, the loaded config digest and target ID. Before changing its scope, the worker +requires the matching fixture profile, deployment path/digest and host-issued task +profile pin. Omitting the profile is refused. The generic semantic worker is unchanged. +Immutable profile identity, persistence, live disablement and explicit resume use +the existing runtime controls. The adapter's Windows x64 gate runs before helper +acquisition. The GUI Apply target action passes the same profile through the shared +service; no separate GUI authority exists. + +Passive listings retain `readiness=not_probed` and `native_evidence=not_recorded`. +The explicit diagnostic `probe` uses a separate non-display helper with a 15-second +bootstrap deadline and a 10-second artifact inspection deadline. It validates the +pinned configuration and PE bytes without constructing a native target or executing +the fixture. Successful reports contain `status=static_artifacts_ready`, bounded +`checked_bytes`, `fixture_execution=not_run` and `native_evidence=not_recorded`. +The private worker's `--inspect` mode accepts only empty bootstrap/inspection requests; +it refuses task configuration, desktop events and execution. Static inspection is +portable; it does not bypass the Windows x64 gate for actual fixture acquisition. + +At most two inspections may own capacity in one host process, with one per profile +per runtime. Host-management authority is refreshed during request polling and before +publication. Timeouts and cancellation retire the helper. Failed retirement retains +its owner and capacity for runtime-close retries. Shutdown seals new admissions and +retains the runtime database lock while construction or retirement is unfinished, +including when no task lease exists. Passive listing never starts this helper. +The GUI target-operation selector with Apply target and the headless target-control +API use this same path. +Neither this diagnostic nor the injected roundtrip/disable tests prove native +availability or loaded-code trust. Native execution remains paused. + +### Completion evidence + +Host-selected semantic adapters can declare an ordered `observation_sources` +contract and a nonempty `observation_fields` tuple of at most 64 unique field names. +Every source must corroborate every declared field. The first declared source is +the command's primary snapshot. Such adapters return +an `ObservationReport` through the existing observation API; task JSON cannot enable +this capability. The native proxy requires the exact source contract and report +version 3 and sorted `semantic_fields` in the worker bootstrap. Versions 1 and 2 +are rejected. A generic semantic proxy refuses that extension. + +The report requires `field_scope`; `from_dict` requires host `fields` as well as +`required` sources. The wire scope must match the host scope exactly, and source +fields outside that scope are rejected. Even a field omitted by every source +remains missing; if every source fails, all required fields are missing. + +Reports retain up to four sources, each tagged as `snapshot`, `partial` or `failure`. +A `PartialObservation` contains validated `CaptureMetadata`, successful scalar +fields and fixed per-field failures. Its values and failures must be disjoint and +together cover the host field scope. The field failure reasons are `not_found`, +`ambiguous`, `protected`, `unsupported`, `unreadable` and `budget_exceeded`. +Valid empty strings, false booleans and null values remain values, never substitutes +for failed reads. Reports preserve capture intervals, missing field names and typed +value conflicts. All successful and partial captures +must refer to the same target lifetime. The host adapter must normalize its reviewed +fields into the same schema and revision domain before declaring this contract. +Equal values with different revisions conflict; boolean and integer values do not +compare equal. Agreement without checked revisions remains `unverified`. Partial, +conflicting and unverified reports remain visible but cannot ground commands. +Authority, cancellation, target-change and cleanup errors are not reportable as +ordinary missing-source reasons and must propagate from acquisition. + +Action fingerprints retain every source's state and provenance. The complete report +crosses the helper boundary unchanged before the worker converts it to the primary +command snapshot. The journal retains the full source report and original `semantic_fields`. +Completion parses both reports against that saved scope, so later adapter changes +cannot shrink the requirement. Completion requires fresh compatible evidence from every original source; disagreement or missing +sources produces an unknown result. The complete-only `SemanticSnapshot` wire schema +is unchanged and lives in `semantic_snapshot.py`, re-exported by `semantic_target.py`. + +The managed fixture now captures `process_memory` and `fixture_protocol` sources. +The IPC source uses the retained launch-bound control, stamps identity from the +measured memory binding and accepts only the fixed snapshot fields and sequence. +Capture and precommit readback share one owner lock; cleanup can interrupt IPC +without acquiring that lock. Before `compare_set`, fresh complete agreement must +still match the original memory snapshot. The fixture remains responsible for its +atomic sequence comparison at commit. + +Safe memory read failures retain the IPC snapshot in a partial report. Unsupported +memory observations can indicate failed code attestation and therefore propagate, +as do scope, lifetime and cleanup errors. IPC protocol/transport failures are not +downgraded to missing sources; their retirement failures remain reachable. Checkpoints +revalidate the captured operation and owner before and after each source boundary. + +Tests use injected native calls/buffers, the actual reader and real hidden Python +helper IPC. The scoped UIA reader described below preserves explicit field failures +and best-effort capture metadata. Native UI deployment trust, DOM source +identity and revision normalization remain pending. Existing foreground desktop or +legacy DOM dictionaries are not converted automatically. This work is not native +observation or background-application acceptance. + +A `semantic` success criterion compares fresh completion-time observations with +the recorded target witness for a named command. For the test-owned counter: + +```json +{"kind": "semantic", "tool": "AC_increment", "fields": {"value": 1}} +``` + +The command must already be in the task's allowed tools. The criterion grants no +additional fields, reader, native target or command. The Agent Tasks scope JSON +editor and its Submit action preserve this condition through the shared task API. +The host must explicitly register a fixture profile; no fixture is enabled by default. + +Before semantic dispatch, the journal stores the validated original snapshot. +Only a host-selected `SemanticTarget` supplies this witness. Completion uses the +last effective attempt for that command; an uncertain attempt stays unknown, +while attempts proven to have no effect do not discard earlier completed work. +Every semantic observation must use the host's `time.perf_counter()` clock domain +and have its entire capture interval inside the current runtime read request. +(`time.monotonic()` ticks every 15.6 ms on Windows before Python 3.13, too coarse +to order a capture against its acceptance.) +The runtime rejects cached pre-dispatch reads and future timestamps before +publication or verification. A helper on another clock domain cannot use this +contract without a separately reviewed clock/proof protocol. + +The current snapshot must match target identity, adapter, schema and source, have +a checked revision at least as new as the witness, and use a different observation +ID with a capture interval starting after the witness ended. Best-effort snapshots, +changed identities, missing fields and absent witnesses yield `unknown`. + +Expected fields are bounded scalars compared without coercion. A valid readback +with different values yields `failed`, even when the command returned success. +An exact match yields `passed`; other criteria and unresolved receipts still +prevent task success. `result_equals` continues to inspect the prior result only. +IPC fixture tests cover lying success replies and helper restart; these checks do +not establish native memory acceptance or desktop noninterference. + ## Cleanup ownership Each observation opens and closes its own handle. A failed close remains owned @@ -269,8 +648,59 @@ reuse, permission denial, cancellation and failed handle retirement. Compare exa semantic values to fixture-owned expected values. Independently observe foreground window, focus, mouse and desktop-input events to establish noninterference. +### Native artifact preparation + +The separate [native fixture source](../test/fixtures/native_memory/README.md) is +an x64 C implementation with static CRT. Its builder compiles a captured source +copy, rejects ambient compiler options, checks unchanged source, and inventories +the image without executing it. Current direct imports are `bcrypt.dll` and +`kernel32.dll`; source, image and build-tool hashes are recorded per build. +This removes the Python interpreter/source chain from this candidate artifact, +but does not establish loaded-image or OS dependency trust. Protocol behavior, +foreground noninterference and native fault cases remain unverified. + +`plan_pinned_image` now derives a factory-only code plan from the full pinned +baseline SHA-256. The supported format is bounded x64 PE32+ with all executable +sections enumerated. The parser rejects writable executable sections, overlapping +layouts, invalid entry points, unsupported relocation types, and relocations or +import-address tables that touch protected bytes. Headers and complete aligned +executable spans are included; callers cannot construct or replace a plan to omit +coverage. File and image bounds are 64 MiB, and protected reads are capped at 1 MiB. + +`guard_probe_image` requires the exact `OwnedLaunch.image_sha256` as well as matching +application/version labels. The caller must explicitly supply sufficient probe +limits; the guard never raises those limits. Every observation checks the header +and code hashes through the same retained, bounded resolver view as semantic data, +then rechecks module base/size before and after the underlying resolver. A mismatch +publishes no semantic values. Budget, cancellation and cleanup behavior stay with +the reader. No raw executable bytes enter observations. + +Loaded addresses differ from file offsets, and relocations may change bytes; see +Microsoft's [PE format specification](https://learn.microsoft.com/en-us/windows/win32/debug/pe-format). +This implementation rejects relocation of protected bytes instead of normalizing +it. Padding to section alignment is conservatively projected as zero after raw +data; its compatibility still requires native acceptance. A short read or padding +mismatch refuses the image rather than dropping coverage. Matching these ranges +is not atomic execution integrity, live page-protection evidence, DLL/source trust, +or proof that no other executable mappings exist. x86/ARM64 image plans remain +unsupported. Tests use synthetic mappings and static build-artifact inspection. + ### Owned fixture preparation +`fixture_probe.py` supplies the internal schema-one adapter. `FixtureBinding` +copies validated bootstrap locations and the parent challenge into an immutable +binding. It rejects unknown protocol/schema versions, incorrect structure sizes, +invalid pointer widths, overflowing ranges and overlapping buffers before reading. +Each resolution checks the retained process PID and pointer width, then reads and +compares the header challenge and locations. This binding is not an attestor. + +Its probe accepts only application version `1` and the separately attested +executable ID. The 72-byte ceiling covers the 40-byte header, 16-byte payload and +two eight-byte sequence reads. The decoder requires exactly 16 bytes and canonical +zero-padded `ready`, `busy` or `done` states, even for a query that selects only the +document ID. Unknown fields and mixed generations publish no semantic values. +Injected-provider tests cover this adapter; native acceptance remains paused. + `test/fixtures/process_memory_fixture.py` owns fixed payload and sequence buffers for its process lifetime. Its bounded JSON-lines protocol uses inherited stdin and stdout pipes. Bootstrap and control replies have distinct message kinds on the @@ -279,6 +709,20 @@ Only the fixture changes its buffers. The parent can request expected semantic state, a validated state change or shutdown; it cannot request arbitrary memory reads or writes. +The additive `compare_set` command requires an operation ID, launch nonce, expected +even sequence, document ID and job status. The serial server compares the sequence +and publishes the change in one command. Its receipt states `atomic` only relative +to that server's commands. This is not a guarantee against arbitrary memory writes. +Exact retries return the original receipt, including after later state changes; +conflicting reuse of an ID is refused. Launch-bound refusals are also retained. +A 128-entry fixture ledger never evicts: new IDs are refused when full, while old +receipts remain queryable. This is a fixture resource cap, not a performance target. +The legacy `set` command remains for fault injection; runtime adapters must use +`compare_set`. A restart changes the nonce and refuses old requests. Receipts are +not durable across restart, do not attest executable identity, and never replace +independent state readback. Hidden IPC tests cover replay and fresh snapshots; +native memory and desktop noninterference acceptance remain paused. + Bootstrap reports PID, pointer width, buffer locations, fixture source digest and a fresh launch nonce as unverified self-reports. The nonce is not OS process birth, and the source digest is not measured executable identity. No reviewed probe may @@ -304,7 +748,331 @@ cross-process memory readback, ASLR resolution, native publication guarantees or desktop noninterference. Shared-memory mappings were rejected because parent-side mapping reads would bypass the future process-memory provider. -No native acceptance command is supplied or executed by this increment. Native -execution stays paused under `Progress.md`; native verification of the typed calls, +The native fixture README documents a static-by-default smoke CLI with an explicit +execution option. Its external image pin and source inventory checks do not establish +dependency trust. Injected smoke tests cover initial state, receipts, fresh readback, +managed completion and retryable cleanup, without running the native artifact. +The C fixture can also prepare fixed split/guard/no-access/decommitted payload +layouts, with bootstrap as their only operation. Source review and compilation do +not validate native page behavior. The diagnostic page runner binds private payload +locations through the checked bootstrap and observes the actual reader's existing +queries. It requires exact adjacent region metadata, a successful eight-byte prefix +read before the second-page query, and one handle for the whole observation. +Changed mappings or evidence from multiple observations cannot pass. Each case +claims and consumes a fresh observation scope; earlier successful traces cannot +be replayed against another target. Split mode +requires complete initial semantic readback; refusal modes require both the expected +reader reason and matching payload evidence, without reading the protected half. +These cases request only read-only IPC snapshots, never state mutations, and do not +claim runtime completion or full native +fault coverage. Only injected tests have exercised the runner. +Native execution stays paused under `Progress.md`; native verification of the typed calls, trusted bootstrap matching, page-protection fault injection, host probe configuration, runtime lifecycle/policy integration and application coverage remain required for M1/M3. + + +### Owned UI fixture preparation + +`test/fixtures/native_memory/build_fixture.py --kind uia` builds a separate hidden +window artifact with fixed read-only controls for future scoped UIA tests. Its +schema-2 manifest and kernel32/user32 import allowlist are distinct from the memory +fixture. The default memory build retains its existing schema and dependencies. +The UI artifact has only a correlated one-line private bootstrap and EOF shutdown, +no state mutation API. `OwnedUiaLauncher` uses a receive-only `OwnedUiaChannel`, +which inherits hidden process-tree ownership and bounded startup waits. Its closed +1024-byte envelope rejects duplicates, extra fields and repeated/ended streams. +No command or input acknowledgment can be sent through this channel. + +`OwnedProcessChannel` now owns the common launch/retirement lifecycle used by both +fixture launchers. `PopenLauncher.facts()` measures the original retained launch +handle again; bootstrap PID never selects a new process to open. Before publishing +`BoundUiaWindow`, the owner validates the attestor and window PID on both sides of +a checkpoint, then checks current authority again and fences retirement. Binding +verification repeats these checks and retires on failure. File leases remain owned +by the separate `OwnedLaunch`; callers must retain and close both owners. + +The binding proves only that this HWND currently belongs to the retained process. +`ScopedUiaSource` additionally pins the root runtime ID across captures, checks the +original HWND and PID, and verifies raw-tree ancestry before and after property +reads. Host code supplies exact automation IDs and chooses only `name`, `value` or +`enabled`. Traversal and ancestry walks have finite budgets. Text reads require +password checks before and after reading; an unavailable protection property is +reported as protected. COM calls remain on the source's owning thread. +Runtime IDs are opaque and may be reused. Pinning and repeated checks detect +observed replacement; they do not establish atomic state or permanent window identity. + +`UiaObservationTarget` is an internal read-only managed adapter. It pins the original +task and owner, creates the optional native COM backend during managed readiness, +and publishes source `uia` through report version 3. Per-field failures retain valid +fields from the same capture. A complete UIA capture still has `revision=None` and +`consistency=best_effort`, so it cannot authorize actions or semantic completion. +The adapter rejects commands and grants no Invoke, SetValue, focus or input rights. +During a capture every COM call re-validates the pinned task and owner, while the full +runtime checkpoint (cancellation, durable budget, live authority) runs at most every +50 ms; the unthrottled checkpoint after the capture runs before anything is published. + +`owned_uia_target` retains the launcher, pre-launch lease and post-launch observer +before acquisition. `UiaFixtureImage` requires the separate `uia-fixture` version-1 +identity, an absolute Windows path and bounded image bytes. Its `attestation_timeout` +covers image attestation; window bootstrap has a separate five-second timeout. +The enclosing helper must bound total readiness and blocking COM work. +The managed adapter owns readiness and terminal state; no second lifecycle is +introduced. Cleanup attempts child retirement first and then both image owners, +retaining failures for retry. The publication lock contains no native work and +prevents source installation after cleanup. `native_uia_target` constructs inert +owners and does not launch a child or create COM until managed readiness. + +The helper owner must bound blocking COM work and retain cleanup ownership. +Injected COM tests cover scoped reads, field failures and root replacement; hidden +Python helpers cover managed reporting and timeout retirement. Native deployment +trust remains pending. No native UI executable was run, and native UIA property +exposure and desktop noninterference remain unverified. The UI artifact manifest +stays schema 2; it is independent of observation report version 3. See the fixture +README for the field table and startup protocol. + +The typed owner query follows Microsoft's +[GetWindowThreadProcessId](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowthreadprocessid) +contract: both the returned thread ID and output PID must be nonzero. + + +### Fixed read-only UI worker deployment + +The host-managed `uia_fixture` profile has empty `allowed_tools`, `roots` and +`apps`. Its settings contain only an absolute `config_path` and the independently +verified `config_sha256` of that file. Profile registration, reload and probe do +not read an image or launch a helper. Probe currently reports `not_supported` +with `native_evidence=not_recorded`; it is not the memory fixture static inspector. + +The UI configuration is a closed JSON object with exactly these fields: + +| Field | Required value | +|---|---| +| `schema` | Integer `1`, excluding booleans | +| `kind` | `uia_fixture` | +| `host`, `target` | Bounded identifiers; target must match the profile name | +| `image` | Absolute Windows path to the host-reviewed UI fixture | +| `image_sha256` | Independently reviewed lowercase SHA-256 digest | +| `max_image_bytes` | Integer from 1 through 67,108,864 | +| `attestation_timeout` | Number greater than zero and at most 60 seconds | + +The shared pinned loader bounds configuration to 16 KiB and rejects duplicate +keys. It hashes the exact configuration bytes before following the image path. +The UI loader bounds and hashes image bytes before constructing owners. The +original launch still leases and rechecks the image; startup self-reports never +select a new PID. Memory deployment and UI deployment schemas remain distinct. + +The proxy uses the fixed isolated module `je_auto_control.utils.agent_runtime.uia_worker`. +Its bootstrap must match report version 3, source `uia`, the fixed UI fields and +an exact `uia_fixture` object containing integer `version=1`, configuration SHA +and target. The worker validates platform, deployment reference and original +profile/target pin before mutating scope or acquiring resources. Both worker +and proxy reject effect requests, including direct grounded calls. Existing +host management, CLI and GUI JSON routes carry the profile without new commands. + +An empty task tool scope is accepted only in external mode with no planned +actions. Existing completion criteria remain mandatory and `actions_complete` +refuses empty plans. Partial and best-effort UI reports cannot prove semantic +completion. These tasks expose observations for review; they do not imply a +successful effect or grant later input authority. Task options cannot replace +host deployment settings. Disabling the profile revokes work and retires the +original helper under the existing runtime ownership rules. + +Tests use injected image/window/COM functions and real hidden Python helper IPC. +The isolated packaged worker help command was checked without native acquisition. +No UI profile was registered against a real native deployment. Trusted helper +source/interpreter/DLL delivery, actual UIA behavior and desktop noninterference +remain pending in Progress.md. + +## Internal service-status prerequisite + +`WindowsServiceStatusReader` in `agent_runtime/windows_service.py` accepts one +host-selected service key name. Construction validates and binds functions but +opens no handles. Its first `read(timeout=..., checkpoint=...)` opens the local +active SCM database with `SC_MANAGER_CONNECT`, then the named service with +`SERVICE_QUERY_STATUS`. It retains both handles until `close()`. Callers must +retain the reader before reading and through any failed cleanup retry. + +Only Win32 own-process/shared-process services, optionally interactive, are +accepted. The reader has no enumeration, remote host, process access, start, +stop, configuration or elevation methods. This is an internal prerequisite, +not a registered profile, executor command, public API or supported os.service +operation. The managed helper, report adapter and operation/readback cycle +remain in `Progress.md`. + +The nine-DWORD status is the latest SCM report, marked `best_effort`. Its progress +checkpoint is not a revision. PID is diagnostic only and omitted for stopped, +start-pending and stop-pending states, or when zero. Accepted controls do not +grant operation permission. Query success does not establish an atomic snapshot, +actual instantaneous service state or process identity. + +Every admitted acquisition/query/checkpoint failure retires the reader. Close +sets retirement before waiting for the serialized native call, attempts service +then SCM cleanup, and retains failed handles for retry. Nested reads are refused; +checkpoint-triggered close is supported. An admission timeout does not retire +another read already in progress. Deadlines reject late output but cannot +interrupt native calls or cleanup; enclosing helper retirement remains necessary. +Injected tests establish these contracts without calling actual services. + +Official contracts are documented in +[QueryServiceStatusEx](https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-queryservicestatusex), +[OpenSCManagerW](https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-openscmanagerw), +[OpenServiceW](https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-openservicew) +and [SERVICE_STATUS_PROCESS](https://learn.microsoft.com/en-us/windows/win32/api/winsvc/ns-winsvc-service_status_process). + +### Internal control and independent readback + +`WindowsServiceController` composes the same private session owner as the reader. +Its host-supplied immutable allowed-operation set selects START and/or STOP rights +in addition to QUERY_STATUS. The reader still grants only query rights and does +not bind control functions. Both façades keep service handles private. + +`perform(operation, expected=before, operation_id=journal_id, timeout=1, +checkpoint=checkpoint)` rereads through the retained handle and rejects changed +status before dispatch. START requires STOPPED. STOP requires RUNNING or PAUSED +and a reported STOP control bit. This comparison is non-atomic. Start has no +arguments; stop sends only SERVICE_CONTROL_STOP. The returned control status is +discarded because it is not independent readback. + +Before entering the native call, the session records an uncertain attempt in a +bounded, non-evicting ledger. A successful return and final checkpoint produce +an acceptance receipt, never proof of completion. A repeat of the same ID and +request returns that original receipt without dispatch. A conflicting ID reuse +is refused. Native failures, including start error 1053, cannot establish absence +of effects. Uncertain attempts prevent further control in that owner; fresh +reads remain diagnostic and cannot clear uncertainty. +The ledger belongs to this retained session, not durable storage. A helper restart +cannot reconstruct accepted requests; the runtime must retain its journal and +refuse automatic replay across that boundary. + +An accepted start blocks new controls until a separate public read reports +RUNNING. An accepted stop similarly waits for STOPPED. The preflight read inside +another perform cannot clear this fence. Thus stale SCM status cannot by itself +cause automatic repeated controls. Reaching the ledger limit refuses another +operation before any effect. The session does not poll, retry, stop dependencies, +change service configuration or elevate privileges. + +This implementation remains internal. A future managed profile must review +configured dependencies because SCM can start them with the selected service. +It must also establish operation authority, helper retirement, truthful service +readback criteria and desktop noninterference. Existing best-effort observation +and semantic completion gates are unchanged. Native services have not been run. + +See [StartServiceW](https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-startservicew), +[ControlService](https://learn.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-controlservice) +and the [service database](https://learn.microsoft.com/en-us/windows/win32/services/database-of-installed-services). + +### Managed service evidence + +The in-process managed adapter has a separate service dispatch contract. It does +not implement `SemanticTarget` or convert SCM progress into a revision. A service +observation carries fixed target/configuration/scope identifiers, a retained-owner +binding, a unique observation ID, a capture interval and strict status fields. +The binding identifies this owner lifetime, not a Windows service incarnation or +process identity. The outer dispatcher rejects captures outside its current read +request and fingerprints state without capture IDs or timestamps. + +Readiness pins the original task specification and authorization provenance. +Operations recheck that scope before and after checkpoints. Only the host's +allowed `AC_service_start` and `AC_service_stop` operations with empty arguments +can reach the retained controller. Cleanup retires publication before closing the +controller, and failed cleanup remains owned for retry. + +The closed completion clauses are: + +```json +{"kind": "service_state", "tool": "AC_service_start", "state": "running"} +``` + +```json +{"kind": "service_state", "tool": "AC_service_stop", "state": "stopped"} +``` + +Only these tool/state pairs are valid. The criterion must refer to a tool in the +task scope and cannot be used as a resume precondition. A confirmed journal +attempt must match the acceptance's operation ID and operation, with identical +target, configuration, scope and binding across the original observation, +acceptance and new readback. The new capture must begin after acceptance and use +a new observation ID. Cached acceptance retains its original timestamp. + +A fresh report with another state fails the condition. Missing acceptance, +unknown effects, old captures, mismatched provenance or another owner binding +produce unknown. Passing means the latest SCM query after acceptance reported +the requested state. It does not prove health, causation, atomic completion or +desktop noninterference. Existing semantic revision and multi-source report +gates remain unchanged. + +Tests use the real managed runtime and injected service calls. Owned helper IPC +and service locking are described below. Dependency review, trusted production +deployment and native acceptance remain pending. + +### Owned service helper IPC + +The service proxy uses a host-selected helper argv and the existing owned channel +with display acquisition disabled. Bootstrap binds version, target, configuration, +service scope and retained-owner binding before observations or effects are +accepted. Every report and acceptance must match that binding. A replacement +helper cannot reuse the earlier owner's evidence. Service commands use a separate +`perform_service` message; ordinary `perform` and semantic `perform_grounded` +cannot dispatch them. + +The worker shares background request and retirement guards with semantic targets, +while retaining separate service schemas. Private service configuration accepts only the +fixed task spec and owner. It rejects profile, presence and extra fields before +changing worker state, and pins the original spec and authorization-store source. +Request checkpoints refresh that authority. Request, cleanup and EOF retirement +all refuse desktop input and new cleanup commands. Cleanup accepts only empty +key/button collections and retains failed ownership until retirement succeeds. + +Service query errors cross IPC as fixed `ServiceFailure` codes. Unknown reasons, +mixed error formats, extra fields and custom error text are rejected without +echoing their contents. Error envelopes are checked before input events. + +For this helper version, service keys must be printable ASCII, at most 256 +characters, and contain no slash, backslash or NUL. Case aliases share one scope +and resource path; whitespace is preserved. The resource key excludes target +name, configuration digest and database path. Two owners using the same lock +root therefore contend for the same service, even with different task/profile +names. The default root is the current user's `.je_auto_control/service_ownership`. +Construction computes paths without launching a helper or acquiring a service. + +This is coordination between framework owners using that root. Unicode key +canonicalization, coordination across Windows users and external SCM clients +are not provided. The lower-level SCM reader's Unicode name support is unchanged. +Hidden Python helper tests inject service calls and check actual child retirement; +they do not establish native SCM compatibility or desktop noninterference. +### Pinned service profiles + +A host-reviewed `service` profile accepts exactly `config_path`, `config_sha256` +and `service_key` settings. The ASCII key determines the same-service lock before +helper launch. Registration, reload and probe do not open the deployment file, +start a helper or access SCM. A missing deployment therefore does not prevent +reopening the runtime to manage unrelated targets, including when the service +profile is disabled. Probe reports `not_supported` and `native_evidence=not_recorded`. + +The fixed worker loads at most 16 KiB of raw configuration and checks its pinned +SHA-256 before parsing the duplicate-free, closed object: + +```json +{"schema":1,"kind":"service","target":"reviewed-service","service_key":"ExampleService","operations":["start","stop"]} +``` + +Operations must be a nonempty unique list drawn from `start` and `stop`. The +profile may narrow that ceiling through `allowed_tools`; tasks may narrow it +again. Neither grants filesystem roots, desktop apps, arbitrary helper commands, +remote SCM connections or credentials. The service key in the profile must match +the loaded key's canonical scope. Case aliases match; whitespace is preserved. +The deployment digest binds configuration bytes; the profile digest binds the +host's task policy. They are separate identities. + +Pinned-worker configuration requires exactly `spec`, `owner` and `profile`. +It validates deployment identity, operation ceilings, platform and the task's +profile digest before delegating the unchanged spec and owner to the private +worker contract. The full original task pin prevents later profile substitution. +Private helpers still reject profile injection. Bootstrap and readback continue +to require the same retained-owner binding; restarting cannot confirm an old +command using a new owner. + +The profile does not attest a service executable, its dependencies or its desktop +behavior. START can activate configured dependencies. No profile is registered on +a real host by this change, and trusted interpreter/package delivery, dependency +review and native background acceptance remain outstanding. diff --git a/docs/source/Eng/doc/ai_agents/ai_agents_doc.rst b/docs/source/Eng/doc/ai_agents/ai_agents_doc.rst index 5f92950ab..ce13e511e 100644 --- a/docs/source/Eng/doc/ai_agents/ai_agents_doc.rst +++ b/docs/source/Eng/doc/ai_agents/ai_agents_doc.rst @@ -1,6 +1,18 @@ AI agents and computer use =========================== +Host-selected semantic targets accept a success criterion such as +``{"kind": "semantic", "tool": "AC_increment", "fields": {"value": 1}}`` +for the test-owned counter. The command must already be allowed by the task. +Completion reads fresh state and matches the original recorded target identity, +adapter, schema and source before comparing fields without type coercion. +The complete capture interval must fall inside the current read request using +the same host monotonic clock. Cached observations are rejected; changed identity, +missing fields and uncertain effects cannot prove success. +The Agent Tasks scope JSON editor preserves this criterion through Submit. +This adds no memory permission or native target registration. Native memory +adapter integration and acceptance remain tracked in Progress.md. + Transfer management now shares ``manage_agent_transfer(operation, request)``, ``AC_agent_transfer``, ``ac_agent_transfer``, authenticated ``POST /agent/transfer``, and Script Builder metadata. The CLI uses ``agent-task transfer --operation review_export --request request.json``. Review returns an approval @@ -491,7 +503,7 @@ Managed workflow waits (workflow_wait / AC_workflow_wait) poll only exact scoped AgentHumanReview identifies an unsaved-content or unknown-dialog gate. It persists waiting_user and retires input ownership, including for external observe requests; explicit resume still rechecks the gate. Windows detection uses native dialog/disabled-owner evidence and known English/Chinese/Japanese unsaved labels. Workspace tasks also pause for leading/trailing asterisks in document titles; a window entry may supply unsaved_selector and unsaved_value for an application-specific indicator before layout changes. These checks do not infer every application's dirty state. Recognized standard file pickers use a context-local driver on the existing AC_handle_file_dialog executor: exact unique title, same PID, confirmed foreground and canonical rooted absolute paths. UIA control patterns must belong to the actual owned root window, even when another window shares its PID. All behavior has fake-native/loopback coverage; actual platform acceptance remains unverified. -Host-reviewed targets use AgentTargetProfile and manage_agent_target (AC_agent_target; register/get/disable/enable/probe). Names and configuration are immutable; desktop/file/browser adapters are currently supported; unimplemented kinds are rejected and optional browser helper_python is host-reviewed. Tasks pin the host profile digest and cannot expand its tools, applications, roots or network origins. Availability persists across restart and is checked at dispatch; disabling requests pause/cleanup, while enabling requires explicit task resume. list_agent_targets / AC_agent_target_list / CLI agent-task targets expose passive metadata with readiness=not_probed and native_evidence=not_recorded. Full configuration requires manage_hosts; CLI agent-task target and the GUI Host targets page use the same service. Live anonymous MCP tool sessions have operator authority across direct and legacy wrapper calls; MCP host management requires an authenticated administrator. Trusted direct Python callers remain unchanged. Browser automation belongs to WebRunner (je_web_runner), with D:/Codes/WebRunner as the development source; browser profiles use the managed je_web_runner SDK contract, and dependency probes do not establish native readiness. +Host-reviewed targets use AgentTargetProfile and manage_agent_target (AC_agent_target; register/get/disable/enable/probe). Names and configuration are immutable; desktop/file/browser/fixture adapters are configured; unimplemented kinds are rejected and optional browser helper_python is host-reviewed. Tasks pin the host profile digest and cannot expand its tools, applications, roots or network origins. Availability persists across restart and is checked at dispatch; disabling requests pause/cleanup, while enabling requires explicit task resume. list_agent_targets / AC_agent_target_list / CLI agent-task targets expose passive metadata with readiness=not_probed and native_evidence=not_recorded. Full configuration requires manage_hosts; CLI agent-task target and the GUI Host targets page use the same service. Live anonymous MCP tool sessions have operator authority across direct and legacy wrapper calls; MCP host management requires an authenticated administrator. Trusted direct Python callers remain unchanged. Fixture profiles accept only config_path/config_sha256 and AC_fixture_set_state, with no roots or applications. They use the fixed isolated packaged worker and require matching bootstrap/configure deployment bindings. Registration remains inert. Explicit fixture probes inspect pinned static artifacts in a separate background helper with bootstrap/inspection deadlines, live management checks and retry-retained shutdown ownership. Success reports static_artifacts_ready, fixture_execution=not_run and native_evidence=not_recorded; it does not attest loaded code. Native fixture execution remains paused. Browser automation belongs to WebRunner (je_web_runner), with D:/Codes/WebRunner as the development source; browser profiles use the managed je_web_runner SDK contract, and dependency probes do not establish native readiness. Existing browser automation, including open_path(URL) and AC_open_path, delegates to WebRunner (Python package je_web_runner). URL plans now report backend=je_web_runner; callers inspecting the previous webbrowser descriptor should use the new value. Signatures and local-file opening stay compatible. URL execution requires the configured WebRunner project and propagates WebRunnerBridgeError when unavailable, without opening an OS browser as a fallback. The development source is D:/Codes/WebRunner. Planning and injected-opener tests remain usable without that package; browser protocol support is determined by WebRunner and its selected browser. Existing dedicated browser GUI/MCP/AC paths and recorded WR_* actions share the same bridge. @@ -1199,3 +1211,68 @@ Installed dashboard resources Installed wheel and source distributions include the REST Dashboard and Swagger HTML, CSS and JavaScript resources. The same localhost REST routes and authentication rules apply to an installed package; serving static pages grants no task or desktop input authority. + +Host-selected semantic adapters may declare a fixed multi-source observation contract. Existing observe calls preserve partial/conflicting reports; actions and completion require fresh complete agreement from every source. Helper bootstrap pins the source contract and the full report crosses IPC before conversion to a command snapshot. The fixture now combines reviewed memory reads and its retained read-only IPC snapshot under one capture/commit lock, while cleanup can interrupt IPC. Injected-reader and hidden-helper tests cover source disagreement, partial memory failures and precommit agreement. Native UI deployment trust, DOM integration and desktop acceptance remain pending. + +Semantic observation field scopes +--------------------------------- + +Multi-source report version 3 requires host-defined fields in every source. +A field omitted by all sources remains missing and cannot authorize a command +or prove completion. Helper bootstrap and the original journal witness bind +the same field scope. Versions 1 and 2 and out-of-scope fields are rejected. +A tagged partial source keeps successful values separately from fixed per-field +failures. Valid empty strings and false values remain distinct from unreadable, +unsupported, ambiguous, protected or missing fields. Partial sources and complete +best-effort captures grant no action or completion authority. + +The native fixture builder accepts ``--kind uia`` for a separate owned hidden-window +artifact. Its static manifest remains schema 2. The internal startup owner validates +the exact challenge, retained process and current HWND owner; its channel accepts +no commands. ``ScopedUiaSource`` checks the original HWND/PID and pins the root runtime +ID across captures. It verifies raw-tree ancestry around reads, bounds traversal, +protects password text and keeps COM calls on the source owner thread. + +``UiaObservationTarget`` creates COM lazily during managed readiness and publishes +read-only UIA results through the existing observation API. It has no Invoke, +SetValue, focus or input operations. Injected COM and hidden Python helper tests +cover partial fields, managed reporting and timeout retirement. Native deployment +trust and all desktop acceptance remain pending. No native UI fixture execution +or desktop noninterference is claimed. + +The internal owned UI target retains its launcher and both image leases before +attestation, attempts every owner during cleanup, and retains failed cleanup for +retry. A publication lock prevents late source installation after shutdown. The +native factory only constructs owners; native deployment trust +and native acceptance remain pending. + +Host management can register a ``uia_fixture`` profile with empty ``allowed_tools``, +``roots`` and ``apps``, and only ``config_path``/``config_sha256`` settings. It uses a fixed +isolated worker and validates deployment, profile and target pins before acquisition. +Both endpoints refuse commands. External tasks may use an empty tool scope only +without planned actions; completion criteria remain required and an empty plan +cannot prove completion. UI partial/best-effort reports remain diagnostic. +Registration and probe acquire nothing; probe reports ``not_supported`` and +``native_evidence=not_recorded``. The existing target API, CLI and GUI JSON editor +carry this profile. Injected and hidden-helper tests do not establish native trust. + +Host-selected in-process service adapters can use the closed ``service_state`` criterion: +``{"kind":"service_state","tool":"AC_service_start","state":"running"}`` or STOP/stopped. +It requires the matching confirmed acceptance and a new SCM report from the same +retained owner after acceptance. A passing result reports SCM state, not atomic +completion, health or desktop noninterference. These tool names are adapter-scoped, +not global executor commands. Existing task APIs and the GUI JSON editor carry the +criterion. The host-reviewed ``service`` profile pins ``config_path``, ``config_sha256`` +and an ASCII ``service_key``. Its fixed worker checks deployment identity and the +operation ceiling before task scope. Registration, reload and probe do not read +the deployment or access SCM; native acceptance remains pending. +Every pinned path (each profile's ``config_path`` and the image a deployment names) must be +a local drive path: UNC shares, ``\\.\pipe\`` names, ``\\?\`` device paths and ``..`` segments are +refused, so registering a profile cannot make the host send its credentials to another machine. +Before a fixture image runs, its lease also refuses a location another account could change: +every directory from the drive root down must be a real directory (no junction or symlink) that +only SYSTEM, Administrators, TrustedInstaller and the running user may rename, delete, re-ACL or +add files to, and the leased file's final path must be the configured one. Deploy fixtures under +a protected directory such as ``%LOCALAPPDATA%``; a drive root that grants Authenticated Users Modify +(common on secondary drives) or a shared ``%TEMP%`` is refused. The fixture starts in its own +directory with a minimal environment: a system-only ``PATH`` and none of the host's tokens or keys. diff --git a/docs/source/Zh/doc/ai_agents/ai_agents_doc.rst b/docs/source/Zh/doc/ai_agents/ai_agents_doc.rst index 9b78c1ffb..54702e889 100644 --- a/docs/source/Zh/doc/ai_agents/ai_agents_doc.rst +++ b/docs/source/Zh/doc/ai_agents/ai_agents_doc.rst @@ -1,6 +1,15 @@ AI Agent 與 Computer Use =========================== +主機選定的語意 target 可使用完成條件,例如自有 counter 測試的 +``{"kind": "semantic", "tool": "AC_increment", "fields": {"value": 1}}``。 +命令必須已在任務允許清單中。完成驗證重新讀取狀態,核對記錄中的目標身分、 +adapter、schema 與來源,再比較欄位,不進行型別轉換。 +完整擷取區間必須落在當次讀取請求內,並使用同一主機的單調時鐘。 +快取觀察會遭拒絕;身分改變、欄位缺失及效果未知均不能證明成功。 +Agent Tasks 的 scope JSON 編輯器透過 Submit 保留此條件。 +這不授予記憶體權限,也不登記原生 target;原生 adapter 整合與驗收仍列於 Progress.md。 + 成果移交管理已共用 ``manage_agent_transfer(operation, request)``、``AC_agent_transfer``、 ``ac_agent_transfer``、具授權的 ``POST /agent/transfer`` 與 Script Builder metadata。CLI 使用 ``agent-task transfer --operation review_export --request request.json``。審閱回傳批准 token; @@ -335,7 +344,7 @@ Agent 任務介面將任務範圍、工作流程設定、觸發器、技能及 AgentHumanReview 表示未儲存內容或未知對話框需人工審閱;包含外部觀察請求都會記錄 waiting_user 並釋放輸入控制權,明確恢復後仍會重新檢查。Windows 依原生對話框/停用擁有者及英中日已知未儲存文字判定。Workspace 也會拒絕標題首尾帶星號的文件,並可在視窗設定加入 unsaved_selector 與 unsaved_value,於改變排列前檢查應用特有指示;不宣稱能推斷所有程式的未儲存狀態。標準檔案對話框沿用 AC_handle_file_dialog 執行器,受管 driver 只接受唯一精確標題、相同 PID、已確認前景,以及授權根目錄內的絕對路徑。UIA 控制項須屬於實際指定的根視窗,同 PID 的其他視窗也會拒絕。模擬原生與本機 HTTP 測試已有覆蓋,實際平台驗收仍未驗證。 -主機目標以 AgentTargetProfile 與 manage_agent_target(AC_agent_target,register/get/disable/enable/probe)設定。名稱及設定固定不可替換,目前提供 desktop/files/browser adapter,未實作類型會被拒絕;瀏覽器可使用主機審閱的 helper_python。任務固定主機設定摘要,不能擴大工具、應用、根目錄或網路來源。啟停狀態會跨重啟保存並於分派時檢查;停用會要求暫停及清理,重新啟用仍須明確恢復任務。list_agent_targets/AC_agent_target_list/CLI agent-task targets 只提供被動資訊,readiness=not_probed、native_evidence=not_recorded;完整設定需要 manage_hosts。CLI agent-task target 及 GUI「主機目標」頁使用同一服務。匿名有效 MCP 工具 session 的直接及舊式包裝呼叫都以 operator 權限執行;MCP 主機管理需要已驗證的管理員,可信任的直接 Python 呼叫維持原行為。瀏覽器自動化統一由 WebRunner(je_web_runner)提供,本機開發來源為 D:/Codes/WebRunner;browser profile 使用受管 je_web_runner SDK 契約,依賴診斷不代表原生可用。 +主機目標以 AgentTargetProfile 與 manage_agent_target(AC_agent_target,register/get/disable/enable/probe)設定。名稱及設定固定不可替換,目前可設定 desktop/files/browser/fixture/uia_fixture/service adapter,未實作類型會被拒絕;瀏覽器可使用主機審閱的 helper_python。任務固定主機設定摘要,不能擴大工具、應用、根目錄或網路來源。啟停狀態會跨重啟保存並於分派時檢查;停用會要求暫停及清理,重新啟用仍須明確恢復任務。list_agent_targets/AC_agent_target_list/CLI agent-task targets 只提供被動資訊,readiness=not_probed、native_evidence=not_recorded;完整設定需要 manage_hosts。CLI agent-task target 及 GUI「主機目標」頁使用同一服務。匿名有效 MCP 工具 session 的直接及舊式包裝呼叫都以 operator 權限執行;MCP 主機管理需要已驗證的管理員,可信任的直接 Python 呼叫維持原行為。fixture profile 只接受 config_path/config_sha256 與 AC_fixture_set_state,不能授予根目錄或桌面應用。固定隔離 worker 的 bootstrap/configure 均須符合部署綁定;註冊不取得資源。明確呼叫 fixture probe 時,會由獨立背景 helper 檢查固定的靜態產物,並具備 bootstrap/檢查時限、即時管理權限核對及可重試的關閉所有權。成功回報 static_artifacts_ready、fixture_execution=not_run 與 native_evidence=not_recorded,不證明已載入程式碼可信。原生 fixture 執行仍暫停。瀏覽器自動化統一由 WebRunner(je_web_runner)提供,本機開發來源為 D:/Codes/WebRunner;browser profile 使用受管 je_web_runner SDK 契約,依賴診斷不代表原生可用。 既有瀏覽器自動化(包含 open_path(URL) 與 AC_open_path)統一交由 WebRunner,Python 套件名稱為 je_web_runner。URL 計畫的 backend 現為 je_web_runner,原本比較 webbrowser 描述值的呼叫端需改用新值;函式介面與本機檔案開啟維持相容。實際 URL 執行需要設定的 WebRunner 專案,缺少時傳出 WebRunnerBridgeError,不改用 OS 瀏覽器。本機開發來源為 D:/Codes/WebRunner;純計畫及注入 opener 測試不需要該套件。協定支援由 WebRunner 與其選用的瀏覽器決定。既有瀏覽器 GUI/MCP/AC 及錄製的 WR_* 動作都使用同一橋接。 @@ -982,3 +991,51 @@ Linux 內部 presence_peer_linux 以不可繼承的 pidfd 保留原始 Unix stre wheel 與原始碼發行套件包含 REST Dashboard 和 Swagger 的 HTML、CSS、JavaScript 資源。 安裝後的套件沿用相同的本機 REST 路由與授權規則;提供靜態頁面不授予任務或桌面輸入權限。 + +主機選定的語意 adapter 可宣告固定的多來源觀察契約。既有 observe 呼叫保留部分缺失與衝突報告;操作及完成判定要求每個來源的新鮮完整一致證據。helper bootstrap 固定來源契約,完整報告跨 IPC 傳遞後才轉換為命令快照。fixture 已在同一把擷取/提交鎖下結合受審閱的記憶體讀取與保留的唯讀 IPC snapshot,cleanup 仍可中斷 IPC。注入 reader 與隱藏 helper 測試涵蓋來源衝突、部分記憶體失敗及提交前一致性。原生 UI 部署信任、DOM 整合與桌面驗收仍待完成。 + +語意觀察欄位契約 +---------------- + +多來源報告版本 3 要求每個來源提供主機指定的必要欄位。即使所有來源都漏掉同一欄位, +仍會標示缺失,不能授權動作或確認完成。helper 握手及原始 journal witness 綁定相同欄位範圍。 +版本 1、版本 2 及範圍外欄位會被拒絕。標記為 partial 的來源分別保留有效值與固定的欄位失敗原因。 +有效空字串及 false 不會被當成無法讀取、不支援、歧義、受保護或缺失欄位。 +部分來源與完整的 best-effort 擷取都不授予操作或完成判定權限。 + +原生 fixture 建置工具接受 ``--kind uia``,產生獨立自有隱藏視窗產物,靜態 manifest 維持 schema 2。 +內部啟動擁有者核對 challenge、保留程序與目前 HWND 擁有者,通道不接受指令。 +``ScopedUiaSource`` 核對原始 HWND/PID,並在擷取之間固定根節點 runtime ID。 +讀取前後都驗證 raw-tree 祖先關係,限制走訪數量並保護密碼文字;COM 呼叫保留在來源擁有執行緒。 + +``UiaObservationTarget`` 在受管 readiness 中延遲建立 COM,透過既有觀察 API 發布唯讀 UIA 結果。 +它不提供 Invoke、SetValue、焦點或輸入操作。注入 COM 與隱藏 Python helper 測試涵蓋部分欄位、 +受管報告及逾時回收。原生部署信任與所有桌面驗收仍待完成。 +尚未執行原生 UI fixture,也未證明不干擾桌面。 + +內部自有 UI target 在 attestation 前保留啟動器及兩個獨立映像租約擁有者; +清理會嘗試全部資源並保留失敗項目供重試。發布鎖防止關閉後存入晚到的來源。 +原生 factory 僅建立擁有者;原生部署信任及原生驗收仍待完成。 + +主機管理可註冊 ``uia_fixture`` profile,``allowed_tools``、``roots``、``apps`` 都為空, +設定只接受 ``config_path``/``config_sha256``。固定隔離 worker 在取得資源前核對部署、profile +與目標 pin,兩端都拒絕命令。外部任務只有在沒有預排動作時可使用空工具集合; +仍須提供完成條件,空計畫不能證明完成,UI partial/best-effort 報告仍只供診斷。 +註冊與 probe 不取得資源;probe 回傳 ``not_supported`` 與 ``native_evidence=not_recorded``。 +既有目標 API、CLI 與 GUI JSON 編輯器可傳遞此 profile。注入及隱藏 helper 測試不代表原生信任成立。 + +主機選定的程序內服務 adapter 可使用封閉的 ``service_state`` 完成條件: +``{"kind":"service_state","tool":"AC_service_start","state":"running"}``,或 STOP/stopped。 +判定須有對應操作的確認回條,以及同一資源擁有者在接受後取得的新 SCM 查詢。 +通過只表示 SCM 回報該狀態,不證明原子完成、健康或桌面不干擾。這些工具名稱只屬於 +adapter 範圍,不是全域 executor 指令。既有任務 API 與 GUI JSON 編輯器可傳遞此條件。 +主機審閱的 ``service`` profile 固定 ``config_path``、``config_sha256`` 及 ASCII ``service_key``。 +固定 worker 核對部署的服務與操作上限後才接受任務範圍。註冊、重載與 probe 不讀取部署檔 +或存取 SCM;原生驗收仍待完成。 +所有固定路徑(各 profile 的 ``config_path`` 及部署指定的映像檔)都必須是本機磁碟路徑: +UNC 共用、``\\.\pipe\`` 名稱、``\\?\`` 裝置路徑與 ``..`` 片段一律拒絕,註冊 profile 不能讓主機把認證送到其他機器。 +fixture 映像執行前,租約還會拒絕其他帳號能變更的位置:從磁碟根目錄往下的每一層都必須是實體目錄 +(不能是 junction 或 symlink),且只有 SYSTEM、Administrators、TrustedInstaller 與目前使用者能改名、刪除、 +改 ACL 或新增檔案;租約檔案的最終路徑也必須等於設定的路徑。請把 fixture 部署在 ``%LOCALAPPDATA%`` 這類受保護目錄; +授予 Authenticated Users 修改權限的磁碟根目錄(次要磁碟常見)或共用的 ``%TEMP%`` 會被拒絕。 +fixture 在自己的目錄啟動,只帶最小環境變數:僅含系統目錄的 ``PATH``,不帶主機的任何 token 或金鑰。 diff --git a/docs/updates/2026-11-b.md b/docs/updates/2026-11-b.md index 2ad4f1eec..b1c409aaa 100644 --- a/docs/updates/2026-11-b.md +++ b/docs/updates/2026-11-b.md @@ -1144,3 +1144,61 @@ - **Change.** A new `settled(source)` helper retries an `inspect` that missed its deadline, or that found the source busy, for up to 5 s, as `check` does. It replaces the two drain calls (lines 175 and 223). The inspects that test the deadline, the capacity limit or the not-started path are unchanged. - **Tests:** `test_agent_presence_windows.py`, 26 passed in each of 3 runs. - **Files:** `test/unit_test/headless/test_agent_presence_windows.py`. + +## U-20261117-04 · 2026-11-17 · Release 1.2.2: PR #552 merged into main · #release + +- **What.** The maintainer approved the merge once the checks passed. They failed once, on `d97f09c7` (U-20261117-03). On `229bb33d` every check passed in the first round, and PR #552 (`dev` → `main`, 100 commits) was merged with a merge commit at 2026-11-17 03:55 UTC as `a798b4ed`, using `--match-head-commit`. +- **Release.** The `AutoControl Stable CI` run on `main` (44013574012) succeeded: tests on 3.11 to 3.14, then `publish`. It released `je_auto_control` **1.2.2** to PyPI and committed `Bump version to 1.2.2 [skip ci]` (`632f90c7`) on `main`. +- **Included:** + - the PySide6 split, 6.12.0 on Python 3.12+ and 6.11.2 on 3.11; + - the deferred-deletion abort workarounds (the test-side GC pause and GUI-thread collection); + - stoppable HTTP requests, template matching and OCR; + - the Slack handler `stop()` fix; + - read-only `ac_diagnose` audit verification; + - the M0 routing profile; + - the dnspython 2.9.2 lock floor. Dependabot alert 177 is now `fixed`. +- **Files:** `docs/updates/2026-11-b.md`, `docs/updates/README.md`. + +## U-20261117-05 · 2026-11-17 · The workspace-sync example checks its generation path, clearing Sonar's blocker · #security #sonarcloud #examples + +- **Finding.** The SonarCloud quality gate on `main` was `ERROR` on a single condition: `new_security_rating` was 5, with 1 required. The one vulnerability behind it was `pythonsecurity:S2083`, a BLOCKER, "Path Traversal via file content in sync_workspace.main()", at `examples/sync_workspace.py:26` (opened 2026-10-19). The taint analysis treats the directory `materialize_sync_profile()` returns as shaped by synchronized content, and the example read `workspace.ini` from it with no check. The other 271 new-code issues are code smells, mostly composite test assertions (S9073: 162); none affects the gate. +- **Change.** The example resolves the cache root it passes in. It then resolves the generation's `workspace.ini` and reads it only when `is_relative_to(cache)` holds; otherwise it raises `ConfigSyncError`. The example's output is unchanged. +- **Tests:** the example runs as before. `test_sync_workspace.py`, `test_sync_preferences_review.py`, `test_config_sync_gui.py` and `test_doc_counts.py`: 71 passed. +- **Files:** `examples/sync_workspace.py`. +- **Correction (PR #556 analysis).** SonarCloud did not accept the `is_relative_to` check as a sanitiser: the finding moved to the + copy line, with the generation's file content as its source. The copy is now `shutil.copyfile(generated, working_copy)`, so the + content no longer passes through `read_bytes()` / `write_bytes()`. The containment check stays. +- **Open items:** the gate on `main` clears only once this reaches `main`. + +## U-20261117-06 · 2026-11-17 · SonarCloud cleanup, product code: 69 new-code findings on main · #sonarcloud #cleanup + +- **Scope.** On `main`, SonarCloud listed 272 open new-code issues: 70 in product code and 202 in tests. This entry covers the product code; the vulnerability among them is U-20261117-05. +- **Broad excepts (S5754, 28 sites in 12 files)** were all deliberate. + - They are cleanup boundaries that collect the failure, run the other independent cleanups, and re-raise later through `raise_cleanup_failures` or while preserving control signals (asyncio's `CancelledError` is a `BaseException`). The rest hand an outcome to another thread or future (`stoppable_call`, the HTTP helper), or release the source before re-raising (`multi_viewer`). + - Narrowing them would drop control signals during cleanup, so each gets `# NOSONAR` on its `except` line next to the `# reason:` the broad-except gate reads. Reasons were shortened to keep every line within 120 characters. +- **Always-true conditions (S2589, 4)** are identity re-checks after an `await` or a `close()` that can replace the field. They are not logic errors and are kept, each annotated with why. +- **Duplicated literals (S1192, 11)** became module constants in 6 modules: `"request stopped"`, `"as AC_presence_register"`, and the WebRTC media-owner labels. Only identical string tokens were replaced, using `tokenize`. +- **Smaller fixes:** + - **Redundant exception classes (S5713):** `ConnectionError` is an `OSError`, and `AuthorizationError` is a `PermissionError`, so the redundant one is dropped from each tuple. + - **Loop lambdas (S1515):** the two in `process_memory` became `functools.partial`. + - **Nested conditional (S3358):** the record tab's chain became an `if` chain in `_status_key`. + - **Unused parameter (S1172):** `stop_resource` now uses its `label`, adding `while stopping