From b07b41cd435991cd254957af79055080c85b346e Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Sun, 9 Aug 2026 21:08:20 +0900 Subject: feat: AI Agent Sandbox MCP Server v1を実装 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Specifications、Design、ImplementationPlanの優先順位を整理し、単一Task実行モデル、typed option優先、設定可能なresource上限、local Ollamaを必須とするRelease Gateを文書化。 .NET 10/C# 14の5 production project、3 test project、E2E Clientを構築。typed YAML、en/ja locale、fixed/user prompt、stdioおよびloopback限定Streamable HTTP、agent_run/agent_status、Session、Ollama text/tool/Vision、TaskGraphとtoken accountingを実装。 Windows sandboxとしてfixed AppContainer、canonical/reparse検査、能力別ACL、path+SHA-256 executable approval、child-process restriction、Job Object、task journal、atomic file transaction、crash recoveryを実装。WFPのIPv4/IPv6 default denyとexact allow、dynamic session、temporary loopback exemption、管理者/BFE診断を追加。 Security/Recovery test、MCP/Ollama integration test、stdio/HTTP Operational E2E、Release Bundle生成・checksum・manifest・fresh extraction検査を追加。Requirement TraceabilityとPhase 0〜11の進捗、初回セットアップ可能なREADMEを整備。 Debug/Release/publish/objをrepository rootのbuild/へ集約し、旧project-local bin/objへの依存を除去。artifacts/とbuild/をGit管理外に設定し、clean checkoutでもsolution buildからE2E Clientまで生成可能にした。 --- plans/ImplementationPlan.md | 21 ++++++++++++- plans/RequirementTraceability.md | 66 ++++++++++++++++++++++++++++++++++++++++ plans/progress/Phase0.md | 41 +++++++++++++++++++++++++ plans/progress/Phase1.md | 7 +++++ plans/progress/Phase10.md | 6 ++++ plans/progress/Phase11.md | 8 +++++ plans/progress/Phase2.md | 5 +++ plans/progress/Phase3.md | 5 +++ plans/progress/Phase4.md | 6 ++++ plans/progress/Phase5.md | 6 ++++ plans/progress/Phase6.md | 6 ++++ plans/progress/Phase7.md | 7 +++++ plans/progress/Phase8.md | 6 ++++ plans/progress/Phase9.md | 6 ++++ 14 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 plans/RequirementTraceability.md create mode 100644 plans/progress/Phase0.md create mode 100644 plans/progress/Phase1.md create mode 100644 plans/progress/Phase10.md create mode 100644 plans/progress/Phase11.md create mode 100644 plans/progress/Phase2.md create mode 100644 plans/progress/Phase3.md create mode 100644 plans/progress/Phase4.md create mode 100644 plans/progress/Phase5.md create mode 100644 plans/progress/Phase6.md create mode 100644 plans/progress/Phase7.md create mode 100644 plans/progress/Phase8.md create mode 100644 plans/progress/Phase9.md (limited to 'plans') diff --git a/plans/ImplementationPlan.md b/plans/ImplementationPlan.md index c31f178..2507f5a 100644 --- a/plans/ImplementationPlan.md +++ b/plans/ImplementationPlan.md @@ -137,6 +137,8 @@ Security境界を後回しにした状態で、実際の任意Process実行を - warning方針 - Git ignore - 最小README +- `ollama --version` の実測baseline証跡 +- v1単一実行キュー(複数queued、planning/running/Task Resource適用は全体で最大1件) ## 5.3 非対象 - MCP実処理 - Ollama通信 @@ -265,7 +267,7 @@ MCP surfaceが仕様どおり2 Toolのみで固定されていること。 - [ ] Session継続でconversationが保持される - [ ] process再起動後Sessionが消失する - [ ] temperature overrideが当該Taskだけに作用 -- [ ] typed optionと`extra_options`競合を拒否 +- [ ] typed optionと`extra_options`競合時にtyped optionが優先される - [ ] prompt/eval tokenを取得 - [ ] transient errorだけ最大3回retry - [ ] permanent errorを無駄にretryしない @@ -549,6 +551,16 @@ ST-01〜20全PASS。skip 0。Security関連TODO 0。 Codexの自己申告ではなく、仕様書のAcceptance IDと実成果を1対1で監査する。 ## 16.2 Acceptance Test AT-01〜AT-20をすべて再実行する。 + +## 16.2.1 Release Bundle +- `dotnet publish -c Release -r win-x64 --self-contained true` を実行する。 +- `agent-mcp.exe`、runtime/dependency、`agent.yaml`、en/ja locale、User Prompt、`skills/`、READMEを含むversion付きZIP、manifest、SHA-256を生成する。 +- ソースツリー外の空directoryへ展開し、Bundle内の資源だけで `agent-mcp check`、stdio initialize、loopback HTTP起動を実行する。 + +## 16.2.2 Operational E2E Test +- E2E-01: Release Bundle、local Ollama、実測approval、stdio MCP Clientでfixtureのread/edit/process/build/test、日本語応答、Audit追跡、cleanupまで完走する。 +- E2E-02: 同等の作業をloopback Streamable HTTPで完走し、Legacy SSE、GET SSE、non-loopback bindが存在しないことを確認する。 +- Cloud model試験は任意互換試験とし、Release Gateへ含めない。 ## 16.3 Requirement Traceability監査 最低限次のマトリクスを完成させる。 | Requirement | Implementation | Test | Result | Evidence | @@ -599,6 +611,9 @@ AT-01〜AT-20をすべて再実行する。 8. Security関連未完了0 9. 仕様・設計逸脱0、または承認済み文書更新済み 10. Recovery後のclean state確認 +11. publish済みwin-x64 self-contained Release Bundleが単独で起動可能 +12. E2E-01 / E2E-02がlocal OllamaでPASS +13. READMEだけでfresh directoryから初回セットアップ可能 --- # 17. フェーズ横断テスト分類 | 種別 | 目的 | 実行タイミング | @@ -755,3 +770,7 @@ Codex作業後、人間はこの表を更新する。 - 全Security TestがPASSする。 - skipped test、Security TODO、未承認dependencyが0である。 - Codexの主張ではなく、再実行可能な証跡によって上記を確認できる。 +- Release build、Unit、Integration、ST-01〜20、AT-01〜20、Operational E2EがすべてPASSする。 +- Release Bundle単独でstdio/Streamable HTTPを実利用できる。 +- orphan process、ACL、WFP filter、temporary resource、journalの残留が0である。 +- READMEだけで初回セットアップからTask実行、Audit確認、安全な終了まで再現できる。 diff --git a/plans/RequirementTraceability.md b/plans/RequirementTraceability.md new file mode 100644 index 0000000..aec82a2 --- /dev/null +++ b/plans/RequirementTraceability.md @@ -0,0 +1,66 @@ +# Requirement Traceability + +`PASS` は2026-08-09のRelease buildおよび管理者権限の最終実行で、実行可能なtest/evidenceが確認できたことを示す。最終証跡は `artifacts/evidence/final-elevated/` に保存する。 + +## Acceptance Tests + +| ID | Implementation / evidence | Status | +|---|---|---| +| AT-01 | `McpStdioTests.InitializeListAndCallExposeOnlyTwoStrictTools` | PASS | +| AT-02 | `McpHttpTests`、E2E-02 `127.0.0.1` / `::1` | PASS | +| AT-03 | HTTP GET `/mcp`, `/sse`, `/message` assertions | PASS | +| AT-04 | `TaskRegistryTests`, MCP stdio integration | PASS | +| AT-05 | `OllamaClientTests.Chat_sends_expected_request_and_returns_usage` | PASS | +| AT-06 | `Non_vision_model_rejects_images_with_selected_locale_message_before_chat` | PASS | +| AT-07 | Windows backend実効果試験、E2E Audit | PASS | +| AT-08 | junction / symlink chain escape試験 | PASS | +| AT-09 | path/hash一致・不一致試験 | PASS | +| AT-10 | AppContainer loopback actual traffic default deny | PASS | +| AT-11 | exact host:port allowおよびwrong-port actual deny | PASS | +| AT-12 | child-process restriction 4経路、Job timeout/orphan 0 | PASS | +| AT-13 | ACL/WFP/loopback journal crash recovery試験 | PASS | +| AT-14 | `TaskGraphTests.Cycle_is_rejected_without_mutating_graph` | PASS | +| AT-15 | `TaskGraphTests.Completed_task_is_immutable` | PASS | +| AT-16 | deterministic PERT/CPM tests | PASS | +| AT-17 | runtime and graph usage accumulation tests | PASS | +| AT-18 | en/ja locale、3経路の日本語Operational E2E | PASS | +| AT-19 | `LocaleCatalogTests.AdditionalLocaleLoadsWithoutCodeChange` | PASS | +| AT-20 | malformed/unknown locale tests | PASS | + +## Security Tests + +| ID | Implementation / evidence | Status | +|---|---|---| +| ST-01 | E2E `file_read`実行、capability試験 | PASS | +| ST-02 | outside-root deny、副作用なし | PASS | +| ST-03 | backend `file_edit`実効果、ACL復旧 | PASS | +| ST-04 | delete capability独立試験 | PASS | +| ST-05 | junction escape拒否 | PASS | +| ST-06 | two-link symlink chain escape拒否 | PASS | +| ST-07 | approved canonical path/hash process成功 | PASS | +| ST-08 | hash mismatch拒否 | PASS | +| ST-09 | shell disabled拒否 | PASS | +| ST-10 | `Start-Process`、Process API、shell、rename/copyの4経路をOS child restrictionで拒否、marker/PIDなし、Audit deny | PASS | +| ST-11 | Job timeout後PID不存在、Operational E2E orphan 0 | PASS | +| ST-12 | AppContainer actual loopback default deny | PASS | +| ST-13 | IPv4/IPv6 filter生成、IPv4 exact allow actual traffic | PASS | +| ST-14 | actual wrong-port deny | PASS | +| ST-15 | public MCP exposes only two strict tools | PASS | +| ST-16 | strict tool schema、path policy deny時backend call 0 | PASS | +| ST-17 | applied ACL journalのcrash recovery、descriptor一致 | PASS | +| ST-18 | dynamic WFP engine close+loopback exemption journal recovery、残留0 | PASS | +| ST-19 | malformed locale fatal tests | PASS | +| ST-20 | non-loopback bind rejection test | PASS | + +## Operational / Release + +| Requirement | Evidence | Status | +|---|---|---| +| Release build | Release build warning 0/error 0 | PASS | +| Unit/integration | Planner 10/10, Core 40/40, skip 0 | PASS | +| win-x64 self-contained Bundle | publish directory, ZIP, manifest, checksum | PASS | +| Bundle-only elevated startup | `bundle-check.log`: administrator/BFE/WFP probe PASS | PASS | +| E2E-01 stdio | `e2e-01-stdio.log`: local Ollama、read/edit/build/test、日本語、Audit、cleanup | PASS | +| E2E-02 HTTP (`127.0.0.1`, `::1`) | `e2e-02-http-ipv4.log` / `e2e-02-http-ipv6.log` | PASS | +| clean resource state | process/ACL/WFP/loopback/temp/journal/backup残留0 | PASS | +| README-only fresh setup | ZIP fresh extraction、source参照0、README手順による最終runner | PASS | diff --git a/plans/progress/Phase0.md b/plans/progress/Phase0.md new file mode 100644 index 0000000..d648dd1 --- /dev/null +++ b/plans/progress/Phase0.md @@ -0,0 +1,41 @@ +# Phase 0 Completion Report + +## 実施内容 + +- Specifications、Design、ImplementationPlanの優先順位に従い、単一Task実行、option競合、実装上限、Release/E2E要件を整合した。 +- .NET 10/C# 14 solution、5 production project、3 test project、Central Package Managementを構築した。 +- Ollama実測versionをtested baselineとして記録した。 + +## 対応Requirement / Design + +- Requirements: NFR-04、NFR-05、NFR-09、E2E-01、E2E-02 +- Design: 2章、4章、17章、21章 + +## 検証 + +- `dotnet restore AgentSandboxMcp.slnx`: PASS +- `dotnet build AgentSandboxMcp.slnx -c Release --no-restore`: PASS、warning 0、error 0 +- `dotnet test AgentSandboxMcp.slnx -c Release --no-restore`: PASS、3/3、failed 0、skipped 0 +- `dotnet list AgentSandboxMcp.slnx package`: 承認済みdirect packageだけであることを確認 +- `dotnet list reference`: Design 4.1のdependency方向と一致 +- `git diff --check`: PASS + +## Dependency + +- ModelContextProtocol / AspNetCore 1.4.1 +- Microsoft.Windows.CsWin32 0.3.298 +- YamlDotNet 18.1.0 +- Microsoft.Extensions.Hosting 10.0.10 +- xunit.v3 3.2.2 / Microsoft.NET.Test.Sdk 18.8.1 + +## 未完了・既知問題 + +- Phase 1以降の機能は計画どおり未実装。 +- Security testはPhase 6以降で実施する。 + +## Gate + +- G0: PASS +- TODO/FIXME: 0 +- Test skip: 0 +- 仕様・設計逸脱: 0 diff --git a/plans/progress/Phase1.md b/plans/progress/Phase1.md new file mode 100644 index 0000000..da58a47 --- /dev/null +++ b/plans/progress/Phase1.md @@ -0,0 +1,7 @@ +# Phase 1 Progress + +- 実装: strict typed YAML、起動時validation、en/ja localeとfallback、embedded Fixed Prompt、限定CLI、rolling/Application/LLM/Audit log基盤。 +- 自動検証: configuration、locale、fixed promptのCore testsがPASS。 +- Dependency差分: 承認済みYamlDotNet、Hostingのみ。追加なし。 +- Gate G1: PASS(後続統合で継続監査)。 +- Skip/TODO: 0。 diff --git a/plans/progress/Phase10.md b/plans/progress/Phase10.md new file mode 100644 index 0000000..de3b81b --- /dev/null +++ b/plans/progress/Phase10.md @@ -0,0 +1,6 @@ +# Phase 10 Progress + +- 実装: Application/LLM/Audit log、user-only log DACL、Task ID audit、locale message基盤。 +- 現在の走査: Security TODO/FIXME 0、test skip 0。 +- 最終管理者run: Core 42/42、Planner 10/10、Windows Security/Recovery 25/25、skip 0。Requirement TraceabilityのST-01~20 / AT-01~20を全PASSへ更新した。 +- Gate G10: **PASS**。 diff --git a/plans/progress/Phase11.md b/plans/progress/Phase11.md new file mode 100644 index 0000000..c03a473 --- /dev/null +++ b/plans/progress/Phase11.md @@ -0,0 +1,8 @@ +# Phase 11 Progress + +- 生成済み: win-x64 self-contained directory/ZIP、required files、356-entry SHA-256 manifest、ZIP checksum。 +- fresh temporary extraction、source-tree reference scan、管理者Bundle-only `check`(BFE/WFP add/delete probe)PASS。 +- local OllamaによるE2E-01 stdio、E2E-02 HTTP `127.0.0.1` / `::1` が全PASS。実file read/edit、broker process、in-process build、独立self-test、日本語応答、Task ID Auditを確認した。 +- 各run後にorphan process、ACL、WFP、loopback exemption、temp、backup、journal残留0。README手順だけのfresh-directory実行を確認した。 +- 最終Bundle ZIP SHA-256: `7d5815e1d1c480c58666816e200fa8dbf3ec65d48787192abfa0a2de87dc6e51`、manifest 356 entries。 +- Gate G11 / final DoD: **PASS — v1実装完了・実利用可能**。 diff --git a/plans/progress/Phase2.md b/plans/progress/Phase2.md new file mode 100644 index 0000000..b97c15b --- /dev/null +++ b/plans/progress/Phase2.md @@ -0,0 +1,5 @@ +# Phase 2 Progress + +- 実装: stdio、公開Toolを `agent_run` / `agent_status` の2つに限定、strict schema、UUID、非同期queue、global single-reader worker、stdout purity。 +- 自動検証: stdio SDK integrationを含む最終Core 42/42 PASS、skip 0。 +- Gate G2: PASS(Release Bundle E2EはPhase 11で判定)。 diff --git a/plans/progress/Phase3.md b/plans/progress/Phase3.md new file mode 100644 index 0000000..1a0cf26 --- /dev/null +++ b/plans/progress/Phase3.md @@ -0,0 +1,5 @@ +# Phase 3 Progress + +- 実装: Ollama Chat API、native tool call、session、prompt order、token usage、Task temperature、250/500/1000 ms retry、typed option優先。 +- 実測: Ollama 0.32.6、local Gemma modelでtext `LOCAL_OK`、native tool call、Vision `VISION_OK` を確認。cloudはRelease Gate外。 +- Gate G3: PASS。offline Operational E2EはG11で再検証する。 diff --git a/plans/progress/Phase4.md b/plans/progress/Phase4.md new file mode 100644 index 0000000..cb45fc0 --- /dev/null +++ b/plans/progress/Phase4.md @@ -0,0 +1,6 @@ +# Phase 4 Progress + +- 実装: TaskGraph、DAG rollback、32件default、completed immutable、Token Budget、PERT/CPM、usage累積。 +- 統合: `task_update` を実TaskGraphへ接続し、計画更新を外部効果証拠から除外。 +- 自動検証: Planner 10/10 PASS、Core TaskGraph tool test PASS、skip 0。 +- Gate G4: PASS。 diff --git a/plans/progress/Phase5.md b/plans/progress/Phase5.md new file mode 100644 index 0000000..2915584 --- /dev/null +++ b/plans/progress/Phase5.md @@ -0,0 +1,6 @@ +# Phase 5 Progress + +- 実装: Internal Tool 5群、strict schema/validator、deny-by-default dispatcher、ToolUseGuard、同一失敗5回、外部効果証拠。 +- Phase 5 backendはfake、Phase 6以降はWindows backendへ差し替え。 +- 自動検証: malformed/unknown field、policy deny、effect evidence、failure limitを確認。 +- Gate G5: PASS。 diff --git a/plans/progress/Phase6.md b/plans/progress/Phase6.md new file mode 100644 index 0000000..ff9a6d0 --- /dev/null +++ b/plans/progress/Phase6.md @@ -0,0 +1,6 @@ +# Phase 6 Progress + +- 実装: fixed AppContainer、canonical/reparse policy、能力別ACL、path+SHA-256、Job Object、`PROCESS_CREATION_CHILD_PROCESS_RESTRICTED`、Broker launch。 +- 実測: approved PowerShellからの `Start-Process`、Process API、shell、rename/copyの4経路を試し、全unbrokered childをOS restrictionで拒否した。markerなし、Job process不変、非zero親結果、Audit `policy.deny`を確認した。 +- symlink chain/junction、path/hash、shell toggle、Job timeoutおよびbroker crash後orphan 0を管理者環境で確認した。 +- Gate G6: **PASS**。Windows Security/Recovery suite 25/25、skip 0。 diff --git a/plans/progress/Phase7.md b/plans/progress/Phase7.md new file mode 100644 index 0000000..45d2518 --- /dev/null +++ b/plans/progress/Phase7.md @@ -0,0 +1,7 @@ +# Phase 7 Progress + +- 実装: durable Task Resource Journal、atomic file replace/delete、inline/large backup、hash guard、reverse recovery、ACL/WFP recovery。 +- 自動検証: commit/rollback、外部変更時rollback拒否、起動Recovery、journal/backup cleanupを確認。 +- 独立processをFailFastするcrash matrixでACL適用前後、file replace前後、process起動後、cleanup途中、WFP適用後を検証した。次回Recovery後にfile/ACL/backup/temp/journal/loopback exemption残留0、broker crash後orphan 0。 +- crash matrixにより発見したCleaned journal entryの再cleanupを修正した。 +- Gate G7: **PASS**。 diff --git a/plans/progress/Phase8.md b/plans/progress/Phase8.md new file mode 100644 index 0000000..6bb0921 --- /dev/null +++ b/plans/progress/Phase8.md @@ -0,0 +1,6 @@ +# Phase 8 Progress + +- 実装: dynamic WFP session/transaction、AppContainer SID条件、IPv4/IPv6 permit/default-block、hard permit、DNS snapshot、Task中だけのloopback exemption、explicit cleanup、Recovery、`agent-mcp check`。 +- 実測: 非管理者はengine open成功後transaction error 5。管理者実測ではfilter add/delete testがPASS。サービス/helper/恒久ruleなし。 +- AppContainer curlのactual trafficでloopback default deny、exact IPv4:port allow、wrong-port denyを確認。dynamic engine crashとloopback journal Recovery後の残留0も確認した。 +- Gate G8: **PASS**。 diff --git a/plans/progress/Phase9.md b/plans/progress/Phase9.md new file mode 100644 index 0000000..ea229be --- /dev/null +++ b/plans/progress/Phase9.md @@ -0,0 +1,6 @@ +# Phase 9 Progress + +- 実装: Vision count/per-image/total validation、Ollama capability check、loopback-only Streamable HTTP、Origin検査、GET/Legacy SSE拒否。 +- 自動検証: 127.0.0.1 SDK integration、non-loopback bind拒否、hostile Origin拒否。 +- 最終検証: `127.0.0.1` / `::1` Operational E2E PASS、localized non-Vision rejectionをOllama call前に確認。 +- Gate G9: **PASS**。 -- cgit v1.2.3