From 01e537e2b52ef9f5c31b38b09ab9d50fd5c0c2e5 Mon Sep 17 00:00:00 2001 From: SIkebe <17608272+SIkebe@users.noreply.github.com> Date: Wed, 2 Dec 2026 00:39:31 +0900 Subject: [PATCH 1/7] Update Microsoft.Copilot.SDK to 2.0.5 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- Directory.Packages.props | 2 +- src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs | 2 +- .../Components/ThirdPartyNoticesPanelTests.cs | 2 +- .../Copilot/CopilotInProcessRuntimeTests.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 8d0eec28..9cd251e0 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -41,7 +41,7 @@ - + diff --git a/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs b/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs index ea66cbd5..6cda3c45 100644 --- a/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs +++ b/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs @@ -13,7 +13,7 @@ public static class ThirdPartyNotices { public static IReadOnlyList All { get; } = [ - Mit("Microsoft.Copilot.SDK", "2.0.5-preview.3", "Copyright (c) Microsoft Corporation. All rights reserved.", "https://github.com/github/copilot-sdk"), + Mit("Microsoft.Copilot.SDK", "2.0.5", "Copyright (c) Microsoft Corporation. All rights reserved.", "https://github.com/github/copilot-sdk"), new( "Markdig", "1.2.0", diff --git a/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs b/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs index 9f793683..181e8470 100644 --- a/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs @@ -28,7 +28,7 @@ public void Renders_Third_Party_Notices() Assert.Contains("MudBlazor", packages); var sdkIndex = Array.IndexOf(packages, "Microsoft.Copilot.SDK"); Assert.NotEqual(-1, sdkIndex); - Assert.Equal("2.0.5-preview.3", versions[sdkIndex]); + Assert.Equal("2.0.5", versions[sdkIndex]); Assert.Contains("Microsoft.Web.WebView2", packages); Assert.Contains("BSD-2-Clause", cut.Markup, StringComparison.Ordinal); Assert.Contains("MIT", cut.Markup, StringComparison.Ordinal); diff --git a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs index d16fa466..206febec 100644 --- a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs @@ -41,7 +41,7 @@ public async Task PingAsync_Connects_To_Bundled_InProcess_Runtime() var status = await client.GetStatusAsync(TestContext.Current.CancellationToken); Assert.Equal("pong: in-process", response.Message); - Assert.Equal("1.0.118-3", status.Version); + Assert.Equal("1.0.118", status.Version); } #pragma warning disable MCPSDK001 // Exercise experimental public APIs against the bundled native runtime. From 8e7b3fda4261c84453efd3dbc9f7616a97a2468b Mon Sep 17 00:00:00 2001 From: SIkebe <17608272+SIkebe@users.noreply.github.com> Date: Wed, 2 Dec 2026 09:30:11 +0900 Subject: [PATCH 2/7] Update Copilot SDK to 2.0.6 preview 0 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- Directory.Packages.props | 2 +- .../Settings/ThirdPartyNotices.cs | 2 +- .../Components/ThirdPartyNoticesPanelTests.cs | 2 +- .../Copilot/CopilotInProcessRuntimeTests.cs | 100 +++++++++++++++++- .../Copilot/RadarPermissionPolicyTests.cs | 24 +++++ 5 files changed, 126 insertions(+), 4 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 9cd251e0..e390c8f4 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -41,7 +41,7 @@ - + diff --git a/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs b/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs index 6cda3c45..3518c554 100644 --- a/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs +++ b/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs @@ -13,7 +13,7 @@ public static class ThirdPartyNotices { public static IReadOnlyList All { get; } = [ - Mit("Microsoft.Copilot.SDK", "2.0.5", "Copyright (c) Microsoft Corporation. All rights reserved.", "https://github.com/github/copilot-sdk"), + Mit("Microsoft.Copilot.SDK", "2.0.6-preview.0", "Copyright (c) Microsoft Corporation. All rights reserved.", "https://github.com/github/copilot-sdk"), new( "Markdig", "1.2.0", diff --git a/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs b/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs index 181e8470..6b972a78 100644 --- a/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs @@ -28,7 +28,7 @@ public void Renders_Third_Party_Notices() Assert.Contains("MudBlazor", packages); var sdkIndex = Array.IndexOf(packages, "Microsoft.Copilot.SDK"); Assert.NotEqual(-1, sdkIndex); - Assert.Equal("2.0.5", versions[sdkIndex]); + Assert.Equal("2.0.6-preview.0", versions[sdkIndex]); Assert.Contains("Microsoft.Web.WebView2", packages); Assert.Contains("BSD-2-Clause", cut.Markup, StringComparison.Ordinal); Assert.Contains("MIT", cut.Markup, StringComparison.Ordinal); diff --git a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs index 206febec..e79ef131 100644 --- a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs @@ -41,7 +41,7 @@ public async Task PingAsync_Connects_To_Bundled_InProcess_Runtime() var status = await client.GetStatusAsync(TestContext.Current.CancellationToken); Assert.Equal("pong: in-process", response.Message); - Assert.Equal("1.0.118", status.Version); + Assert.Equal("1.0.119-0", status.Version); } #pragma warning disable MCPSDK001 // Exercise experimental public APIs against the bundled native runtime. @@ -131,6 +131,104 @@ public async Task Host_Hook_Selection_Preserves_Sdk_Tool_Audit_Callbacks(bool ho } } + [Theory] + [InlineData(false)] + [InlineData(true)] + public async Task Host_Hook_Selection_Controls_Plugin_Hooks_Without_Workspace_Trust_Grant(bool hostHooksEnabled) + { + var ct = TestContext.Current.CancellationToken; + var root = Path.Combine(Path.GetTempPath(), $"reposyncradar-plugin-hooks-{Guid.NewGuid():N}"); + var workspace = Path.Combine(root, "workspace"); + var plugin = Path.Combine(root, "plugin"); + var home = Path.Combine(root, "home"); + var marker = Path.Combine(root, "hook-invoked.txt"); + Directory.CreateDirectory(workspace); + Directory.CreateDirectory(plugin); + Directory.CreateDirectory(home); + try + { + await File.WriteAllTextAsync( + Path.Combine(plugin, "plugin.json"), """{"name":"hook-fixture","version":"1.0.0"}""", ct); + var escapedMarker = marker.Replace("'", "''", StringComparison.Ordinal); + var hookJson = System.Text.Json.JsonSerializer.Serialize(new + { + version = 1, + hooks = new + { + preToolUse = new[] + { + new + { + type = "command", + powershell = $"Set-Content -LiteralPath '{escapedMarker}' -Value invoked", + timeoutSec = 60, + }, + }, + }, + }); + await File.WriteAllTextAsync(Path.Combine(plugin, "hooks.json"), hookJson, ct); + var copilot = new CopilotOptions { CopilotHome = home, Streaming = true }; + var options = CopilotSessionFactory.BuildClientOptions( + copilot, NullLogger.Instance, "offline-plugin-hook-test", "0.1.30"); + options.Models.RequestHandler = new ToolCallingModelRequestHandler(); + options.GitHub.Token = null; + await using var client = new CopilotClient(options); + var before = new TaskCompletionSource<(PreToolUseHookInput Input, string? SessionId)>( + TaskCreationOptions.RunContinuationsAsynchronously); + var after = new TaskCompletionSource<(PostToolUseHookInput Input, string? SessionId)>( + TaskCreationOptions.RunContinuationsAsynchronously); + var tool = AIFunctionFactory.Create( + () => "synthetic result", + new AIFunctionFactoryOptions { Name = "radar_test", Description = "A synthetic offline tool." }); + var config = SessionConfigBuilder.Build( + SessionPurpose.Adoption, + Options.Create(copilot), + static (_, _) => Task.FromResult(PermissionDecision.ApproveOnce()), + tools: [tool]); + ConfigureOfflineProvider(config); + config.WorkingDirectory = workspace; + config.ConfigDirectory = home; + config.Plugins.Directories = [plugin]; + config.Hooks.EnableHostHooks = hostHooksEnabled; + Assert.Null(config.Filesystem.TrustWorkingDirectory); + var availableTools = new ToolSet(); + availableTools.AddCustom("radar_test"); + config.Tools.AvailableTools = availableTools; + config.Hooks.Handlers = new SessionHooks + { + OnPreToolUse = (input, invocation) => + { + before.TrySetResult((input, invocation.SessionId)); + return Task.FromResult(null); + }, + OnPostToolUse = (input, invocation) => + { + after.TrySetResult((input, invocation.SessionId)); + return Task.FromResult(null); + }, + }; + + await using var session = await client.CreateSessionAsync(config, ct); + var response = await session.SendAndWaitAsync("Call radar_test.", TimeSpan.FromSeconds(90), ct); + var pre = await before.Task.WaitAsync(TimeSpan.FromSeconds(15), ct); + var post = await after.Task.WaitAsync(TimeSpan.FromSeconds(15), ct); + + Assert.Equal(hostHooksEnabled, File.Exists(marker)); + Assert.Equal("done", response?.Data.Content); + Assert.Equal(session.SessionId, pre.SessionId); + Assert.Equal(session.SessionId, post.SessionId); + Assert.Equal("radar_test", pre.Input.ToolName); + Assert.Equal(pre.Input.ToolName, post.Input.ToolName); + Assert.False(string.IsNullOrWhiteSpace(pre.Input.ToolCallId)); + Assert.Equal(pre.Input.ToolCallId, post.Input.ToolCallId); + Assert.NotNull(post.Input.ToolResult); + } + finally + { + Directory.Delete(root, recursive: true); + } + } + [Theory] [InlineData("standard")] [InlineData("high")] diff --git a/tests/RepoSyncRadar.App.Tests/Copilot/RadarPermissionPolicyTests.cs b/tests/RepoSyncRadar.App.Tests/Copilot/RadarPermissionPolicyTests.cs index 72fa6ae0..ba028eff 100644 --- a/tests/RepoSyncRadar.App.Tests/Copilot/RadarPermissionPolicyTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Copilot/RadarPermissionPolicyTests.cs @@ -420,6 +420,30 @@ public async Task Shell_Unknown_Is_DeniedByRules_Without_Prompt() await prompt.DidNotReceive().ConfirmAsync(Arg.Any(), Arg.Any()); } + [Theory] + [InlineData(null, false)] + [InlineData(false, false)] + [InlineData(true, false)] + [InlineData(true, true)] + public async Task Shell_ReadOnly_Hint_Does_Not_Bypass_Host_Denial(bool? readOnly, bool managedApprovalRequired) + { + var request = NewShell("tc-read-only", "git status", managedApprovalRequired); + request.ReadOnly = readOnly; + var restored = Assert.IsType( + JsonSerializer.Deserialize(JsonSerializer.Serialize(request))); + Assert.Equal(readOnly, restored.ReadOnly); + var prompt = Substitute.For(); + + var result = await CreatePolicy(prompt).HandleAsync(restored, _invocation); + + Assert.Equal(_userNotAvailableKind, result.Kind); + AssertDecisionContext( + result, + PermissionDecisionOutcome.AutopilotDenied, + PermissionDecisionSource.HostPolicy); + await prompt.DidNotReceive().ConfirmAsync(Arg.Any(), Arg.Any()); + } + [Fact] public async Task Managed_Shell_Remains_DeniedByRules_Without_Prompt() { From c9c72b05e101c2ff9dff77806c84e83e1d1431a1 Mon Sep 17 00:00:00 2001 From: SIkebe <17608272+SIkebe@users.noreply.github.com> Date: Wed, 2 Dec 2026 11:55:19 +0900 Subject: [PATCH 3/7] Fix runtime shutdown cancellation observation Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/copilot-instructions.md | 2 +- .github/skills/copilot-sdk-dotnet-audit/SKILL.md | 2 +- .../Copilot/CopilotInProcessRuntimeTests.cs | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index fbdcbcb1..cd750356 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -44,7 +44,7 @@ Use these repository instructions as the starting point. When code or validated - Write git commit messages in English. - Before creating or updating a pull request, read `.github/pull_request_template.md` and use every section in the PR body. Keep PR descriptions in English, and resolve each validation line by checking it or replacing it with `N/A - `. When the PR closes or resolves an issue, include the matching `Closes #...`, `Fixes #...`, or `Resolves #...` line explicitly in the Related Issues section. - Logging must use source-generated `[LoggerMessage]`. Do not call `_logger.LogDebug/LogInformation/LogWarning(...)` extension methods directly. Use `partial sealed class` methods such as `private static partial void LogXxx(ILogger logger, ...)`. -- In xUnit tests, pass `TestContext.Current.CancellationToken` when calling cancellable APIs. For NSubstitute `Received`/`DidNotReceive`, use `Arg.Any()` or the real token. +- In xUnit tests, pass `TestContext.Current.CancellationToken` when calling cancellable APIs. For NSubstitute `Received`/`DidNotReceive`, use `Arg.Any()` or the real token. When asserting that a pending operation was canceled, observe its `OperationCanceledException`; a separate token callback disposed while the operation unwinds can be unregistered before it runs. - WPF E2E fixtures should pass a dummy `COPILOT_GITHUB_TOKEN` into the App child process so eager startup sign-in does not enter GitHub OAuth Device Flow on CI. - E2E hosts must isolate the DPAPI store with `REPOSYNCRADAR_GITHUB_TOKEN_PATH`. Signed-in UI tests also need a dummy stored token and configured OAuth client ID; `COPILOT_GITHUB_TOKEN` alone does not set the UI auth state. - Automated policy UI tests must not send fixture tokens to live `managedSettings.resolve` endpoints. Keep WebView availability checks offline; verify policy success, failure, and redaction with injected component-test responses. diff --git a/.github/skills/copilot-sdk-dotnet-audit/SKILL.md b/.github/skills/copilot-sdk-dotnet-audit/SKILL.md index 4fd39979..51923088 100644 --- a/.github/skills/copilot-sdk-dotnet-audit/SKILL.md +++ b/.github/skills/copilot-sdk-dotnet-audit/SKILL.md @@ -175,7 +175,7 @@ Preview / experimental 機能を採用するときは、利用理由、public AP 変更した範囲に応じてテストを追加・更新する。 - SDK option wiring: `CopilotSessionFactoryTests` -- Native runtime probes: SDK を直接参照する test host で実行し、現在版の asset-copy targets が動くことを確認する。transitive App reference だけでは旧 native payload がテスト出力に残る場合があるため、managed SDK の版や ping 成功だけを新 RPC/event の対応証明にしない。 +- Native runtime probes: SDK を直接参照する test host で実行し、現在版の asset-copy targets が動くことを確認する。transitive App reference だけでは旧 native payload がテスト出力に残る場合があるため、managed SDK の版や ping 成功だけを新 RPC/event の対応証明にしない。pending inference の cancellation は待機操作の `OperationCanceledException` で確認する。unwind 中に dispose される別の token callback は実行前に解除される場合がある。 - config binding/post-configure: `OptionsValidationTests` - local settings round-trip: `FileLocalAppSettingsStoreTests` - session config/tool filters: `SessionConfigBuilderTests` diff --git a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs index e79ef131..5a27cc04 100644 --- a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs @@ -611,9 +611,17 @@ private sealed class PendingModelRequestHandler : CopilotRequestHandler protected override async Task SendRequestAsync( HttpRequestMessage request, CopilotRequestContext ctx) { - using var registration = ctx.CancellationToken.Register(() => Cancelled.TrySetResult()); Started.TrySetResult(); - await Task.Delay(Timeout.InfiniteTimeSpan, ctx.CancellationToken); + try + { + await Task.Delay(Timeout.InfiniteTimeSpan, ctx.CancellationToken); + } + catch (OperationCanceledException) when (ctx.CancellationToken.IsCancellationRequested) + { + Cancelled.TrySetResult(); + throw; + } + throw new InvalidOperationException("The pending inference must end through cancellation."); } } From 2e89423e3d7adc3f72cb4f8faa9d8cb168ebddaf Mon Sep 17 00:00:00 2001 From: SIkebe <17608272+SIkebe@users.noreply.github.com> Date: Wed, 2 Dec 2026 13:25:09 +0900 Subject: [PATCH 4/7] Update Copilot SDK to 2.0.6 preview 1 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../skills/copilot-sdk-dotnet-audit/SKILL.md | 2 +- Directory.Packages.props | 2 +- .../Settings/ThirdPartyNotices.cs | 2 +- .../Components/ThirdPartyNoticesPanelTests.cs | 2 +- .../Copilot/CopilotInProcessRuntimeTests.cs | 64 +++++++++++++++---- .../Copilot/RadarPermissionPolicyTests.cs | 45 +++++++++++++ 6 files changed, 100 insertions(+), 17 deletions(-) diff --git a/.github/skills/copilot-sdk-dotnet-audit/SKILL.md b/.github/skills/copilot-sdk-dotnet-audit/SKILL.md index 51923088..7ae6aaeb 100644 --- a/.github/skills/copilot-sdk-dotnet-audit/SKILL.md +++ b/.github/skills/copilot-sdk-dotnet-audit/SKILL.md @@ -175,7 +175,7 @@ Preview / experimental 機能を採用するときは、利用理由、public AP 変更した範囲に応じてテストを追加・更新する。 - SDK option wiring: `CopilotSessionFactoryTests` -- Native runtime probes: SDK を直接参照する test host で実行し、現在版の asset-copy targets が動くことを確認する。transitive App reference だけでは旧 native payload がテスト出力に残る場合があるため、managed SDK の版や ping 成功だけを新 RPC/event の対応証明にしない。pending inference の cancellation は待機操作の `OperationCanceledException` で確認する。unwind 中に dispose される別の token callback は実行前に解除される場合がある。 +- Native runtime probes: SDK を直接参照する test host で実行し、現在版の asset-copy targets が動くことを確認する。transitive App reference だけでは旧 native payload がテスト出力に残る場合があるため、managed SDK の版や ping 成功だけを新 RPC/event の対応証明にしない。pending inference の cancellation は待機操作の `OperationCanceledException` で確認する。unwind 中に dispose される別の token callback は実行前に解除される場合がある。Windows の command hook fixture は `timeoutSec` を明示し、送信待ちをそれより長くする。marker 不在時は `hook.end` の error を出し、timeout と設定誤りを区別する。session metadata の host trust grant を永続化された folder trust と混同せず、nullable な MCP policy を実際の server 使用状況と同一視しない。 - config binding/post-configure: `OptionsValidationTests` - local settings round-trip: `FileLocalAppSettingsStoreTests` - session config/tool filters: `SessionConfigBuilderTests` diff --git a/Directory.Packages.props b/Directory.Packages.props index e390c8f4..709dc11c 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -41,7 +41,7 @@ - + diff --git a/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs b/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs index 3518c554..bcd93785 100644 --- a/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs +++ b/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs @@ -13,7 +13,7 @@ public static class ThirdPartyNotices { public static IReadOnlyList All { get; } = [ - Mit("Microsoft.Copilot.SDK", "2.0.6-preview.0", "Copyright (c) Microsoft Corporation. All rights reserved.", "https://github.com/github/copilot-sdk"), + Mit("Microsoft.Copilot.SDK", "2.0.6-preview.1", "Copyright (c) Microsoft Corporation. All rights reserved.", "https://github.com/github/copilot-sdk"), new( "Markdig", "1.2.0", diff --git a/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs b/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs index 6b972a78..14f80c4f 100644 --- a/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs @@ -28,7 +28,7 @@ public void Renders_Third_Party_Notices() Assert.Contains("MudBlazor", packages); var sdkIndex = Array.IndexOf(packages, "Microsoft.Copilot.SDK"); Assert.NotEqual(-1, sdkIndex); - Assert.Equal("2.0.6-preview.0", versions[sdkIndex]); + Assert.Equal("2.0.6-preview.1", versions[sdkIndex]); Assert.Contains("Microsoft.Web.WebView2", packages); Assert.Contains("BSD-2-Clause", cut.Markup, StringComparison.Ordinal); Assert.Contains("MIT", cut.Markup, StringComparison.Ordinal); diff --git a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs index 5a27cc04..2cccdc24 100644 --- a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs @@ -1,5 +1,7 @@ using Microsoft.Copilot; using Microsoft.Copilot.Rpc; +using System.Collections.Concurrent; +using System.Diagnostics; using System.Net; using System.Net.Http; using System.Runtime.InteropServices; @@ -16,6 +18,8 @@ namespace RepoSyncRadar.App.Tests.Copilot; public sealed class CopilotInProcessRuntimeTests { + private static readonly string[] HookCommandArgs = ["/d", "/c", "echo invoked > hook-invoked.txt"]; + [Fact] public void Native_Library_Matches_The_Bundled_Runtime_Node() { @@ -41,7 +45,7 @@ public async Task PingAsync_Connects_To_Bundled_InProcess_Runtime() var status = await client.GetStatusAsync(TestContext.Current.CancellationToken); Assert.Equal("pong: in-process", response.Message); - Assert.Equal("1.0.119-0", status.Version); + Assert.Equal("1.0.119-1", status.Version); } #pragma warning disable MCPSDK001 // Exercise experimental public APIs against the bundled native runtime. @@ -57,7 +61,6 @@ public async Task Host_Hook_Selection_Preserves_Sdk_Tool_Audit_Callbacks(bool ho Directory.CreateDirectory(hookDirectory); try { - var escapedMarker = marker.Replace("'", "''", StringComparison.Ordinal); var hookJson = System.Text.Json.JsonSerializer.Serialize(new { version = 1, @@ -65,7 +68,14 @@ public async Task Host_Hook_Selection_Preserves_Sdk_Tool_Audit_Callbacks(bool ho { preToolUse = new[] { - new { type = "command", powershell = $"Set-Content -LiteralPath '{escapedMarker}' -Value invoked" }, + new + { + type = "command", + exec = Path.Combine(Environment.SystemDirectory, "cmd.exe"), + args = HookCommandArgs, + cwd = home, + timeoutSec = 60, + }, }, }, }); @@ -111,11 +121,14 @@ public async Task Host_Hook_Selection_Preserves_Sdk_Tool_Audit_Callbacks(bool ho }; await using var session = await client.CreateSessionAsync(config, ct); - var response = await session.SendAndWaitAsync("Call radar_test.", TimeSpan.FromSeconds(45), ct); + var hookEvents = new ConcurrentQueue(); + using var subscription = CaptureHookEvents(session, hookEvents); + var response = await session.SendAndWaitAsync("Call radar_test.", TimeSpan.FromSeconds(90), ct); + + Assert.True(hostHooksEnabled == File.Exists(marker), + $"Host hooks enabled: {hostHooksEnabled}; response: {response?.Data.Content}; hook events: {string.Join("; ", hookEvents)}"); var pre = await before.Task.WaitAsync(TimeSpan.FromSeconds(15), ct); var post = await after.Task.WaitAsync(TimeSpan.FromSeconds(15), ct); - - Assert.Equal(hostHooksEnabled, File.Exists(marker)); Assert.Equal("done", response?.Data.Content); Assert.Equal(session.SessionId, pre.SessionId); Assert.Equal(session.SessionId, post.SessionId); @@ -132,9 +145,11 @@ public async Task Host_Hook_Selection_Preserves_Sdk_Tool_Audit_Callbacks(bool ho } [Theory] - [InlineData(false)] - [InlineData(true)] - public async Task Host_Hook_Selection_Controls_Plugin_Hooks_Without_Workspace_Trust_Grant(bool hostHooksEnabled) + [InlineData(false, false, false)] + [InlineData(true, false, false)] + [InlineData(false, true, true)] + public async Task Host_Hook_Selection_Controls_Plugin_Hooks_Across_Trust_And_Config_Discovery( + bool hostHooksEnabled, bool trustWorkingDirectory, bool enableConfigDiscovery) { var ct = TestContext.Current.CancellationToken; var root = Path.Combine(Path.GetTempPath(), $"reposyncradar-plugin-hooks-{Guid.NewGuid():N}"); @@ -149,7 +164,6 @@ public async Task Host_Hook_Selection_Controls_Plugin_Hooks_Without_Workspace_Tr { await File.WriteAllTextAsync( Path.Combine(plugin, "plugin.json"), """{"name":"hook-fixture","version":"1.0.0"}""", ct); - var escapedMarker = marker.Replace("'", "''", StringComparison.Ordinal); var hookJson = System.Text.Json.JsonSerializer.Serialize(new { version = 1, @@ -160,7 +174,9 @@ await File.WriteAllTextAsync( new { type = "command", - powershell = $"Set-Content -LiteralPath '{escapedMarker}' -Value invoked", + exec = Path.Combine(Environment.SystemDirectory, "cmd.exe"), + args = HookCommandArgs, + cwd = root, timeoutSec = 60, }, }, @@ -190,7 +206,15 @@ await File.WriteAllTextAsync( config.ConfigDirectory = home; config.Plugins.Directories = [plugin]; config.Hooks.EnableHostHooks = hostHooksEnabled; - Assert.Null(config.Filesystem.TrustWorkingDirectory); + if (trustWorkingDirectory) + { + config.Filesystem.TrustWorkingDirectory = WorkingDirectoryTrust.Session; + } + if (enableConfigDiscovery) + { + config.EnableConfigDiscovery = true; + config.Extensions.Enabled = false; + } var availableTools = new ToolSet(); availableTools.AddCustom("radar_test"); config.Tools.AvailableTools = availableTools; @@ -209,11 +233,18 @@ await File.WriteAllTextAsync( }; await using var session = await client.CreateSessionAsync(config, ct); + var metadata = await session.Rpc.Metadata.SnapshotAsync(ct); + var hookEvents = new ConcurrentQueue(); + using var subscription = CaptureHookEvents(session, hookEvents); var response = await session.SendAndWaitAsync("Call radar_test.", TimeSpan.FromSeconds(90), ct); + + Assert.True(hostHooksEnabled == File.Exists(marker), + $"Host hooks enabled: {hostHooksEnabled}; response: {response?.Data.Content}; hook events: {string.Join("; ", hookEvents)}"); var pre = await before.Task.WaitAsync(TimeSpan.FromSeconds(15), ct); var post = await after.Task.WaitAsync(TimeSpan.FromSeconds(15), ct); - Assert.Equal(hostHooksEnabled, File.Exists(marker)); + Assert.Equal(trustWorkingDirectory, metadata.AuthoritativeWorkspaceTrust); + Assert.Equal(enableConfigDiscovery, metadata.EnableConfigDiscovery); Assert.Equal("done", response?.Data.Content); Assert.Equal(session.SessionId, pre.SessionId); Assert.Equal(session.SessionId, post.SessionId); @@ -229,6 +260,13 @@ await File.WriteAllTextAsync( } } + private static IDisposable CaptureHookEvents(CopilotSession session, ConcurrentQueue hookEvents) + { + var elapsed = Stopwatch.StartNew(); + return session.On(evt => hookEvents.Enqueue( + $"{elapsed.Elapsed}: {evt.Data.HookType}: success={evt.Data.Success}, error={evt.Data.Error?.Message}")); + } + [Theory] [InlineData("standard")] [InlineData("high")] diff --git a/tests/RepoSyncRadar.App.Tests/Copilot/RadarPermissionPolicyTests.cs b/tests/RepoSyncRadar.App.Tests/Copilot/RadarPermissionPolicyTests.cs index ba028eff..af1f6c3a 100644 --- a/tests/RepoSyncRadar.App.Tests/Copilot/RadarPermissionPolicyTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Copilot/RadarPermissionPolicyTests.cs @@ -485,6 +485,51 @@ public async Task Managed_Unknown_Kind_Remains_DeniedByRules() await prompt.DidNotReceive().ConfirmAsync(Arg.Any(), Arg.Any()); } + [Theory] + [InlineData(false, false)] + [InlineData(true, false)] + [InlineData(true, true)] + public async Task Workflow_Arguments_Do_Not_Change_Denial_Or_Appear_In_Logs( + bool hasArguments, bool managedApprovalRequired) + { + const string privateValue = "private-workflow-argument"; + var request = new PermissionRequestWorkflow + { + ApprovalKey = "workflow-fixture", + Args = hasArguments ? JsonSerializer.SerializeToElement(new { input = privateValue }) : null, + CanPersistApproval = false, + Description = "A synthetic workflow.", + ManagedApprovalRequired = managedApprovalRequired, + Name = "fixture", + Operation = new WorkflowPermissionOperation("run"), + Phases = [], + ToolCallId = "tc-workflow", + }; + var restored = Assert.IsType( + JsonSerializer.Deserialize(JsonSerializer.Serialize(request))); + Assert.Equal(hasArguments, restored.Args.HasValue); + if (hasArguments) + { + Assert.Equal(privateValue, restored.Args?.GetProperty("input").GetString()); + } + var prompt = Substitute.For(); + var logger = new CapturingLogger(); + var policy = new RadarPermissionPolicy( + new UrlAllowList(Options.Create(new CopilotOptions())), prompt, logger); + + var result = await policy.HandleAsync(restored, _invocation); + + Assert.Equal(_userNotAvailableKind, result.Kind); + AssertDecisionContext( + result, + PermissionDecisionOutcome.AutopilotDenied, + PermissionDecisionSource.HostPolicy); + await prompt.DidNotReceive().ConfirmAsync(Arg.Any(), Arg.Any()); + Assert.NotEmpty(logger.Entries); + Assert.All(logger.Entries, entry => + Assert.DoesNotContain(privateValue, entry.Message, StringComparison.Ordinal)); + } + [Theory] [InlineData(null, false)] [InlineData("radar_list_commits", false)] From f6b280b125eb9a0266368414c3c52f4fa9b9d508 Mon Sep 17 00:00:00 2001 From: SIkebe <17608272+SIkebe@users.noreply.github.com> Date: Thu, 3 Dec 2026 00:00:35 +0900 Subject: [PATCH 5/7] Update Copilot SDK to 2.0.6 preview 2 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/copilot-instructions.md | 2 +- Directory.Packages.props | 2 +- docs/USAGE.md | 2 +- .../Copilot/CopilotSessionFactory.cs | 10 ++++++++++ .../Settings/ThirdPartyNotices.cs | 2 +- .../Components/ThirdPartyNoticesPanelTests.cs | 2 +- .../Copilot/CopilotInProcessRuntimeTests.cs | 9 ++++++++- .../Copilot/CopilotSessionFactoryTests.cs | 17 +++++++++++++++++ 8 files changed, 40 insertions(+), 6 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index cd750356..250f2c87 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -76,7 +76,7 @@ Use these repository instructions as the starting point. When code or validated - SDK 2.x (`Microsoft.Copilot.SDK`, namespace `Microsoft.Copilot`, experimental diagnostic `MCPSDK001`) groups client/session settings. Set `CopilotClientOptions.Mode = CopilotClientMode.CodingAgent` to keep the v1 runtime defaults; `Empty` changes persistence and auth. Offline BYOK runtime tests must use named providers, `GitHub.Capi.Enabled = false`, and a null client `GitHub.Token`, because session creation validates any supplied GitHub token against the live API. - RepoSyncRadar uses `RuntimeConnection.ForInProcess()` exclusively; per-client `Environment` and `WorkingDirectory` are unsupported. The SDK supports typed in-process `Telemetry`, but the app intentionally does not configure exporters or content capture. Verify native runtime startup, a model turn, and shutdown in installed-package smoke before a release. - Keep session file-change tracking disabled until RepoSyncRadar has a user-visible rewind flow; current radar tools do not edit workspace files. -- Start all app-owned sessions with `PermissionMode.Manual` and verify `PermissionModeResult` before exposing them. Keep runtime Auto recovery disabled until consent and recovery outcomes are wired to the visible fallback tracker; never silently resend an active request. +- Start all app-owned sessions with `PermissionMode.Manual`; before exposing them, verify `PermissionModeResult` and require `Permissions.GetAllowAllAsync().ApproveAllTools` to report false. Treat true or unreported as unconfirmed, not manual approval. Keep runtime Auto recovery disabled until consent and recovery outcomes are wired to the visible fallback tracker; never silently resend an active request. - Treat SDK capabilities as unavailable until confirmed in the installed package's public API. Do not rely on runtime internals or prompt-only structured-output guarantees. - Promote `model.call_final_result` failure codes only for root `session.error` events with `errorType: "query"`; consume the pending result so unrelated errors cannot reuse it. - Managed-policy UI must use safe display DTOs, distinguish missing from empty/false, preserve per-source allowlist intersection, and cover the bundled runtime schema. Use SDK effective model/effort/context/Fusion values and per-control provenance; never replace an explicit `unmanaged` with legacy Auto. Label runtime `fusionTier` projections from legacy Auto when the returned layers establish that no layer supplies `fusionTier`; do not infer that origin when layers are absent. Policy preferences do not prove execution support. Redact originally requested values through the same allowlist. Bound each entry to 32 values plus one trailing omission marker across nested values and sources. Show app-injected restrictions separately using the shared session configuration, not a duplicated policy definition. diff --git a/Directory.Packages.props b/Directory.Packages.props index 709dc11c..45e6eb1e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -41,7 +41,7 @@ - + diff --git a/docs/USAGE.md b/docs/USAGE.md index 6a6db85b..cd8641ad 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -130,7 +130,7 @@ VS Code 専用の `vscode.temporaryDefaultToLocalHarness` は、未報告・空 **アプリが注入する権限制限(別枠)** には、セッション作成コードと共通の設定から、権限確認の迂回禁止、AI による権限承認の禁止、`shell` の拒否を表示します。アプリによる明示的な自動承認以外は、従来どおりユーザーが判断します。管理ポリシーの診断スナップショットにはこの層は含まれず、別枠の一覧も実セッションでの適用確認やツールごとの追加承認判断を示すものではありません。 -すべての Copilot セッションは起動時に Manual 権限モードを明示し、SDK がその適用を確認できない場合は処理を開始せずエラーを表示します。進行中の要求を Auto モデルへ切り替えるランタイムの復旧機能は有効にしていません。セッション作成時の代替モデル選択は、上記の通知付きのアプリ側処理を維持します。 +すべての Copilot セッションは起動時に Manual 権限モードを明示し、SDK がその適用とツールの一括自動承認が無効であることを確認できない場合は処理を開始せずエラーを表示します。進行中の要求を Auto モデルへ切り替えるランタイムの復旧機能は有効にしていません。セッション作成時の代替モデル選択は、上記の通知付きのアプリ側処理を維持します。 Triage・下書き再生成・まとめて解説のモデル処理が失敗した場合、SDK が最終結果を報告した範囲で、入力過大、レート制限、リクエスト拒否、サービス障害、通信障害を区別して対処方法を表示します。キャンセルやタイムアウトを別の障害に置き換えず、自動で再送しません。分類できない場合は従来のエラー表示を維持します。この結果イベントはモデル処理単位であり、ワークフロー成功や課金リクエスト数を表すものではありません。 diff --git a/src/RepoSyncRadar.App/Copilot/CopilotSessionFactory.cs b/src/RepoSyncRadar.App/Copilot/CopilotSessionFactory.cs index d79cdec7..7e5eab6f 100644 --- a/src/RepoSyncRadar.App/Copilot/CopilotSessionFactory.cs +++ b/src/RepoSyncRadar.App/Copilot/CopilotSessionFactory.cs @@ -136,6 +136,8 @@ public async Task CreateSessionAsync( try { ValidatePermissionMode(session.PermissionModeResult); + var permissions = await session.Rpc.Permissions.GetAllowAllAsync(cancellationToken).ConfigureAwait(false); + ValidateNoBlanketToolApproval(permissions.ApproveAllTools); } catch { @@ -155,6 +157,14 @@ internal static void ValidatePermissionMode(PermissionsSetModeResult? result) throw new InvalidOperationException("Copilot did not confirm manual permission mode for the session."); } } + + internal static void ValidateNoBlanketToolApproval(bool? approveAllTools) + { + if (approveAllTools is not false) + { + throw new InvalidOperationException("Copilot did not confirm that blanket tool approval is disabled for the session."); + } + } #pragma warning restore MCPSDK001 /// diff --git a/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs b/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs index bcd93785..12876572 100644 --- a/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs +++ b/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs @@ -13,7 +13,7 @@ public static class ThirdPartyNotices { public static IReadOnlyList All { get; } = [ - Mit("Microsoft.Copilot.SDK", "2.0.6-preview.1", "Copyright (c) Microsoft Corporation. All rights reserved.", "https://github.com/github/copilot-sdk"), + Mit("Microsoft.Copilot.SDK", "2.0.6-preview.2", "Copyright (c) Microsoft Corporation. All rights reserved.", "https://github.com/github/copilot-sdk"), new( "Markdig", "1.2.0", diff --git a/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs b/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs index 14f80c4f..40abe9fe 100644 --- a/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs @@ -28,7 +28,7 @@ public void Renders_Third_Party_Notices() Assert.Contains("MudBlazor", packages); var sdkIndex = Array.IndexOf(packages, "Microsoft.Copilot.SDK"); Assert.NotEqual(-1, sdkIndex); - Assert.Equal("2.0.6-preview.1", versions[sdkIndex]); + Assert.Equal("2.0.6-preview.2", versions[sdkIndex]); Assert.Contains("Microsoft.Web.WebView2", packages); Assert.Contains("BSD-2-Clause", cut.Markup, StringComparison.Ordinal); Assert.Contains("MIT", cut.Markup, StringComparison.Ordinal); diff --git a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs index 2cccdc24..161ca60c 100644 --- a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs @@ -45,7 +45,7 @@ public async Task PingAsync_Connects_To_Bundled_InProcess_Runtime() var status = await client.GetStatusAsync(TestContext.Current.CancellationToken); Assert.Equal("pong: in-process", response.Message); - Assert.Equal("1.0.119-1", status.Version); + Assert.Equal("1.0.119-3", status.Version); } #pragma warning disable MCPSDK001 // Exercise experimental public APIs against the bundled native runtime. @@ -384,6 +384,8 @@ public async Task App_Policy_Allows_Manual_Mode_And_Blocks_Assisted_Approval() Assert.Equal(PermissionMode.Manual, session.PermissionModeResult.Mode); var initialMode = await session.Rpc.Permissions.GetModeAsync(ct); Assert.Equal(PermissionMode.Manual, initialMode.Mode); + var initialPermissions = await session.Rpc.Permissions.GetAllowAllAsync(ct); + Assert.Equal(false, initialPermissions.ApproveAllTools); var enforced = new TaskCompletionSource( TaskCreationOptions.RunContinuationsAsynchronously); using var subscription = session.On(evt => @@ -404,6 +406,11 @@ public async Task App_Policy_Allows_Manual_Mode_And_Blocks_Assisted_Approval() var capabilities = await session.Rpc.Permissions.GetCapabilitiesAsync(ct); Assert.False(capabilities.AssistedApproval); Assert.False(capabilities.BypassPermissions); + var approveAllError = await Assert.ThrowsAsync( + () => session.Rpc.Permissions.SetApproveAllAsync(true, cancellationToken: ct)); + Assert.Contains("disabled by policy", approveAllError.Message, StringComparison.OrdinalIgnoreCase); + var currentPermissions = await session.Rpc.Permissions.GetAllowAllAsync(ct); + Assert.Equal(false, currentPermissions.ApproveAllTools); } [Fact] diff --git a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotSessionFactoryTests.cs b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotSessionFactoryTests.cs index 80f4209e..15749a08 100644 --- a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotSessionFactoryTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotSessionFactoryTests.cs @@ -48,6 +48,23 @@ public void ValidatePermissionMode_Rejects_Missing_Result() { Assert.Throws(() => CopilotSessionFactory.ValidatePermissionMode(null)); } + + [Fact] + public void ValidateNoBlanketToolApproval_Accepts_Confirmed_False() + { + CopilotSessionFactory.ValidateNoBlanketToolApproval(false); + } + + [Theory] + [InlineData(true)] + [InlineData(null)] + public void ValidateNoBlanketToolApproval_Rejects_Enabled_Or_Unreported(bool? approveAllTools) + { + var exception = Assert.Throws( + () => CopilotSessionFactory.ValidateNoBlanketToolApproval(approveAllTools)); + + Assert.Equal("Copilot did not confirm that blanket tool approval is disabled for the session.", exception.Message); + } #pragma warning restore MCPSDK001 [Fact] From ba5d4bb7b7ef93f2eda4afa3d7dad5cab18ee450 Mon Sep 17 00:00:00 2001 From: SIkebe <17608272+SIkebe@users.noreply.github.com> Date: Thu, 3 Dec 2026 00:13:08 +0900 Subject: [PATCH 6/7] Update Copilot SDK to 2.0.6 preview 3 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/copilot-instructions.md | 2 +- Directory.Packages.props | 2 +- docs/USAGE.md | 2 +- .../Copilot/CopilotModelFailure.cs | 11 ++- .../Resources/SharedResource.en.resx | 2 + .../Resources/SharedResource.resx | 2 + .../Settings/ThirdPartyNotices.cs | 2 +- .../Components/AppHeaderTests.cs | 15 ++-- .../Components/ThirdPartyNoticesPanelTests.cs | 2 +- .../Copilot/CopilotInProcessRuntimeTests.cs | 70 ++++++++++++++++++- .../Copilot/CopilotModelFailureTests.cs | 57 +++++++++++++++ 11 files changed, 154 insertions(+), 13 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 250f2c87..c386d322 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -78,7 +78,7 @@ Use these repository instructions as the starting point. When code or validated - Keep session file-change tracking disabled until RepoSyncRadar has a user-visible rewind flow; current radar tools do not edit workspace files. - Start all app-owned sessions with `PermissionMode.Manual`; before exposing them, verify `PermissionModeResult` and require `Permissions.GetAllowAllAsync().ApproveAllTools` to report false. Treat true or unreported as unconfirmed, not manual approval. Keep runtime Auto recovery disabled until consent and recovery outcomes are wired to the visible fallback tracker; never silently resend an active request. - Treat SDK capabilities as unavailable until confirmed in the installed package's public API. Do not rely on runtime internals or prompt-only structured-output guarantees. -- Promote `model.call_final_result` failure codes only for root `session.error` events with `errorType: "query"`; consume the pending result so unrelated errors cannot reuse it. +- Promote `model.call_final_result` failure codes only for root `session.error` events with `errorType: "query"`; consume the pending result so unrelated errors cannot reuse it. Classify the runtime's `empty_turn` and `static_context_blocked` codes only for root query errors, without inferring retry advice. - Managed-policy UI must use safe display DTOs, distinguish missing from empty/false, preserve per-source allowlist intersection, and cover the bundled runtime schema. Use SDK effective model/effort/context/Fusion values and per-control provenance; never replace an explicit `unmanaged` with legacy Auto. Label runtime `fusionTier` projections from legacy Auto when the returned layers establish that no layer supplies `fusionTier`; do not infer that origin when layers are absent. Policy preferences do not prove execution support. Redact originally requested values through the same allowlist. Bound each entry to 32 values plus one trailing omission marker across nested values and sources. Show app-injected restrictions separately using the shared session configuration, not a duplicated policy definition. - The SDK downloads a SHA-256-verified GitHub Release native runtime bundle. Published builds must preserve every SDK-generated runtime asset, including `copilot_runtime.dll`, `runtime.node`, hidden marker files, and nested runtime dependencies; a standalone `copilot.exe` is not a substitute. diff --git a/Directory.Packages.props b/Directory.Packages.props index 45e6eb1e..bab38b3e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -41,7 +41,7 @@ - + diff --git a/docs/USAGE.md b/docs/USAGE.md index cd8641ad..0f973d5c 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -132,7 +132,7 @@ VS Code 専用の `vscode.temporaryDefaultToLocalHarness` は、未報告・空 すべての Copilot セッションは起動時に Manual 権限モードを明示し、SDK がその適用とツールの一括自動承認が無効であることを確認できない場合は処理を開始せずエラーを表示します。進行中の要求を Auto モデルへ切り替えるランタイムの復旧機能は有効にしていません。セッション作成時の代替モデル選択は、上記の通知付きのアプリ側処理を維持します。 -Triage・下書き再生成・まとめて解説のモデル処理が失敗した場合、SDK が最終結果を報告した範囲で、入力過大、レート制限、リクエスト拒否、サービス障害、通信障害を区別して対処方法を表示します。キャンセルやタイムアウトを別の障害に置き換えず、自動で再送しません。分類できない場合は従来のエラー表示を維持します。この結果イベントはモデル処理単位であり、ワークフロー成功や課金リクエスト数を表すものではありません。 +Triage・下書き再生成・まとめて解説のモデル処理が失敗した場合、SDK が最終結果を報告した範囲で、入力過大、レート制限、リクエスト拒否、サービス障害、通信障害を区別して対処方法を表示します。SDK が該当する query エラーコードを報告した場合は、表示可能な出力のない処理と静的コンテキスト枠の超過も区別します。キャンセルやタイムアウトを別の障害に置き換えず、自動で再送しません。分類できない場合は従来のエラー表示を維持します。この結果イベントはモデル処理単位であり、ワークフロー成功や課金リクエスト数を表すものではありません。 ### 2.4 起動 diff --git a/src/RepoSyncRadar.App/Copilot/CopilotModelFailure.cs b/src/RepoSyncRadar.App/Copilot/CopilotModelFailure.cs index 0ab7821b..fd39a387 100644 --- a/src/RepoSyncRadar.App/Copilot/CopilotModelFailure.cs +++ b/src/RepoSyncRadar.App/Copilot/CopilotModelFailure.cs @@ -11,6 +11,8 @@ public enum CopilotModelFailureKind RequestRejected, ServerError, TransportError, + EmptyTurn, + StaticContextBlocked, } public sealed class CopilotModelFailureException(CopilotModelFailureKind kind, Exception innerException) @@ -49,7 +51,14 @@ internal void Observe(SessionEvent evt) } else if (evt is SessionErrorEvent error) { - _failed = error.Data.ErrorType == "query" ? _latest : null; + _failed = error.Data.ErrorType == "query" + ? error.Data.ErrorCode switch + { + "empty_turn" => CopilotModelFailureKind.EmptyTurn, + "static_context_blocked" => CopilotModelFailureKind.StaticContextBlocked, + _ => _latest, + } + : null; _latest = null; } else if (evt is ModelCallStartEvent or AssistantTurnStartEvent or ToolExecutionStartEvent) diff --git a/src/RepoSyncRadar.App/Resources/SharedResource.en.resx b/src/RepoSyncRadar.App/Resources/SharedResource.en.resx index 694c760a..9d7f90ab 100644 --- a/src/RepoSyncRadar.App/Resources/SharedResource.en.resx +++ b/src/RepoSyncRadar.App/Resources/SharedResource.en.resx @@ -22,6 +22,8 @@ The model rejected the request (HTTP 4xx). Check sign-in, model access, and policy before generating again. The model service failed (HTTP 5xx). Wait before generating again. The model connection failed. Check your network before generating again. + Copilot completed the turn without visible output. + The model's context budget is too small for the system instructions and tool definitions. Yes No text/microsoft-resx diff --git a/src/RepoSyncRadar.App/Resources/SharedResource.resx b/src/RepoSyncRadar.App/Resources/SharedResource.resx index 27e396c2..ca41ca70 100644 --- a/src/RepoSyncRadar.App/Resources/SharedResource.resx +++ b/src/RepoSyncRadar.App/Resources/SharedResource.resx @@ -22,6 +22,8 @@ モデルがリクエストを拒否しました(HTTP 4xx)。サインイン、モデルの利用権限、ポリシーを確認してから再生成してください。 モデルのサービス側で障害が発生しました(HTTP 5xx)。時間を置いてから再生成してください。 モデルとの通信に失敗しました。ネットワークを確認してから再生成してください。 + Copilot の処理が表示可能な出力を返さずに終了しました。 + システム指示とツール定義がモデルのコンテキスト枠を超えたため、処理できませんでした。 あり なし text/microsoft-resx diff --git a/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs b/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs index 12876572..da5e2f8d 100644 --- a/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs +++ b/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs @@ -13,7 +13,7 @@ public static class ThirdPartyNotices { public static IReadOnlyList All { get; } = [ - Mit("Microsoft.Copilot.SDK", "2.0.6-preview.2", "Copyright (c) Microsoft Corporation. All rights reserved.", "https://github.com/github/copilot-sdk"), + Mit("Microsoft.Copilot.SDK", "2.0.6-preview.3", "Copyright (c) Microsoft Corporation. All rights reserved.", "https://github.com/github/copilot-sdk"), new( "Markdig", "1.2.0", diff --git a/tests/RepoSyncRadar.App.Tests/Components/AppHeaderTests.cs b/tests/RepoSyncRadar.App.Tests/Components/AppHeaderTests.cs index eb3e3c32..856d7ddf 100644 --- a/tests/RepoSyncRadar.App.Tests/Components/AppHeaderTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Components/AppHeaderTests.cs @@ -557,9 +557,12 @@ public void Triage_Progress_Uses_Current_Work_Label_For_Busy_Status_Without_Coun } [Theory] - [InlineData(false)] - [InlineData(true)] - public void Triage_Failure_Shows_Error_Without_Publishing_Broadcaster(bool classified) + [InlineData(null, "network down")] + [InlineData(CopilotModelFailureKind.RateLimited, "レート制限")] + [InlineData(CopilotModelFailureKind.EmptyTurn, "表示可能な出力")] + [InlineData(CopilotModelFailureKind.StaticContextBlocked, "コンテキスト枠")] + public void Triage_Failure_Shows_Error_Without_Publishing_Broadcaster( + CopilotModelFailureKind? failureKind, string expectedMessage) { var session = Substitute.For(); session @@ -572,8 +575,8 @@ public void Triage_Failure_Shows_Error_Without_Publishing_Broadcaster(bool class var sp = BuildServices(session, out var agent, out var broadcaster); agent .RunMorningTriageAsync(Arg.Any?>(), Arg.Any()) - .ThrowsAsync(classified - ? new CopilotModelFailureException(CopilotModelFailureKind.RateLimited, new InvalidOperationException("private-model-details")) + .ThrowsAsync(failureKind is { } kind + ? new CopilotModelFailureException(kind, new InvalidOperationException("private-model-details")) : new InvalidOperationException("network down")); using var ctx = new Bunit.BunitContext(); @@ -584,7 +587,7 @@ public void Triage_Failure_Shows_Error_Without_Publishing_Broadcaster(bool class var err = cut.Find("[data-testid=\"app-header-error\"]"); Assert.Contains("Triage 失敗", err.TextContent); - Assert.Contains(classified ? "レート制限" : "network down", err.TextContent); + Assert.Contains(expectedMessage, err.TextContent); Assert.DoesNotContain("private-model-details", err.TextContent, StringComparison.Ordinal); broadcaster.DidNotReceive().Publish(); } diff --git a/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs b/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs index 40abe9fe..48cebd11 100644 --- a/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs @@ -28,7 +28,7 @@ public void Renders_Third_Party_Notices() Assert.Contains("MudBlazor", packages); var sdkIndex = Array.IndexOf(packages, "Microsoft.Copilot.SDK"); Assert.NotEqual(-1, sdkIndex); - Assert.Equal("2.0.6-preview.2", versions[sdkIndex]); + Assert.Equal("2.0.6-preview.3", versions[sdkIndex]); Assert.Contains("Microsoft.Web.WebView2", packages); Assert.Contains("BSD-2-Clause", cut.Markup, StringComparison.Ordinal); Assert.Contains("MIT", cut.Markup, StringComparison.Ordinal); diff --git a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs index 161ca60c..983e8e29 100644 --- a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs @@ -45,7 +45,7 @@ public async Task PingAsync_Connects_To_Bundled_InProcess_Runtime() var status = await client.GetStatusAsync(TestContext.Current.CancellationToken); Assert.Equal("pong: in-process", response.Message); - Assert.Equal("1.0.119-3", status.Version); + Assert.Equal("1.0.119-4", status.Version); } #pragma warning disable MCPSDK001 // Exercise experimental public APIs against the bundled native runtime. @@ -619,6 +619,54 @@ public async Task Final_Model_Error_From_Native_Runtime_Is_Classified_Without_Re Assert.All(handler.AgentInvocationIds, id => Assert.False(string.IsNullOrWhiteSpace(id))); } + [Theory] + [InlineData(false, "empty_turn", CopilotModelFailureKind.EmptyTurn)] + [InlineData(true, "static_context_blocked", CopilotModelFailureKind.StaticContextBlocked)] + public async Task Query_Error_Code_From_Native_Runtime_Is_Classified_Without_Real_Inference( + bool oversizedStaticContext, string code, CopilotModelFailureKind kind) + { + var handler = new EmptyModelRequestHandler(); + var options = CopilotSessionFactory.BuildClientOptions( + new CopilotOptions(), NullLogger.Instance, "offline-query-error-test", "0.1.30"); + options.Models.RequestHandler = handler; + options.GitHub.Token = null; + await using var client = new CopilotClient(options); + var config = SessionConfigBuilder.Build(SessionPurpose.Adoption, + Options.Create(new CopilotOptions()), + static (_, _) => Task.FromResult(PermissionDecision.Reject("Offline test denies all tools."))); + ConfigureOfflineProvider(config); + if (oversizedStaticContext) + { + config.SystemMessage = new SystemMessageConfig + { + Mode = SystemMessageMode.Append, + Content = string.Concat(Enumerable.Repeat("Static context budget probe. ", 4000)), + }; + var model = Assert.Single(config.Inference.Models!); + model.MaxContextWindowTokens = 8192; + model.MaxPromptTokens = 4096; + model.MaxOutputTokens = 512; + } + + var ct = TestContext.Current.CancellationToken; + var sdkSession = await client.CreateSessionAsync(config, ct); + var errors = new ConcurrentQueue(); + using var subscription = sdkSession.On(evt => + errors.Enqueue($"{evt.Data.ErrorType}:{evt.Data.ErrorCode}")); + await using var session = new SdkCopilotSession(sdkSession, SessionPurpose.Adoption, NullLogger.Instance, null); + + var failure = await Record.ExceptionAsync(async () => + await session.SendAsync("Offline query error probe.", TimeSpan.FromSeconds(90), ct)); + + Assert.Contains($"query:{code}", errors); + var classified = Assert.IsType(failure); + Assert.Equal(kind, classified.Kind); + if (!oversizedStaticContext) + { + Assert.True(handler.RequestCount > 0); + } + } + [Theory] [InlineData(false)] [InlineData(true)] @@ -712,6 +760,26 @@ protected override Task SendRequestAsync(HttpRequestMessage } } + private sealed class EmptyModelRequestHandler : CopilotRequestHandler + { + private int _requestCount; + internal int RequestCount => Volatile.Read(ref _requestCount); + + protected override Task SendRequestAsync(HttpRequestMessage request, CopilotRequestContext ctx) + { + Interlocked.Increment(ref _requestCount); + const string response = + """data: {"id":"chatcmpl-empty","object":"chat.completion.chunk","created":1,"model":"gpt-5.5","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}""" + + "\n\n" + + """data: {"id":"chatcmpl-empty","object":"chat.completion.chunk","created":1,"model":"gpt-5.5","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}""" + + "\n\ndata: [DONE]\n\n"; + return Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(response, Encoding.UTF8, "text/event-stream"), + }); + } + } + private sealed class ToolCallingModelRequestHandler : CopilotRequestHandler { private const string _toolResponse = diff --git a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotModelFailureTests.cs b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotModelFailureTests.cs index 7001fd5b..f9dd8633 100644 --- a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotModelFailureTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotModelFailureTests.cs @@ -50,6 +50,60 @@ public void Final_Result_Classifies_Actual_Session_Error_And_Preserves_Cause(str Assert.Same(original, classified.InnerException); } + [Theory] + [InlineData("empty_turn", CopilotModelFailureKind.EmptyTurn)] + [InlineData("static_context_blocked", CopilotModelFailureKind.StaticContextBlocked)] + public void Query_Error_Code_Classifies_Without_A_Model_Result(string code, CopilotModelFailureKind kind) + { + var collector = new CopilotModelFailureCollector(); + collector.Observe(CodedError(code)); + var original = new InvalidOperationException("runtime error"); + + var classified = Assert.IsType(collector.Classify(original)); + + Assert.Equal(kind, classified.Kind); + Assert.Same(original, classified.InnerException); + Assert.Null(collector.Classify(new OperationCanceledException(TestContext.Current.CancellationToken))); + Assert.Null(collector.Classify(new TimeoutException())); + } + + [Theory] + [InlineData("empty_turn")] + [InlineData("static_context_blocked")] + public void Coded_NonQuery_And_Subagent_Errors_Do_Not_Classify_Root_Send(string code) + { + var collector = new CopilotModelFailureCollector(); + collector.Observe(CodedError(code, "notification")); + Assert.Null(collector.Classify(new InvalidOperationException())); + + var subagentError = CodedError(code); + subagentError.AgentId = "subagent"; + collector.Observe(subagentError); + Assert.Null(collector.Classify(new InvalidOperationException())); + } + + [Fact] + public void Unknown_Query_Error_Code_Preserves_Final_Model_Result() + { + var collector = new CopilotModelFailureCollector(); + collector.Observe(Final("http_429")); + collector.Observe(CodedError("future_unknown")); + + var classified = Assert.IsType(collector.Classify(new InvalidOperationException())); + Assert.Equal(CopilotModelFailureKind.RateLimited, classified.Kind); + } + + [Fact] + public void Known_Query_Error_Code_Takes_Precedence_Over_Model_Result() + { + var collector = new CopilotModelFailureCollector(); + collector.Observe(Final("http_429")); + collector.Observe(CodedError("static_context_blocked")); + + var classified = Assert.IsType(collector.Classify(new InvalidOperationException())); + Assert.Equal(CopilotModelFailureKind.StaticContextBlocked, classified.Kind); + } + [Theory] [InlineData("success")] [InlineData("other_error")] @@ -154,4 +208,7 @@ private static SessionEvent Final(string result) private static SessionEvent Error(string errorType = "query") => SessionEvent.FromJson($$$"""{"type":"session.error","data":{"errorType":"{{{errorType}}}","message":"synthetic"}}"""); + + private static SessionEvent CodedError(string code, string errorType = "query") + => SessionEvent.FromJson($$$"""{"type":"session.error","data":{"errorType":"{{{errorType}}}","errorCode":"{{{code}}}","message":"synthetic"}}"""); } From 7d374af456a997383d5422d4e10f0783ac40de7e Mon Sep 17 00:00:00 2001 From: SIkebe <17608272+SIkebe@users.noreply.github.com> Date: Thu, 3 Dec 2026 00:19:15 +0900 Subject: [PATCH 7/7] Update Copilot SDK to 2.0.6 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- Directory.Packages.props | 2 +- src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs | 2 +- .../Components/ThirdPartyNoticesPanelTests.cs | 2 +- .../Copilot/CopilotInProcessRuntimeTests.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index bab38b3e..111c519e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -41,7 +41,7 @@ - + diff --git a/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs b/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs index da5e2f8d..d19ad339 100644 --- a/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs +++ b/src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs @@ -13,7 +13,7 @@ public static class ThirdPartyNotices { public static IReadOnlyList All { get; } = [ - Mit("Microsoft.Copilot.SDK", "2.0.6-preview.3", "Copyright (c) Microsoft Corporation. All rights reserved.", "https://github.com/github/copilot-sdk"), + Mit("Microsoft.Copilot.SDK", "2.0.6", "Copyright (c) Microsoft Corporation. All rights reserved.", "https://github.com/github/copilot-sdk"), new( "Markdig", "1.2.0", diff --git a/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs b/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs index 48cebd11..6bd52784 100644 --- a/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Components/ThirdPartyNoticesPanelTests.cs @@ -28,7 +28,7 @@ public void Renders_Third_Party_Notices() Assert.Contains("MudBlazor", packages); var sdkIndex = Array.IndexOf(packages, "Microsoft.Copilot.SDK"); Assert.NotEqual(-1, sdkIndex); - Assert.Equal("2.0.6-preview.3", versions[sdkIndex]); + Assert.Equal("2.0.6", versions[sdkIndex]); Assert.Contains("Microsoft.Web.WebView2", packages); Assert.Contains("BSD-2-Clause", cut.Markup, StringComparison.Ordinal); Assert.Contains("MIT", cut.Markup, StringComparison.Ordinal); diff --git a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs index 983e8e29..09b58a6d 100644 --- a/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs +++ b/tests/RepoSyncRadar.App.Tests/Copilot/CopilotInProcessRuntimeTests.cs @@ -45,7 +45,7 @@ public async Task PingAsync_Connects_To_Bundled_InProcess_Runtime() var status = await client.GetStatusAsync(TestContext.Current.CancellationToken); Assert.Equal("pong: in-process", response.Message); - Assert.Equal("1.0.119-4", status.Version); + Assert.Equal("1.0.119", status.Version); } #pragma warning disable MCPSDK001 // Exercise experimental public APIs against the bundled native runtime.