Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 - <reason>`. 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<CancellationToken>()` or the real token.
- In xUnit tests, pass `TestContext.Current.CancellationToken` when calling cancellable APIs. For NSubstitute `Received`/`DidNotReceive`, use `Arg.Any<CancellationToken>()` 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.
Expand Down Expand Up @@ -76,9 +76,9 @@ 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.
- 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.

Expand Down
2 changes: 1 addition & 1 deletion .github/skills/copilot-sdk-dotnet-audit/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 は実行前に解除される場合がある。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`
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<ItemGroup Label="GitHub / Copilot">
<PackageVersion Include="Octokit" Version="14.0.0" />
<PackageVersion Include="Microsoft.Copilot.SDK" Version="2.0.5-preview.3" />
<PackageVersion Include="Microsoft.Copilot.SDK" Version="2.0.6" />
Comment thread
SIkebe marked this conversation as resolved.
Resolved
</ItemGroup>

<ItemGroup Label="Installer / Updates">
Expand Down
4 changes: 2 additions & 2 deletions docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ VS Code 専用の `vscode.temporaryDefaultToLocalHarness` は、未報告・空

**アプリが注入する権限制限(別枠)** には、セッション作成コードと共通の設定から、権限確認の迂回禁止、AI による権限承認の禁止、`shell` の拒否を表示します。アプリによる明示的な自動承認以外は、従来どおりユーザーが判断します。管理ポリシーの診断スナップショットにはこの層は含まれず、別枠の一覧も実セッションでの適用確認やツールごとの追加承認判断を示すものではありません。

すべての Copilot セッションは起動時に Manual 権限モードを明示し、SDK がその適用を確認できない場合は処理を開始せずエラーを表示します。進行中の要求を Auto モデルへ切り替えるランタイムの復旧機能は有効にしていません。セッション作成時の代替モデル選択は、上記の通知付きのアプリ側処理を維持します。
すべての Copilot セッションは起動時に Manual 権限モードを明示し、SDK がその適用とツールの一括自動承認が無効であることを確認できない場合は処理を開始せずエラーを表示します。進行中の要求を Auto モデルへ切り替えるランタイムの復旧機能は有効にしていません。セッション作成時の代替モデル選択は、上記の通知付きのアプリ側処理を維持します。

Triage・下書き再生成・まとめて解説のモデル処理が失敗した場合、SDK が最終結果を報告した範囲で、入力過大、レート制限、リクエスト拒否、サービス障害、通信障害を区別して対処方法を表示します。キャンセルやタイムアウトを別の障害に置き換えず、自動で再送しません。分類できない場合は従来のエラー表示を維持します。この結果イベントはモデル処理単位であり、ワークフロー成功や課金リクエスト数を表すものではありません。
Triage・下書き再生成・まとめて解説のモデル処理が失敗した場合、SDK が最終結果を報告した範囲で、入力過大、レート制限、リクエスト拒否、サービス障害、通信障害を区別して対処方法を表示します。SDK が該当する query エラーコードを報告した場合は、表示可能な出力のない処理と静的コンテキスト枠の超過も区別します。キャンセルやタイムアウトを別の障害に置き換えず、自動で再送しません。分類できない場合は従来のエラー表示を維持します。この結果イベントはモデル処理単位であり、ワークフロー成功や課金リクエスト数を表すものではありません。

### 2.4 起動

Expand Down
11 changes: 10 additions & 1 deletion src/RepoSyncRadar.App/Copilot/CopilotModelFailure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public enum CopilotModelFailureKind
RequestRejected,
ServerError,
TransportError,
EmptyTurn,
StaticContextBlocked,
}

public sealed class CopilotModelFailureException(CopilotModelFailureKind kind, Exception innerException)
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions src/RepoSyncRadar.App/Copilot/CopilotSessionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public async Task<ICopilotSession> CreateSessionAsync(
try
{
ValidatePermissionMode(session.PermissionModeResult);
var permissions = await session.Rpc.Permissions.GetAllowAllAsync(cancellationToken).ConfigureAwait(false);
ValidateNoBlanketToolApproval(permissions.ApproveAllTools);
}
catch
{
Expand All @@ -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

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions src/RepoSyncRadar.App/Resources/SharedResource.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<data name="Copilot.Failure.RequestRejected" xml:space="preserve"><value>The model rejected the request (HTTP 4xx). Check sign-in, model access, and policy before generating again.</value></data>
<data name="Copilot.Failure.ServerError" xml:space="preserve"><value>The model service failed (HTTP 5xx). Wait before generating again.</value></data>
<data name="Copilot.Failure.TransportError" xml:space="preserve"><value>The model connection failed. Check your network before generating again.</value></data>
<data name="Copilot.Failure.EmptyTurn" xml:space="preserve"><value>Copilot completed the turn without visible output.</value></data>
<data name="Copilot.Failure.StaticContextBlocked" xml:space="preserve"><value>The model's context budget is too small for the system instructions and tool definitions.</value></data>
<data name="Common.Yes" xml:space="preserve"><value>Yes</value></data>
<data name="Common.No" xml:space="preserve"><value>No</value></data>
<resheader name="resmimetype"><value>text/microsoft-resx</value></resheader>
Expand Down
2 changes: 2 additions & 0 deletions src/RepoSyncRadar.App/Resources/SharedResource.resx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<data name="Copilot.Failure.RequestRejected" xml:space="preserve"><value>モデルがリクエストを拒否しました(HTTP 4xx)。サインイン、モデルの利用権限、ポリシーを確認してから再生成してください。</value></data>
<data name="Copilot.Failure.ServerError" xml:space="preserve"><value>モデルのサービス側で障害が発生しました(HTTP 5xx)。時間を置いてから再生成してください。</value></data>
<data name="Copilot.Failure.TransportError" xml:space="preserve"><value>モデルとの通信に失敗しました。ネットワークを確認してから再生成してください。</value></data>
<data name="Copilot.Failure.EmptyTurn" xml:space="preserve"><value>Copilot の処理が表示可能な出力を返さずに終了しました。</value></data>
<data name="Copilot.Failure.StaticContextBlocked" xml:space="preserve"><value>システム指示とツール定義がモデルのコンテキスト枠を超えたため、処理できませんでした。</value></data>
<data name="Common.Yes" xml:space="preserve"><value>あり</value></data>
<data name="Common.No" xml:space="preserve"><value>なし</value></data>
<resheader name="resmimetype"><value>text/microsoft-resx</value></resheader>
Expand Down
2 changes: 1 addition & 1 deletion src/RepoSyncRadar.App/Settings/ThirdPartyNotices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class ThirdPartyNotices
{
public static IReadOnlyList<ThirdPartyNotice> 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.6", "Copyright (c) Microsoft Corporation. All rights reserved.", "https://github.com/github/copilot-sdk"),
new(
"Markdig",
"1.2.0",
Expand Down
15 changes: 9 additions & 6 deletions tests/RepoSyncRadar.App.Tests/Components/AppHeaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IGitHubAuthSession>();
session
Expand All @@ -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<IProgress<string>?>(), Arg.Any<CancellationToken>())
.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();
Expand All @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.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);
Expand Down
Loading
Loading