From 9bff54d37deb6b479ce976748bdd6307da8e6a92 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Tue, 10 Nov 2026 11:22:50 -0600 Subject: [PATCH 01/23] Use frozen review fixtures and independent disposition gates Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/skills/review-pull-request/SKILL.md | 9 +- .github/workflows/skill-evals.yml | 21 +- eng/skill-evals/README.md | 103 +- eng/skill-evals/assert_results.ps1 | 118 +- eng/skill-evals/grade_disposition.mjs | 175 ++ .../review-candidate-verifier/eval.vally.yaml | 205 +++ .../fixtures/.gitattributes | 3 + .../fixtures/candidate.json | 13 + .../fixtures/changed-files.json | 17 + .../fixtures/changes.diff | 20 + .../fixtures/contracts/api-behavior.txt | 6 + .../fixtures/observations.json | 46 + .../fixtures/package-a/bundle-index.json | 24 + .../fixtures/package-b/bundle-index.json | 25 + .../fixtures/package-c/bundle-index.json | 27 + .../fixtures/package-c/candidate.json | 10 + .../fixtures/package-c/changed-files.json | 16 + .../fixtures/package-c/changes.diff | 23 + .../baseTip/docs/CrossCuttingGuidance.md | 125 ++ .../AI/src/Attributes/ToolBlockAttribute.cs | 32 + .../src/Attributes/ToolParameterAttribute.cs | 16 + .../AI/src/Attributes/ToolResultAttribute.cs | 16 + .../AI/src/Blocks/ActivityContentBlock.cs | 22 + .../AI/src/Blocks/ApprovalStatus.cs | 25 + .../AI/src/Blocks/BlockLifecycleState.cs | 25 + .../Components/AI/src/Blocks/ContentBlock.cs | 73 + .../Blocks/ContentBlockChangedSubscription.cs | 28 + .../AI/src/Blocks/FunctionApprovalBlock.cs | 123 ++ .../Blocks/FunctionInvocationContentBlock.cs | 63 + .../AI/src/Blocks/IInteractiveBlock.cs | 19 + .../AI/src/Blocks/RichContentBlock.cs | 45 + .../AI/src/Blocks/RichText/BlockQuoteNode.cs | 9 + .../AI/src/Blocks/RichText/CodeBlockNode.cs | 39 + .../AI/src/Blocks/RichText/DefinitionNode.cs | 25 + .../AI/src/Blocks/RichText/EmphasisNode.cs | 9 + .../Blocks/RichText/FootnoteDefinitionNode.cs | 19 + .../AI/src/Blocks/RichText/FootnoteNode.cs | 14 + .../Blocks/RichText/FootnoteReferenceNode.cs | 19 + .../AI/src/Blocks/RichText/HeadingNode.cs | 31 + .../AI/src/Blocks/RichText/HtmlNode.cs | 32 + .../AI/src/Blocks/RichText/ImageNode.cs | 46 + .../src/Blocks/RichText/ImageReferenceNode.cs | 25 + .../AI/src/Blocks/RichText/InlineCodeNode.cs | 32 + .../AI/src/Blocks/RichText/LineBreakNode.cs | 14 + .../AI/src/Blocks/RichText/LinkNode.cs | 39 + .../src/Blocks/RichText/LinkReferenceNode.cs | 20 + .../AI/src/Blocks/RichText/ListItemNode.cs | 15 + .../AI/src/Blocks/RichText/ListNode.cs | 38 + .../AI/src/Blocks/RichText/ParagraphNode.cs | 9 + .../AI/src/Blocks/RichText/ReferenceKind.cs | 25 + .../AI/src/Blocks/RichText/RichTextContent.cs | 45 + .../AI/src/Blocks/RichText/RichTextNode.cs | 36 + .../src/Blocks/RichText/StrikethroughNode.cs | 9 + .../AI/src/Blocks/RichText/StrongNode.cs | 9 + .../AI/src/Blocks/RichText/TableCellNode.cs | 9 + .../Blocks/RichText/TableColumnAlignment.cs | 30 + .../AI/src/Blocks/RichText/TableNode.cs | 16 + .../AI/src/Blocks/RichText/TableRowNode.cs | 9 + .../AI/src/Blocks/RichText/TextNode.cs | 32 + .../src/Blocks/RichText/ThematicBreakNode.cs | 9 + .../Components/AI/src/Blocks/UIActionBlock.cs | 101 ++ .../AI/src/Components/AgentBoundary.cs | 78 + .../AI/src/Components/BlockContainer.cs | 30 + .../AI/src/Components/BlockRenderer.cs | 94 + .../Components/BlockRendererRegistration.cs | 13 + .../Components/AI/src/Components/ChatPage.cs | 128 ++ .../Components/ConversationTurnRenderer.cs | 74 + .../AI/src/Components/MessageInput.cs | 169 ++ .../AI/src/Components/MessageList.cs | 204 +++ .../AI/src/Components/MessageListContext.cs | 451 +++++ .../Components/AI/src/Engine/AgentContext.cs | 389 +++++ .../Components/AI/src/Engine/AgentState.cs | 120 ++ .../AI/src/Engine/ConversationStatus.cs | 31 + .../AI/src/Engine/ConversationTurn.cs | 44 + .../AI/src/Engine/IConversationThread.cs | 53 + .../src/Components/AI/src/Engine/UIAgent.cs | 362 ++++ .../Components/AI/src/Engine/UIAgentLog.cs | 24 + .../Components/AI/src/Engine/UIAgentOfT.cs | 122 ++ .../Microsoft.AspNetCore.Components.AI.csproj | 45 + .../AI/src/Pipeline/ActivityHandler.cs | 72 + .../AI/src/Pipeline/BlockMappingContext.cs | 171 ++ .../AI/src/Pipeline/BlockMappingPipeline.cs | 182 ++ .../src/Pipeline/BlockMappingPipelineLog.cs | 27 + .../AI/src/Pipeline/BlockMappingResult.cs | 57 + .../AI/src/Pipeline/ContentBlockHandler.cs | 30 + .../src/Pipeline/FunctionApprovalHandler.cs | 60 + .../src/Pipeline/FunctionInvocationHandler.cs | 54 + .../AI/src/Pipeline/HandleResult.cs | 22 + .../AI/src/Pipeline/HandlerEntry.cs | 61 + .../AI/src/Pipeline/IActiveEntry.cs | 11 + .../AI/src/Pipeline/IHandlerEntry.cs | 9 + .../AI/src/Pipeline/RichTextContentHandler.cs | 54 + .../AI/src/Pipeline/StateMapperContext.cs | 131 ++ .../AI/src/Pipeline/TextBlockHandler.cs | 91 + .../AI/src/Pipeline/UIActionHandler.cs | 48 + .../AI/src/Pipeline/UIAgentOptions.cs | 104 ++ .../Components/AI/src/PublicAPI.Shipped.txt | 1 + .../Components/AI/src/PublicAPI.Unshipped.txt | 360 ++++ .../src/Components/AI/src/wwwroot/ai-chat.css | 457 +++++ .../source/head/src/Engine/Conversation.mjs | 40 + .../AI/src/Attributes/ToolBlockAttribute.cs | 32 + .../src/Attributes/ToolParameterAttribute.cs | 16 + .../AI/src/Attributes/ToolResultAttribute.cs | 16 + .../AI/src/Blocks/ActivityContentBlock.cs | 22 + .../AI/src/Blocks/ApprovalStatus.cs | 25 + .../AI/src/Blocks/BlockLifecycleState.cs | 25 + .../Components/AI/src/Blocks/ContentBlock.cs | 73 + .../Blocks/ContentBlockChangedSubscription.cs | 28 + .../AI/src/Blocks/FunctionApprovalBlock.cs | 123 ++ .../Blocks/FunctionInvocationContentBlock.cs | 63 + .../AI/src/Blocks/IInteractiveBlock.cs | 19 + .../AI/src/Blocks/RichContentBlock.cs | 45 + .../AI/src/Blocks/RichText/BlockQuoteNode.cs | 9 + .../AI/src/Blocks/RichText/CodeBlockNode.cs | 39 + .../AI/src/Blocks/RichText/DefinitionNode.cs | 25 + .../AI/src/Blocks/RichText/EmphasisNode.cs | 9 + .../Blocks/RichText/FootnoteDefinitionNode.cs | 19 + .../AI/src/Blocks/RichText/FootnoteNode.cs | 14 + .../Blocks/RichText/FootnoteReferenceNode.cs | 19 + .../AI/src/Blocks/RichText/HeadingNode.cs | 31 + .../AI/src/Blocks/RichText/HtmlNode.cs | 32 + .../AI/src/Blocks/RichText/ImageNode.cs | 46 + .../src/Blocks/RichText/ImageReferenceNode.cs | 25 + .../AI/src/Blocks/RichText/InlineCodeNode.cs | 32 + .../AI/src/Blocks/RichText/LineBreakNode.cs | 14 + .../AI/src/Blocks/RichText/LinkNode.cs | 39 + .../src/Blocks/RichText/LinkReferenceNode.cs | 20 + .../AI/src/Blocks/RichText/ListItemNode.cs | 15 + .../AI/src/Blocks/RichText/ListNode.cs | 38 + .../AI/src/Blocks/RichText/ParagraphNode.cs | 9 + .../AI/src/Blocks/RichText/ReferenceKind.cs | 25 + .../AI/src/Blocks/RichText/RichTextContent.cs | 45 + .../AI/src/Blocks/RichText/RichTextNode.cs | 36 + .../src/Blocks/RichText/StrikethroughNode.cs | 9 + .../AI/src/Blocks/RichText/StrongNode.cs | 9 + .../AI/src/Blocks/RichText/TableCellNode.cs | 9 + .../Blocks/RichText/TableColumnAlignment.cs | 30 + .../AI/src/Blocks/RichText/TableNode.cs | 16 + .../AI/src/Blocks/RichText/TableRowNode.cs | 9 + .../AI/src/Blocks/RichText/TextNode.cs | 32 + .../src/Blocks/RichText/ThematicBreakNode.cs | 9 + .../Components/AI/src/Blocks/UIActionBlock.cs | 101 ++ .../AI/src/Components/AgentBoundary.cs | 78 + .../AI/src/Components/BlockContainer.cs | 30 + .../AI/src/Components/BlockRenderer.cs | 94 + .../Components/BlockRendererRegistration.cs | 13 + .../Components/AI/src/Components/ChatPage.cs | 128 ++ .../Components/ConversationTurnRenderer.cs | 74 + .../AI/src/Components/MessageInput.cs | 169 ++ .../AI/src/Components/MessageList.cs | 204 +++ .../AI/src/Components/MessageListContext.cs | 451 +++++ .../Components/AI/src/Engine/AgentContext.cs | 380 ++++ .../Components/AI/src/Engine/AgentState.cs | 120 ++ .../AI/src/Engine/ConversationStatus.cs | 31 + .../AI/src/Engine/ConversationTurn.cs | 44 + .../AI/src/Engine/IConversationThread.cs | 53 + .../src/Components/AI/src/Engine/UIAgent.cs | 357 ++++ .../Components/AI/src/Engine/UIAgentLog.cs | 21 + .../Components/AI/src/Engine/UIAgentOfT.cs | 122 ++ .../Microsoft.AspNetCore.Components.AI.csproj | 45 + .../AI/src/Pipeline/ActivityHandler.cs | 72 + .../AI/src/Pipeline/BlockMappingContext.cs | 171 ++ .../AI/src/Pipeline/BlockMappingPipeline.cs | 182 ++ .../src/Pipeline/BlockMappingPipelineLog.cs | 27 + .../AI/src/Pipeline/BlockMappingResult.cs | 57 + .../AI/src/Pipeline/ContentBlockHandler.cs | 30 + .../src/Pipeline/FunctionApprovalHandler.cs | 60 + .../src/Pipeline/FunctionInvocationHandler.cs | 54 + .../AI/src/Pipeline/HandleResult.cs | 22 + .../AI/src/Pipeline/HandlerEntry.cs | 61 + .../AI/src/Pipeline/IActiveEntry.cs | 11 + .../AI/src/Pipeline/IHandlerEntry.cs | 9 + .../AI/src/Pipeline/RichTextContentHandler.cs | 54 + .../AI/src/Pipeline/StateMapperContext.cs | 131 ++ .../AI/src/Pipeline/TextBlockHandler.cs | 91 + .../AI/src/Pipeline/UIActionHandler.cs | 48 + .../AI/src/Pipeline/UIAgentOptions.cs | 104 ++ .../Components/AI/src/PublicAPI.Shipped.txt | 1 + .../Components/AI/src/PublicAPI.Unshipped.txt | 360 ++++ .../src/Components/AI/src/wwwroot/ai-chat.css | 457 +++++ .../mergeBase/src/Engine/Conversation.mjs | 40 + .../review-candidate-verifier/provenance.json | 712 ++++++++ .../catch-policy.vally.yaml | 152 -- .../review-pull-request/eval.vally.yaml | 770 +++++++++ .../fixtures/.gitattributes | 5 + .../fixtures/case-01/baseTip.source | 137 ++ .../fixtures/case-01/case.source | 8 + .../fixtures/case-01/change.diff | 61 + .../fixtures/case-01/context.source | 66 + .../fixtures/case-01/head.source | 150 ++ .../fixtures/case-01/mergeBase.source | 137 ++ .../fixtures/case-01/provenance.json | 103 ++ .../fixtures/case-02/baseTip.source | 1538 +++++++++++++++++ .../fixtures/case-02/case.source | 8 + .../fixtures/case-02/change.diff | 34 + .../fixtures/case-02/context.source | 19 + .../fixtures/case-02/head.source | 91 + .../fixtures/case-02/mergeBase.source | 88 + .../fixtures/case-02/provenance.json | 151 ++ .../fixtures/case-03/baseTip.source | 127 ++ .../fixtures/case-03/case.source | 8 + .../fixtures/case-03/change.diff | 20 + .../fixtures/case-03/context.source | 116 ++ .../fixtures/case-03/head.source | 182 ++ .../fixtures/case-03/mergeBase.source | 175 ++ .../fixtures/case-03/provenance.json | 131 ++ .../fixtures/case-04/baseTip.source | 517 ++++++ .../fixtures/case-04/case.source | 8 + .../fixtures/case-04/change.diff | 108 ++ .../fixtures/case-04/context.source | 164 ++ .../fixtures/case-04/head.source | 104 ++ .../fixtures/case-04/mergeBase.source | 109 ++ .../fixtures/case-04/provenance.json | 131 ++ .../fixtures/case-05/baseTip.source | 160 ++ .../fixtures/case-05/case.source | 8 + .../fixtures/case-05/change.diff | 83 + .../fixtures/case-05/context.source | 87 + .../fixtures/case-05/head.source | 122 ++ .../fixtures/case-05/mergeBase.source | 83 + .../fixtures/case-05/provenance.json | 145 ++ .../baseTip.source} | 0 .../fixtures/case-06/case.source | 1 + .../change.diff} | 0 .../fixtures/case-06/context.source | 40 + .../head.source} | 0 .../mergeBase.source} | 0 .../fixtures/case-06/provenance.json | 36 + .../ConversationEngineTests.cs.source | 21 - .../fixtures/catch-policy/best-effort.txt | 20 - .../catch-policy/existing-question.txt | 22 - .../fixtures/catch-policy/nonthrowing.txt | 24 - .../fixtures/catch-policy/propagation.txt | 21 - .../fixtures/catch-policy/unspecified.txt | 20 - eng/skill-evals/review-smoke.experiment.yaml | 25 + .../review-vs-baseline.experiment.yaml | 23 + eng/skill-evals/run.ps1 | 126 +- eng/skill-evals/skills-smoke.experiment.yaml | 2 +- .../skills-vs-baseline.experiment.yaml | 7 +- eng/skill-evals/stage_run.ps1 | 50 +- eng/skill-evals/test_assert_results.ps1 | 239 ++- eng/skill-evals/test_disposition.mjs | 112 ++ eng/skill-evals/test_run.ps1 | 128 +- eng/skill-evals/test_stage_run.ps1 | 94 + .../tests/test_review_fixtures.ps1 | 203 +++ eng/skill-evals/tests/test_stage_run.ps1 | 4 + 245 files changed, 20112 insertions(+), 343 deletions(-) create mode 100644 eng/skill-evals/grade_disposition.mjs create mode 100644 eng/skill-evals/review-candidate-verifier/eval.vally.yaml create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/.gitattributes create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/candidate.json create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/changed-files.json create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/changes.diff create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/contracts/api-behavior.txt create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/observations.json create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/package-a/bundle-index.json create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/package-b/bundle-index.json create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/package-c/bundle-index.json create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/package-c/candidate.json create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/package-c/changed-files.json create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/package-c/changes.diff create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/baseTip/docs/CrossCuttingGuidance.md create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolBlockAttribute.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolParameterAttribute.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolResultAttribute.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ActivityContentBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ApprovalStatus.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/BlockLifecycleState.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichContentBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HeadingNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HtmlNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListItemNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextContent.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrongNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableCellNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableRowNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TextNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/UIActionBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/AgentBoundary.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockContainer.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRenderer.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRendererRegistration.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ChatPage.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ConversationTurnRenderer.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageInput.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageList.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageListContext.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentContext.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentState.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/ConversationStatus.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/ConversationTurn.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/IConversationThread.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgent.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentLog.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentOfT.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ActivityHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingContext.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingResult.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ContentBlockHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandleResult.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandlerEntry.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IActiveEntry.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IHandlerEntry.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/RichTextContentHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/StateMapperContext.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/TextBlockHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIActionHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIAgentOptions.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Shipped.txt create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Unshipped.txt create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/wwwroot/ai-chat.css create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Engine/Conversation.mjs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolBlockAttribute.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolParameterAttribute.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolResultAttribute.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ActivityContentBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ApprovalStatus.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/BlockLifecycleState.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichContentBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HeadingNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HtmlNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListItemNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextContent.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrongNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableCellNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableRowNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TextNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/UIActionBlock.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/AgentBoundary.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockContainer.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRenderer.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRendererRegistration.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ChatPage.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ConversationTurnRenderer.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageList.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageListContext.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentState.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/IConversationThread.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentOfT.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ActivityHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingContext.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingResult.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ContentBlockHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandleResult.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandlerEntry.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IActiveEntry.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IHandlerEntry.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/RichTextContentHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/StateMapperContext.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/TextBlockHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIActionHandler.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIAgentOptions.cs create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Shipped.txt create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Unshipped.txt create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/wwwroot/ai-chat.css create mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Engine/Conversation.mjs create mode 100644 eng/skill-evals/review-candidate-verifier/provenance.json delete mode 100644 eng/skill-evals/review-pull-request/catch-policy.vally.yaml create mode 100644 eng/skill-evals/review-pull-request/eval.vally.yaml create mode 100644 eng/skill-evals/review-pull-request/fixtures/.gitattributes create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/baseTip.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/case.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/change.diff create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/context.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/head.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/mergeBase.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/provenance.json create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/baseTip.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/case.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/change.diff create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/context.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/head.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/mergeBase.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/provenance.json create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/baseTip.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/case.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/change.diff create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/context.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/head.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/mergeBase.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/provenance.json create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/baseTip.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/case.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/change.diff create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/context.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/head.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/mergeBase.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/provenance.json create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/baseTip.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/case.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/change.diff create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/context.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/head.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/mergeBase.source create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/provenance.json rename eng/skill-evals/review-pull-request/fixtures/{catch-policy/Dependencies.cs.source => case-06/baseTip.source} (100%) create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-06/case.source rename eng/skill-evals/review-pull-request/fixtures/{catch-policy/ConversationEngine.diff => case-06/change.diff} (100%) create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-06/context.source rename eng/skill-evals/review-pull-request/fixtures/{catch-policy/head/ConversationEngine.cs.source => case-06/head.source} (100%) rename eng/skill-evals/review-pull-request/fixtures/{catch-policy/old/ConversationEngine.cs.source => case-06/mergeBase.source} (100%) create mode 100644 eng/skill-evals/review-pull-request/fixtures/case-06/provenance.json delete mode 100644 eng/skill-evals/review-pull-request/fixtures/catch-policy/ConversationEngineTests.cs.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/catch-policy/best-effort.txt delete mode 100644 eng/skill-evals/review-pull-request/fixtures/catch-policy/existing-question.txt delete mode 100644 eng/skill-evals/review-pull-request/fixtures/catch-policy/nonthrowing.txt delete mode 100644 eng/skill-evals/review-pull-request/fixtures/catch-policy/propagation.txt delete mode 100644 eng/skill-evals/review-pull-request/fixtures/catch-policy/unspecified.txt create mode 100644 eng/skill-evals/review-smoke.experiment.yaml create mode 100644 eng/skill-evals/review-vs-baseline.experiment.yaml create mode 100644 eng/skill-evals/test_disposition.mjs create mode 100644 eng/skill-evals/tests/test_review_fixtures.ps1 create mode 100644 eng/skill-evals/tests/test_stage_run.ps1 diff --git a/.github/skills/review-pull-request/SKILL.md b/.github/skills/review-pull-request/SKILL.md index b69f7a2c8612..1876f3c6acbc 100644 --- a/.github/skills/review-pull-request/SKILL.md +++ b/.github/skills/review-pull-request/SKILL.md @@ -282,8 +282,8 @@ coordinator-owned post-gate verifier, not a routed guide worker; it does not cha one-worker-per-guide count or any per-guide worker invariant. Use the same explicitly selected model and reasoning effort as the guide workers. Give it the trusted bundle root; the role-to-root mapping for the frozen `source/` roots; the exact diff and -changed-file references; every provisional finding (identifying any incomplete-fix or -new-feature omission claim); the exact assigned issue, API, base-tip, or +changed-file references; every provisional finding (identifying any incomplete-fix, +new-feature omission, or policy-only secondary-failure suppression claim); the exact assigned issue, API, base-tip, or primary-repository contract paths; and, when validation was used, the immutable source-bound validation artifacts and their paths, not an assertion that tests passed. It may read and search only those assigned frozen inputs, must verify only the supplied @@ -321,7 +321,10 @@ check recorded only in a worker's own `DISCARDED` section, without being propose when a contradicted `DROP` names `contradictedLink: contract` but its cited contract is head-side, keep the candidate in `NEW_FINDINGS` as an intent question with `confidence: question` instead of discarding it. This is an intentional adaptation of the verifier -contract for skill output. External behavior that remains unestablished is +contract for skill output. When `DOWNGRADE(intent)` reports `contract: "n/a"` for a +contract-dependent candidate, record it in `UNRESOLVED` with the missing binding contract, +not as an intent question. Apply the same unresolved inline rule above. Intent cannot +supply or waive a mandatory contract. External behavior that remains unestablished is `UNRESOLVED`. For a `KEEP` or an intent question, accept a verifier-corrected changed-line anchor or diff --git a/.github/workflows/skill-evals.yml b/.github/workflows/skill-evals.yml index 04cb43b309ed..286b7d946682 100644 --- a/.github/workflows/skill-evals.yml +++ b/.github/workflows/skill-evals.yml @@ -6,6 +6,9 @@ on: pull_request: paths: - '.github/skills/**' + - '.github/agents/review-*.agent.md' + - 'docs/CrossCuttingGuidance.md' + - 'docs/BlazorComponentsGuidance.md' - 'eng/skill-evals/**' - '.github/workflows/skill-evals.yml' push: @@ -13,6 +16,9 @@ on: - main paths: - '.github/skills/**' + - '.github/agents/review-*.agent.md' + - 'docs/CrossCuttingGuidance.md' + - 'docs/BlazorComponentsGuidance.md' - 'eng/skill-evals/**' - '.github/workflows/skill-evals.yml' workflow_dispatch: @@ -33,7 +39,11 @@ on: required: true default: review-public-api options: + - port-components-platform-api + - pr-attention-queue - review-public-api + - review-pull-request + - review-candidate-verifier - validate-blazor-feature run_type: description: Trial count to use when action is Run @@ -279,7 +289,16 @@ jobs: MATCHED_EVAL=false for EVAL_NAME in "${ALL_EVALS[@]}"; do if [[ "$FILE" == ".github/skills/$EVAL_NAME/"* || - "$FILE" == "eng/skill-evals/$EVAL_NAME/"* ]]; then + "$FILE" == "eng/skill-evals/$EVAL_NAME/"* || + ( "$EVAL_NAME" == 'review-pull-request' && ( + "$FILE" == '.github/agents/review-guide-worker.agent.md' || + "$FILE" == '.github/agents/review-candidate-verifier.agent.md' || + "$FILE" == 'docs/CrossCuttingGuidance.md' || + "$FILE" == 'docs/BlazorComponentsGuidance.md' + ) ) || + ( "$EVAL_NAME" == 'review-candidate-verifier' && + "$FILE" == '.github/agents/review-candidate-verifier.agent.md' + ) ]]; then AFFECTED+=("$EVAL_NAME") MATCHED_EVAL=true fi diff --git a/eng/skill-evals/README.md b/eng/skill-evals/README.md index 6de78ab02d3f..9084f2886ee1 100644 --- a/eng/skill-evals/README.md +++ b/eng/skill-evals/README.md @@ -9,10 +9,12 @@ stay here. `eng/skill-evals//eval.vally.yaml` is the standard one-skill lane, auto-discovered by this repository's experiment and runner. -`skills-vs-baseline.experiment.yaml` runs each of those specs twice with the +`skills-vs-baseline.experiment.yaml` runs the generic skill specs twice with the same stimuli: once without a skill and once with exactly `.github/skills/` loaded. The experiment owns `environment.skills`; -standard specs must not set it themselves. +standard specs must not set it themselves. Reviewer comparison uses +`review-vs-baseline.experiment.yaml` and `review-smoke.experiment.yaml` instead. +The verifier component suite has no skill arm and runs directly. Any other `*.vally.yaml` file is a specialized suite. Specialized suites are not auto-discovered and must be passed explicitly to the runner. Keep fixture files @@ -20,28 +22,67 @@ beside the spec that consumes them, normally under a `fixtures` directory. Do not place eval specs, `evals` directories, or eval runners in runtime skill directories. A runtime skill may use a `fixtures` directory for non-eval assets. -`review-pull-request/catch-policy.vally.yaml` is a specialized, offline policy -exercise. It stages the current reviewer skill, cross-cutting guide, diff, old/head source, -dependency implementations, and one selected scenario into each trial workspace. -Five independent stimuli cover unspecified policy, existing feedback, propagation, -best-effort reporting, and a nonthrowing producer control. The agent must derive the -effect from source rather than receive the expected behavior in its prompt. -Static tool-result checks require the relevant guidance and source to be read; -binary judging checks the reasoning separately. These checks do not prove every -line was read or replace the semantic judge. Five trials per stimulus must all pass. -Platform-required native skill acquisition is allowed, but does not replace reading -the staged guidance or authorize coordinator execution. -The executor and judge models are both pinned to the reviewer skill's supported -`gpt-5.6-sol`. Because they share a model identity, the judge is not independent- -model corroboration. Overrides are separate model-compatibility results, not -evidence that the default reviewer improved. -This does not invoke live PR review or measure baseline-versus-skilled improvement. -Run it explicitly with -`./eng/skill-evals/run.ps1 Run -Eval eng/skill-evals/review-pull-request/catch-policy.vally.yaml --require-pass`. +The standard `review-pull-request` suite uses frozen source and diff excerpts from +ASP.NET Core PRs #70106, #69782, #70304, #69721, and #70299. These cover exact-input +old/head comparison, constructor mapping versus a lower-layer head test, renderer +disposal and issue intent, an unproven external browser-test path, and existing +feedback on render-mode-dependent navigation. Each case carries its source roles, +Git blob identities, original line ranges, and fixture SHA-256 hashes in +`provenance.json`. Issue and feedback excerpts identify their captured public +revision metadata. Neutral stimulus names and destination paths do not encode +expected dispositions. A sixth case integrates the synthetic public catch-policy +example from #70312. It omits the explicit missing-policy hints and the redundant +existing-question case. It does not represent production framework source. +It replaces the retired standalone catch-policy suite and its duplicate fixtures. +Fixture attributes retain LF and upstream whitespace so Git checkout preserves +the frozen hashes on Windows and Unix. + +These are offline single-context candidate exercises, not full bundle preparation, +guide-worker dispatch, verifier integration, live PR review, or browser tests. +Both arms share frozen source and both guidance documents. Only the skilled arm +receives the skill and verifier/worker instructions. Baseline does not receive +`SKILL.md` or either agent profile. `tool-calls.required` matches both read arguments and +returned bytes, including actual skill text from native acquisition or an installed +file read. A success acknowledgement or a filename citation does not satisfy those +checks. Content signatures prove the specified bytes appeared in a tool result, +not that every possible review path ran. + +Only the deterministic program grader contributes to disposition scores. It checks +the status line, C1's section placement, inline confidence, and existing-thread +deduplication. Skill acquisition, read receipts, and LLM rubrics have zero weight. +The result gate checks evidence/guidance receipts for both arms and skill/profile +receipts for skilled only. A missing baseline skill cannot lower its disposition +score. Each skilled stimulus must independently meet its threshold. Baseline +disposition scores are reported, not threshold-gated. + +The zero-weight LLM rubrics remain secondary diagnostics, not semantic quality +gates. They still incur judge calls during a model-bearing run. The subject and +judge both use `gpt-5.6-sol`; the judge is not independent-model corroboration. +These public development cases are not held-out evidence. Five repeats do not +create five independent PR lineages. + +The `review-candidate-verifier` component suite checks normalized `decision` and +applicable `downgradeKind`, `dropBasis`, and `contradictedLink` fields. It tolerates +irrelevant JSON and citation-format differences. Every case must pass at least +four of five trials independently. Read receipts remain a separate integrity +gate. Case a uses public C# source. Case b adds an assigned synthetic propagation +contract, not an actual public API guarantee. Case c uses a synthetic JavaScript +component and an immutable observation artifact. Component attributes preserve the exact supplied +bytes, including existing line endings. Provenance records hashes and case kinds. + +Cases a, b, and c were measured at 4/5, 5/5, and 5/5 on the predecessor verifier +text. They have not yet been re-run against the merged guard clauses. +Case d uses a scenario close to the one @maraf reported at 3/10 DROP and 7/10 +DOWNGRADE(intent). It has not been measured, so it is not gated. + +Model-free validation checks layout, schema, source hashes, read-guard coverage, +and experiment selection. It does not establish adjudication quality. A +model-bearing `Run` and inspection of every trial's actual read receipts and +semantic result remain necessary before making a behavioral claim. The experiment deliberately does not override `runs`. A standard spec owns its -trial count through `defaults.runs`. The existing specs retain five runs and 25 -trials each. The dotnet/skills quality gate uses five trials as the minimum at +trial count through `defaults.runs`. The reviewer suite has 30 trials per arm. +The component suite has 15 trials. The dotnet/skills quality gate uses five trials as the minimum at which a clean sweep can support a one-sided sign test at 5%; enforcing a trial-count policy here remains a documented follow-up. @@ -56,6 +97,14 @@ Run these commands from any directory: # Prove every validator rule and runner isolation with self-tests ./eng/skill-evals/run.ps1 Test +# Select this suite for layout, lint, and both experiment dry-runs. +./eng/skill-evals/run.ps1 Validate -Suite review-pull-request +./eng/skill-evals/run.ps1 Validate -Suite review-candidate-verifier +# Run infrastructure self-tests plus the selected suite's fixture checks. +./eng/skill-evals/run.ps1 Test -Suite review-pull-request +# The original staging self-test also has this forwarding entry point. +./eng/skill-evals/tests/test_stage_run.ps1 + # Strict Vally parsing/schema lint; does not call a model ./eng/skill-evals/run.ps1 Lint @@ -63,9 +112,17 @@ Run these commands from any directory: ./eng/skill-evals/run.ps1 Run ./eng/skill-evals/run.ps1 Run -Eval eng/skill-evals/review-public-api/eval.vally.yaml ./eng/skill-evals/run.ps1 Run -Eval eng/skill-evals/review-public-api/eval.vally.yaml -Experiment eng/skill-evals/skills-smoke.experiment.yaml +./eng/skill-evals/run.ps1 Run -Suite review-candidate-verifier ./eng/skill-evals/run.ps1 Run -Eval eng/skill-evals//.vally.yaml ``` +Without a suite or explicit experiment, `Run` dispatches each standard suite into +its own output subdirectory. This includes reviewer comparison and the direct +verifier component suite. `assert_results.ps1` checks that combined output +recursively. A direct component run writes a plan beside Vally's timestamped +`results.jsonl`; it does not invent an experiment variant directory. Smoke selects +one repeat per case and cannot establish the full component 4/5 gate. + ## Hosted entry point `.github/workflows/skill-evals.yml` runs `Validate` automatically when pull @@ -179,7 +236,7 @@ invocation. The runner prints the resolved command and reported version for provenance. Additional Vally arguments can be appended to the command. Run output defaults to `artifacts/skill-evals`. -Standard runs use Vally's experiment `--compare` mode. Vally 0.13 and later do +Skill-comparison runs use Vally's experiment `--compare` mode. Vally 0.13 and later do not use the old per-stimulus `pairwise` grader, so comparison is owned by the experiment rather than repeated in each eval spec. diff --git a/eng/skill-evals/assert_results.ps1 b/eng/skill-evals/assert_results.ps1 index 1aa8d38d6cea..80bd054c3243 100644 --- a/eng/skill-evals/assert_results.ps1 +++ b/eng/skill-evals/assert_results.ps1 @@ -9,6 +9,13 @@ Set-StrictMode -Version 3 $resolvedOutput = (Resolve-Path $OutputDirectory).Path $runDirectories = @(Get-ChildItem $resolvedOutput -Directory) +if ($runDirectories.Count -gt 0 -and + @($runDirectories | Where-Object { Test-Path (Join-Path $_.FullName 'plan-snapshot.json') }).Count -eq 0) { + foreach ($directory in $runDirectories) { + & $PSCommandPath -OutputDirectory $directory.FullName + } + return +} if ($runDirectories.Count -ne 1) { throw "Expected exactly one Vally run under '$resolvedOutput'; found $($runDirectories.Count)." } @@ -22,15 +29,26 @@ if (-not (Test-Path $snapshotPath -PathType Leaf)) { $snapshot = Get-Content $snapshotPath -Raw | ConvertFrom-Json -Depth 100 $scoresByVariant = @{} $plansByVariant = @{} -foreach ($variant in @('baseline', 'skilled')) { +$variants = if ($snapshot.evals.Count -eq 1 -and $snapshot.evals[0].variant -eq 'current') { + @('current') +} else { + @('baseline', 'skilled') +} +foreach ($variant in $variants) { $plans = @($snapshot.evals | Where-Object variant -eq $variant) if ($plans.Count -ne 1) { throw "Expected exactly one '$variant' plan; found $($plans.Count)." } $plan = $plans[0] + $names = @($plan.plannedStimulusNames) + if ($names.Count -lt 1 -or $names.Count -ne [int]$plan.plannedStimulusCount -or + @($names | Sort-Object -Unique).Count -ne $names.Count -or + [int]$plan.runs -lt 1) { + throw "The '$variant' plan has invalid stimulus identities or trial counts." + } $plansByVariant[$variant] = $plan - $resultsPath = Join-Path $runDirectory "$variant/results.jsonl" + $resultsPath = Join-Path $runDirectory $(if ($variant -eq 'current') { 'results.jsonl' } else { "$variant/results.jsonl" }) if (-not (Test-Path $resultsPath -PathType Leaf)) { throw "Missing Vally results at '$resultsPath'." } @@ -40,6 +58,17 @@ foreach ($variant in @('baseline', 'skilled')) { Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | ForEach-Object { $_ | ConvertFrom-Json -Depth 100 } ) + $completion = $null + if ($variant -eq 'current') { + $summaries = @($results | Where-Object type -eq 'run-summary') + if ($summaries.Count -ne 1 -or $results[-1].type -ne 'run-summary' -or + $summaries[0].hadExecutionErrors -isnot [bool] -or $summaries[0].hadExecutionErrors -or + [string]::IsNullOrWhiteSpace($summaries[0].runId)) { + throw 'The component output has an invalid or missing completion summary.' + } + $completion = $summaries[0] + $results = @($results | Where-Object type -ne 'run-summary') + } $expectedCount = [int]$plan.plannedStimulusCount * [int]$plan.runs if ($results.Count -ne $expectedCount) { throw "Expected $expectedCount '$variant' trial results; found $($results.Count)." @@ -57,7 +86,31 @@ foreach ($variant in @('baseline', 'skilled')) { } $scores = [Collections.Generic.List[double]]::new() + $scoresByStimulus = @{} + $identities = [Collections.Generic.HashSet[string]]::new() foreach ($result in $results) { + if ($result.type -ne 'trial-result' -or + ($completion -and $result.runId -ne $completion.runId) -or + ($variant -ne 'current' -and ( + -not $result.PSObject.Properties['variant'] -or $result.variant -ne $variant + )) -or + -not $result.PSObject.Properties['stimulus'] -or + $result.stimulus -notin $names) { + throw "The '$variant' variant has an unplanned or missing stimulus." + } + $trialIndex = if ($result.PSObject.Properties['trialIndex']) { + $result.trialIndex + } elseif ([int]$plan.runs -eq 1) { + 0 + } else { + $null + } + if ($null -eq $trialIndex -or + ($trialIndex -isnot [long] -and $trialIndex -isnot [int]) -or + $trialIndex -lt 0 -or $trialIndex -ge [int]$plan.runs -or + -not $identities.Add("$($result.stimulus):$trialIndex")) { + throw "The '$variant' variant has an invalid or duplicate trial identity." + } $gradeResultProperty = $result.PSObject.Properties['gradeResult'] $scoreProperty = if ($gradeResultProperty -and $null -ne $gradeResultProperty.Value) { $gradeResultProperty.Value.PSObject.Properties['score'] @@ -65,17 +118,60 @@ foreach ($variant in @('baseline', 'skilled')) { if (-not $scoreProperty -or $null -eq $scoreProperty.Value) { throw "The '$variant' variant has trial results without grader scores." } - $scores.Add([double]$scoreProperty.Value) + if ($scoreProperty.Value -is [string] -or $scoreProperty.Value -is [bool] -or + -not [double]::IsFinite([double]$scoreProperty.Value) -or + [double]$scoreProperty.Value -lt 0 -or [double]$scoreProperty.Value -gt 1) { + throw "The '$variant' variant has an invalid grader score." + } + $score = [double]$scoreProperty.Value + if ($variant -eq 'current' -and $score -notin @(0, 1)) { + throw 'Component disposition scores must be binary.' + } + $scores.Add($score) + if (-not $scoresByStimulus.ContainsKey($result.stimulus)) { + $scoresByStimulus[$result.stimulus] = [Collections.Generic.List[double]]::new() + } + $scoresByStimulus[$result.stimulus].Add($score) + $isReview = $plan.PSObject.Properties['evalName'] -and $plan.evalName -eq 'review-pull-request' + if ($variant -eq 'current' -or $isReview) { + $requiredReceipts = @("evidence-reads-$($result.stimulus)") + if ($isReview) { + $requiredReceipts += "guidance-reads-$($result.stimulus)" + if ($variant -eq 'skilled') { + $requiredReceipts += "treatment-reads-$($result.stimulus)" + } + } + if (-not $gradeResultProperty.Value.PSObject.Properties['details']) { + throw "The '$variant' trial lacks read-integrity results." + } + $dispositions = @($gradeResultProperty.Value.details | + Where-Object configuredName -eq "disposition-$($result.stimulus)") + if ($dispositions.Count -ne 1 -or $dispositions[0].score -ne $score -or + ($dispositions[0].PSObject.Properties['status'] -and $dispositions[0].status -eq 'error')) { + throw "The '$variant' trial lacks a valid primary disposition result." + } + foreach ($receipt in $requiredReceipts) { + $details = @($gradeResultProperty.Value.details | Where-Object configuredName -eq $receipt) + if ($details.Count -ne 1 -or $details[0].passed -isnot [bool] -or + -not $details[0].passed -or $details[0].score -is [string] -or $details[0].score -ne 1) { + throw "The '$variant' trial '$($result.stimulus):$trialIndex' failed read integrity: $receipt." + } + } + } } $scoresByVariant[$variant] = ($scores | Measure-Object -Average).Average + foreach ($name in $names) { + if (-not $scoresByStimulus.ContainsKey($name) -or + $scoresByStimulus[$name].Count -ne [int]$plan.runs) { + throw "The '$variant' stimulus '$name' has incomplete trial coverage." + } + $caseScore = ($scoresByStimulus[$name] | Measure-Object -Average).Average + if ($variant -ne 'baseline' -and $caseScore -lt [double]$plan.threshold) { + throw "The '$variant' stimulus '$name' score $caseScore is below threshold $($plan.threshold)." + } + Write-Host "$variant/$name score: $caseScore ($($plan.runs) complete trials)." + } } -$baselineScore = $scoresByVariant['baseline'] -$skilledScore = $scoresByVariant['skilled'] -$skilledThreshold = [double]$plansByVariant['skilled'].threshold -if ($skilledScore -lt $skilledThreshold) { - throw "The 'skilled' score $skilledScore is below the required threshold $skilledThreshold." -} - -Write-Host "Both variants produced complete successful results. Baseline score: $baselineScore. Skilled score: $skilledScore (threshold: $skilledThreshold)." +Write-Host 'All planned trials completed. Every gated stimulus met its own threshold.' diff --git a/eng/skill-evals/grade_disposition.mjs b/eng/skill-evals/grade_disposition.mjs new file mode 100644 index 000000000000..0f8d5095d284 --- /dev/null +++ b/eng/skill-evals/grade_disposition.mjs @@ -0,0 +1,175 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { readFileSync } from 'node:fs'; +import { pathToFileURL } from 'node:url'; + +const reviewCases = { + 'case-01': { section: 'DISCARDED', confidence: 'discarded' }, + 'case-02': { section: 'NEW_FINDINGS', confidence: 'verified' }, + 'case-03': { section: 'DISCARDED', confidence: 'discarded' }, + 'case-04': { section: 'UNRESOLVED', confidence: 'unresolved' }, + 'case-05': { section: 'EXISTING_FEEDBACK_COVERAGE', thread: 'discussion_r4487936812' }, + 'case-06': { section: 'UNRESOLVED', confidence: 'unresolved' }, +}; + +const componentCases = { + a: { decision: 'DROP', dropBasis: 'unestablished' }, + b: { decision: 'KEEP' }, + c: { decision: 'KEEP' }, +}; + +function normalizedResult(output) +{ + const text = output.trim().replace(/^```(?:json)?\s*\n([\s\S]*?)\n```\s*$/i, '$1'); + const parsed = JSON.parse(text); + if (parsed && Array.isArray(parsed.results)) + { + return parsed.results.length === 1 ? parsed.results[0] : null; + } + return parsed; +} + +function gradeComponent(name, output) +{ + const expected = componentCases[name]; + if (!expected) + { + throw new Error(`Unknown component case: ${name}`); + } + let actual; + try + { + actual = normalizedResult(output); + } + catch (error) + { + if (!(error instanceof SyntaxError)) + { + throw error; + } + return false; + } + if (!actual || typeof actual !== 'object' || Array.isArray(actual)) + { + return false; + } + const normalized = key => typeof actual[key] === 'string' ? actual[key].trim().toLowerCase() : ''; + if (!Object.entries(expected).every(([key, value]) => normalized(key) === value.toLowerCase())) + { + return false; + } + // Inapplicable fields may be omitted, null, or explicitly marked none. + return ['downgradeKind', 'dropBasis', 'contradictedLink'] + .filter(key => !(key in expected)) + .every(key => actual[key] == null || ['', 'none', 'n/a'].includes(normalized(key))); +} + +function gradeReview(name, output) +{ + const expected = reviewCases[name]; + if (!expected) + { + throw new Error(`Unknown review case: ${name}`); + } + const lines = output.trim().split(/\r?\n/); + if (!/^STATUS: (FINDINGS|NO_FINDINGS)$/.test(lines[0])) + { + return false; + } + const sections = new Map(); + let section; + for (const line of lines.slice(1)) + { + const heading = line.trim().replace(/^#{1,6}\s+/, '').replace(/^\*\*|\*\*$/g, '').replace(/:$/, ''); + if (['NEW_FINDINGS', 'EXISTING_FEEDBACK_COVERAGE', 'UNRESOLVED', 'DISCARDED'].includes(heading)) + { + if (sections.has(heading)) + { + return false; + } + section = heading; + sections.set(section, ''); + } + else if (section) + { + sections.set(section, sections.get(section) + '\n' + line); + } + } + if (sections.size !== 4) + { + return false; + } + if ([...sections.values()].some(text => /\bC(?!1\b)\d+\b/.test(text))) + { + return false; + } + const hasCandidate = key => /\bC1\b/.test(sections.get(key)); + if (!hasCandidate(expected.section)) + { + return false; + } + if (expected.thread) + { + return !hasCandidate('NEW_FINDINGS') && + !hasCandidate('DISCARDED') && + hasCandidate('UNRESOLVED') && + sections.get(expected.section).includes(expected.thread) && + sections.get('UNRESOLVED').includes(expected.thread) && + lines[0] === 'STATUS: NO_FINDINGS'; + } + if (expected.section !== 'UNRESOLVED' && hasCandidate('UNRESOLVED') || + expected.section !== 'DISCARDED' && hasCandidate('DISCARDED') || + hasCandidate('EXISTING_FEEDBACK_COVERAGE')) + { + return false; + } + const inline = sections.get('NEW_FINDINGS'); + const hasInline = hasCandidate('NEW_FINDINGS'); + if (!hasInline) + { + return false; + } + if (hasInline) + { + const confidences = [...inline.matchAll(/\bconfidence\s*:\s*([a-z]+)/gi)].map(match => match[1].toLowerCase()); + if (confidences.length !== 1 || confidences[0] !== expected.confidence || + lines[0] !== 'STATUS: FINDINGS') + { + return false; + } + if (expected.confidence !== 'verified' && + (!inline.includes(`[${expected.confidence.toUpperCase()}]`) || + !new RegExp(`Why ${expected.confidence}:`, 'i').test(inline))) + { + return false; + } + } + return hasInline || lines[0] === 'STATUS: NO_FINDINGS'; +} + +export function grade(input) +{ + const output = input.trajectory?.output; + const name = input.stimulus?.name; + const mode = input.config?.env?.DISPOSITION_MODE; + if (typeof output !== 'string' || typeof name !== 'string') + { + throw new Error('The grader requires final trajectory.output and stimulus.name.'); + } + const passed = mode === 'review' ? gradeReview(name, output) : + mode === 'component' ? gradeComponent(name, output) : + (() => { throw new Error(`Unknown disposition mode: ${mode}`); })(); + return { + name: 'disposition', + kind: 'code', + passed, + score: passed ? 1 : 0, + evidence: passed ? 'Expected normalized disposition and placement.' : 'Wrong or missing normalized disposition or placement.', + }; +} + +if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) +{ + console.log(JSON.stringify(grade(JSON.parse(readFileSync(process.env.EVALUATE_GRADER_INPUT, 'utf8'))))); +} diff --git a/eng/skill-evals/review-candidate-verifier/eval.vally.yaml b/eng/skill-evals/review-candidate-verifier/eval.vally.yaml new file mode 100644 index 000000000000..e65919234466 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/eval.vally.yaml @@ -0,0 +1,205 @@ +name: review-candidate-verifier +description: Verifier component development cases. Normalized disposition only, not a held-out quality estimate. +type: capability +defaults: + runs: 5 + timeout: 600s + model: gpt-5.6-sol +agent_environment: + files: + - src: ../../../.github/agents/review-candidate-verifier.agent.md + dest: verifier.md +grading_environment: + files: + - src: ../grade_disposition.mjs + dest: grade_disposition.mjs +scoring: + weights: + program: 1 + tool-calls: 0 + threshold: 0.8 +stimuli: + - name: a + prompt: | + Read verifier.md as your operating instructions. Read bundle-index.json and candidate.json. + Process exactly the indexed candidate using its frozen source roots, diff, changed-file metadata, + contracts, and immutable validation artifacts. Return one JSON disposition or a results array + with one disposition. The normalized decision and applicable downgradeKind, dropBasis, and + contradictedLink determine this component check. Schema and citation formatting are diagnostic. + Do not fetch, execute target code, modify files, publish, or delegate. + agent_environment: + files: + - src: fixtures/source/head/src/Components/AI/src + dest: source/head/src/Components/AI/src + - src: fixtures/source/mergeBase/src/Components/AI/src + dest: source/mergeBase/src/Components/AI/src + - src: fixtures/source/baseTip/docs/CrossCuttingGuidance.md + dest: source/baseTip/docs/CrossCuttingGuidance.md + - src: fixtures/changes.diff + dest: changes.diff + - src: fixtures/changed-files.json + dest: changed-files.json + - src: fixtures/candidate.json + dest: candidate.json + - src: fixtures/package-a/bundle-index.json + dest: bundle-index.json + graders: + - type: program + name: disposition-a + config: + program: node + args: + - grade_disposition.mjs + env: + DISPOSITION_MODE: component + - type: tool-calls + name: evidence-reads-a + config: + required: + - name: .* + pattern: verifier\.md + result: validationEvidence + - name: .* + pattern: bundle-index\.json + result: sourceRoots + - name: .* + pattern: candidate\.json + result: candidateId + - name: .* + pattern: changes\.diff + result: "@@" + - name: .* + pattern: source[/\\]head[/\\] + result: class AgentContext + - name: .* + pattern: source[/\\]mergeBase[/\\] + result: class AgentContext + - name: .* + pattern: CrossCuttingGuidance\.md + result: catch + - name: b + prompt: | + Read verifier.md as your operating instructions. Read bundle-index.json and candidate.json. + Process exactly the indexed candidate using its frozen source roots, diff, changed-file metadata, + contracts, and immutable validation artifacts. Return one JSON disposition or a results array + with one disposition. The normalized decision and applicable downgradeKind, dropBasis, and + contradictedLink determine this component check. Schema and citation formatting are diagnostic. + Do not fetch, execute target code, modify files, publish, or delegate. + agent_environment: + files: + - src: fixtures/source/head/src/Components/AI/src + dest: source/head/src/Components/AI/src + - src: fixtures/source/mergeBase/src/Components/AI/src + dest: source/mergeBase/src/Components/AI/src + - src: fixtures/source/baseTip/docs/CrossCuttingGuidance.md + dest: source/baseTip/docs/CrossCuttingGuidance.md + - src: fixtures/changes.diff + dest: changes.diff + - src: fixtures/changed-files.json + dest: changed-files.json + - src: fixtures/candidate.json + dest: candidate.json + - src: fixtures/contracts/api-behavior.txt + dest: contracts/api-behavior.txt + - src: fixtures/package-b/bundle-index.json + dest: bundle-index.json + graders: + - type: program + name: disposition-b + config: + program: node + args: + - grade_disposition.mjs + env: + DISPOSITION_MODE: component + - type: tool-calls + name: evidence-reads-b + config: + required: + - name: .* + pattern: verifier\.md + result: validationEvidence + - name: .* + pattern: bundle-index\.json + result: sourceRoots + - name: .* + pattern: candidate\.json + result: candidateId + - name: .* + pattern: changes\.diff + result: "@@" + - name: .* + pattern: source[/\\]head[/\\] + result: class AgentContext + - name: .* + pattern: source[/\\]mergeBase[/\\] + result: class AgentContext + - name: .* + pattern: CrossCuttingGuidance\.md + result: catch + - name: .* + pattern: api-behavior\.txt + result: propagate + - name: c + prompt: | + Read verifier.md as your operating instructions. Read bundle-index.json and candidate.json. + Process exactly the indexed candidate using its frozen source roots, diff, changed-file metadata, + contracts, and immutable validation artifacts. Return one JSON disposition or a results array + with one disposition. The normalized decision and applicable downgradeKind, dropBasis, and + contradictedLink determine this component check. Schema and citation formatting are diagnostic. + Do not fetch, execute target code, modify files, publish, or delegate. + agent_environment: + files: + - src: fixtures/source/head/src/Engine/Conversation.mjs + dest: source/head/src/Engine/Conversation.mjs + - src: fixtures/source/mergeBase/src/Engine/Conversation.mjs + dest: source/mergeBase/src/Engine/Conversation.mjs + - src: fixtures/source/baseTip/docs/CrossCuttingGuidance.md + dest: source/baseTip/docs/CrossCuttingGuidance.md + - src: fixtures/package-c/candidate.json + dest: candidate.json + - src: fixtures/package-c/changes.diff + dest: changes.diff + - src: fixtures/package-c/changed-files.json + dest: changed-files.json + - src: fixtures/observations.json + dest: observations.json + - src: fixtures/package-c/bundle-index.json + dest: bundle-index.json + graders: + - type: program + name: disposition-c + config: + program: node + args: + - grade_disposition.mjs + env: + DISPOSITION_MODE: component + - type: tool-calls + name: evidence-reads-c + config: + required: + - name: .* + pattern: verifier\.md + result: validationEvidence + - name: .* + pattern: bundle-index\.json + result: sourceRoots + - name: .* + pattern: candidate\.json + result: candidateId + - name: .* + pattern: changes\.diff + result: "@@" + - name: .* + pattern: source[/\\]head[/\\] + result: class Conversation + - name: .* + pattern: source[/\\]mergeBase[/\\] + result: class Conversation + - name: .* + pattern: CrossCuttingGuidance\.md + result: catch + - name: .* + pattern: observations\.json + result: Running diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/.gitattributes b/eng/skill-evals/review-candidate-verifier/fixtures/.gitattributes new file mode 100644 index 000000000000..c23c0f83960c --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/.gitattributes @@ -0,0 +1,3 @@ +* -text whitespace=cr-at-eol +*.cs whitespace=-blank-at-eol,-blank-at-eof +*.diff whitespace=-blank-at-eol,-blank-at-eof diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/candidate.json b/eng/skill-evals/review-candidate-verifier/fixtures/candidate.json new file mode 100644 index 000000000000..b0c7f67320b0 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/candidate.json @@ -0,0 +1,13 @@ +{ + "candidateId": "C1", + "claim": "The newly added catch prevents an exception thrown by the logging provider from reaching the caller awaiting SendMessageAsync.", + "mechanism": "A processing exception enters the outer catch, LogProcessingError throws another exception, and the inner catch permits normal completion after NotifyStatusChanged.", + "consequence": "The awaiting caller cannot observe the logging-provider exception.", + "proposedRemedy": "Remove the inner catch so the logging-provider exception propagates.", + "changedLine": { + "role": "head", + "path": "src/Components/AI/src/Engine/AgentContext.cs", + "line": 306 + }, + "repro": "Construct UIAgent with an IChatClient whose streaming response throws ProcessingFailure and an ILoggerFactory returning a logger that enables Error, ignores other levels and throws LoggingFailure from Log at Error. Construct AgentContext with that UIAgent. Await SendMessageAsync and inspect whether LoggingFailure propagates." +} \ No newline at end of file diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/changed-files.json b/eng/skill-evals/review-candidate-verifier/fixtures/changed-files.json new file mode 100644 index 000000000000..a4b1dfa3557f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/changed-files.json @@ -0,0 +1,17 @@ +[ + { + "path": "src/Components/AI/src/Engine/AgentContext.cs", + "status": "modified", + "rightChangedLines": [ + 302, + 303, + 304, + 305, + 306, + 307, + 308, + 309, + 310 + ] + } +] \ No newline at end of file diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/changes.diff b/eng/skill-evals/review-candidate-verifier/fixtures/changes.diff new file mode 100644 index 000000000000..5f8dd1f83c98 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/changes.diff @@ -0,0 +1,20 @@ +diff --git a/src/Components/AI/src/Engine/AgentContext.cs b/src/Components/AI/src/Engine/AgentContext.cs +index 6f9234e593..9f3541fd49 100644 +--- a/src/Components/AI/src/Engine/AgentContext.cs ++++ b/src/Components/AI/src/Engine/AgentContext.cs +@@ -299,6 +299,15 @@ public class AgentContext : IDisposable + _agent.RejectPendingPredictiveState(); + Error = ex; + Status = ConversationStatus.Error; ++ try ++ { ++ _agent.LogProcessingError(ex); ++ } ++ catch (Exception) ++ { ++ // A logging provider failure must not fault the operation after the processing ++ // failure has been surfaced through the conversation state. ++ } + NotifyStatusChanged(); + return; + } diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/contracts/api-behavior.txt b/eng/skill-evals/review-candidate-verifier/fixtures/contracts/api-behavior.txt new file mode 100644 index 000000000000..6f280aaa2099 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/contracts/api-behavior.txt @@ -0,0 +1,6 @@ +Assigned base-tip contract for AgentContext.SendMessageAsync: +When the processing-failure path invokes a logging provider, an exception thrown +by that provider must propagate unchanged to the caller awaiting SendMessageAsync. +Setting Error and Status, or notifying status observers, does not replace this +propagation requirement. This contract applies to the secondary logging failure, +not to the original processing exception. diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/observations.json b/eng/skill-evals/review-candidate-verifier/fixtures/observations.json new file mode 100644 index 000000000000..52e665c3acee --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/observations.json @@ -0,0 +1,46 @@ +{ + "generatedAt": "2026-11-06T16:02:09.187Z", + "producer": "node probe-synthetic.mjs", + "hashes": { + "base": "2c59edf3be93947a250c4c0a2787d103775265058fe3dbc533014932e2012deb", + "head": "13e383993dd60d8548089196ada34afcf791c7995ffda48104bbe23bf15cff11" + }, + "rows": [ + { + "role": "mergeBase", + "returned": false, + "thrown": "LoggingFailure", + "status": "Error", + "notifications": [ + "Error" + ], + "callbackCalls": [ + { + "callback": "work", + "error": "ProcessingFailure" + }, + { + "callback": "log", + "error": "ProcessingFailure" + } + ] + }, + { + "role": "head", + "returned": true, + "thrown": null, + "status": "Running", + "notifications": [], + "callbackCalls": [ + { + "callback": "work", + "error": "ProcessingFailure" + }, + { + "callback": "log", + "error": "ProcessingFailure" + } + ] + } + ] +} \ No newline at end of file diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/package-a/bundle-index.json b/eng/skill-evals/review-candidate-verifier/fixtures/package-a/bundle-index.json new file mode 100644 index 000000000000..b9e397864b6e --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/package-a/bundle-index.json @@ -0,0 +1,24 @@ +{ + "candidate": "candidate.json", + "diff": "changes.diff", + "changedFiles": "changed-files.json", + "sourceRoots": { + "head": "source\\head", + "mergeBase": "source\\mergeBase", + "baseTip": "source\\baseTip" + }, + "sourceRevisions": { + "head": "c0f86a6d725473f7a6f4c56d816ef941591053d2", + "mergeBase": "80ce68b5280ef01757bdf9d94b653da62e5724d5", + "baseTip": "2e792d799058bf25990ce0c8e2b416c736431ca3" + }, + "primarySource": "src\\Components\\AI\\src\\Engine\\AgentContext.cs", + "producerSources": [ + "src\\Components\\AI\\src\\Engine\\UIAgent.cs", + "src\\Components\\AI\\src\\Engine\\UIAgentLog.cs", + "src\\Components\\AI\\src\\Pipeline\\BlockMappingPipeline.cs" + ], + "contractPaths": [ + "source\\baseTip\\docs\\CrossCuttingGuidance.md" + ] +} \ No newline at end of file diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/package-b/bundle-index.json b/eng/skill-evals/review-candidate-verifier/fixtures/package-b/bundle-index.json new file mode 100644 index 000000000000..c8cb95979500 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/package-b/bundle-index.json @@ -0,0 +1,25 @@ +{ + "candidate": "candidate.json", + "diff": "changes.diff", + "changedFiles": "changed-files.json", + "sourceRoots": { + "head": "source\\head", + "mergeBase": "source\\mergeBase", + "baseTip": "source\\baseTip" + }, + "sourceRevisions": { + "head": "c0f86a6d725473f7a6f4c56d816ef941591053d2", + "mergeBase": "80ce68b5280ef01757bdf9d94b653da62e5724d5", + "baseTip": "2e792d799058bf25990ce0c8e2b416c736431ca3" + }, + "primarySource": "src\\Components\\AI\\src\\Engine\\AgentContext.cs", + "producerSources": [ + "src\\Components\\AI\\src\\Engine\\UIAgent.cs", + "src\\Components\\AI\\src\\Engine\\UIAgentLog.cs", + "src\\Components\\AI\\src\\Pipeline\\BlockMappingPipeline.cs" + ], + "contractPaths": [ + "source\\baseTip\\docs\\CrossCuttingGuidance.md", + "contracts\\api-behavior.txt" + ] +} \ No newline at end of file diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/package-c/bundle-index.json b/eng/skill-evals/review-candidate-verifier/fixtures/package-c/bundle-index.json new file mode 100644 index 000000000000..c25e1f353a76 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/package-c/bundle-index.json @@ -0,0 +1,27 @@ +{ + "candidate": "candidate.json", + "diff": "changes.diff", + "changedFiles": "changed-files.json", + "sourceRoots": { + "head": "source\\head", + "mergeBase": "source\\mergeBase", + "baseTip": "source\\baseTip" + }, + "sourceContentHashes": { + "head": "13e383993dd60d8548089196ada34afcf791c7995ffda48104bbe23bf15cff11", + "mergeBase": "2c59edf3be93947a250c4c0a2787d103775265058fe3dbc533014932e2012deb" + }, + "sourceRevisions": { + "baseTip": "2e792d799058bf25990ce0c8e2b416c736431ca3" + }, + "primarySource": "src\\Engine\\Conversation.mjs", + "contractPaths": [ + "source\\baseTip\\docs\\CrossCuttingGuidance.md" + ], + "validationArtifacts": [ + { + "path": "observations.json", + "sha256": "a4355b34aaf0927946a5c5791fafcdeaca05d4d85f247976d289c1626c0cc5f8" + } + ] +} \ No newline at end of file diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/package-c/candidate.json b/eng/skill-evals/review-candidate-verifier/fixtures/package-c/candidate.json new file mode 100644 index 000000000000..0f3da30b2c6b --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/package-c/candidate.json @@ -0,0 +1,10 @@ +{ + "candidateId": "C2", + "claim": "After the work and log callbacks throw, process returns with status Running and without a status notification.", + "changedLine": { + "role": "head", + "path": "src/Engine/Conversation.mjs", + "line": 35 + }, + "repro": "Register an onStatusChanged observer. Supply a work callback that throws ProcessingFailure and a log callback that throws LoggingFailure. Invoke process and inspect its return, public status field, and observer notifications." +} \ No newline at end of file diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/package-c/changed-files.json b/eng/skill-evals/review-candidate-verifier/fixtures/package-c/changed-files.json new file mode 100644 index 000000000000..eb1616665d90 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/package-c/changed-files.json @@ -0,0 +1,16 @@ +[ + { + "path": "src/Engine/Conversation.mjs", + "status": "modified", + "rightChangedLines": [ + 29, + 30, + 31, + 32, + 33, + 35, + 36, + 37 + ] + } +] \ No newline at end of file diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/package-c/changes.diff b/eng/skill-evals/review-candidate-verifier/fixtures/package-c/changes.diff new file mode 100644 index 000000000000..a8b436383932 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/package-c/changes.diff @@ -0,0 +1,23 @@ +diff --git a/src/Engine/Conversation.mjs b/src/Engine/Conversation.mjs +index 4b751950b4..f72499cc94 100644 +--- a/src/Engine/Conversation.mjs ++++ b/src/Engine/Conversation.mjs +@@ -26,15 +26,15 @@ export class Conversation + try + { + this.log(processingError); +- } +- finally +- { + this.status = "Error"; + for (const observer of this.observers) + { + observer(this.status); + } + } ++ catch ++ { ++ } + } + } + } diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/baseTip/docs/CrossCuttingGuidance.md b/eng/skill-evals/review-candidate-verifier/fixtures/source/baseTip/docs/CrossCuttingGuidance.md new file mode 100644 index 000000000000..c3d97b30c04d --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/baseTip/docs/CrossCuttingGuidance.md @@ -0,0 +1,125 @@ +# Cross-cutting guidance + +This guidance covers ASP.NET Core source work. Consult the relevant sections alongside the +requested task and applicable repository and area instructions. + +## Overarching principles + +- Preserve compatibility and public API discipline over local convenience. New APIs, constructors, options, packages, templates, analyzer IDs, and shared-framework metadata become long-lived contracts. +- Prefer existing ASP.NET Core, BCL, SDK, and repository infrastructure over custom helpers. Add abstractions only when they keep user code testable, composable, and stable. +- Treat nullability, validation, cancellation, disposal, and thread-safety annotations as executable design contracts, not comments. +- Separate startup, build-time, analyzer-time, and hot-path runtime work. Per-request, per-diagnostic, file-watcher, and template paths need allocation, caching, and determinism scrutiny. +- Treat filesystem paths, tool commands, configuration, generated output, logs, and package attribution as trust boundaries that can regress even when builds and tests pass. + +## Topics + +### Cross-cutting scope and change shape + +- Apply the [contribution scope requirements](../CONTRIBUTING.md#before-submitting-the-pull-request) to product, tool, template, analyzer, and test-utility changes, including unrelated file moves, generated-file churn, version churn, and refactors beyond the affected scenario. +- Preserve ownership boundaries between product code, shared source, templates, test infrastructure, and build infrastructure; do not expose shared implementation details through public namespaces or packages. +- Prefer established shared helpers for process handling, retries, cancellation, file enumeration, CLI parsing, package metadata, and test hosting before adding one-off infrastructure. +- Remove vestigial debug hooks, unused files, stale comments, obsolete workarounds, and duplicate conditional logic only once the scenario they protected is understood and still covered. + +### Public API surface, compatibility, and lifecycle + +- Minimize public surface area; keep speculative hooks, options, extension points, and constructor overloads internal until a demonstrated scenario and API review justify them. +- Preserve public member names, constructor signatures, enum values, default option values, extension-method behavior, analyzer IDs, template identifiers, package identities, and shared-framework metadata unless the breaking change is deliberate and reviewed. +- Use `[Obsolete]` with actionable migration guidance for deprecated APIs, and keep parallel or additive overloads when compatibility requires old members to remain. +- Use applicable public API design criteria for changed public/protected APIs and shipped defaults/conventions. The [API review process](APIReviewProcess.md#process) governs that process; verify any concern against source signatures and contracts rather than reporting a design preference as a defect. +- Public XML docs must accurately describe purpose, parameters, return values, exceptions, defaults, consumer-observable lifecycle, and non-obvious examples for IntelliSense and generated docs; follow the repository's [public XML-documentation requirement](../.github/copilot-instructions.md#formatting). + +### Nullability, validation, and correctness invariants + +- Validate public API arguments and externally supplied data at entry points with precise exception types, parameter names, and actionable messages; do not let invalid input surface later as `NullReferenceException` or an ambiguous failure. +- Keep nullable annotations, member initialization, `MemberNotNull`-style attributes, and guard clauses aligned with real control-flow invariants; do not use annotations to hide possible null states. +- Model unknown, unsupported, or partially restored states explicitly instead of silently mapping them into an existing known bucket; keep classification separate from filtering so tests can prove both. +- Preserve producer-consumer invariants for buffers, streams, collections, and generated metadata; never advance, reuse, mutate, or expose data beyond what the owner granted. +- Use explicit comparers, culture rules, and case-sensitivity decisions for strings, keys, file names, template identifiers, and configuration names when default equality is not the contract. + +### Async, cancellation, and background work + +- Use Task-based async through the whole call chain; avoid `.Result`, `.Wait()`, sync-over-async wrappers, and synchronous exception behavior that differs from the async contract. +- Flow `CancellationToken` to cancellation-aware async I/O, process execution, analyzer APIs, and long-running test utility APIs; for `IFileProvider.Watch` and file-change notifications, manage `IChangeToken` registration and disposable lifetimes through a documented shutdown path. +- Use `ConfigureAwait(false)` in library code that should not capture a synchronization context, while preserving app/test patterns that intentionally rely on one. +- Wrap fire-and-forget or callback-started async work in explicit error handling so failures are observed, logged, or propagated instead of crashing later or being silently swallowed. +- Prefer `IAsyncDisposable` and async fixture/helper patterns when cleanup is asynchronous; do not block during teardown or replace cancellation with unsafe object nulling. + +### Performance, allocations, caching, and pooling + +- Determine whether code runs at startup, build time, analyzer time, or on a hot runtime path before raising performance findings; optimize hot paths and repeated analyzer traversals first. +- Minimize avoidable allocations in per-request, per-diagnostic, file-provider, localization, cache, and template-generation paths using spans, pooled buffers, capacity hints, cached symbols, and lazy computation where they materially help. +- Use object pooling, `ArrayPool`, shared immutable singleton results, and cache consolidation only when ownership, reset, invalidation, contention, and lifetime semantics are clear. +- Defer expensive or failure-prone work until a caller needs it; avoid constructor, registration, or startup work that eagerly resolves files, assemblies, projects, reflection, or external tools without benefit. +- Measure durations with elapsed-time APIs and keep benchmark or performance validation focused on the changed path rather than wall-clock or environment-sensitive measurements. + +### Resource lifetime, disposal, and I/O + +- Types owning streams, file watchers, pooled buffers, processes, temporary artifacts, native handles, subscriptions, or listeners must make ownership explicit and release deterministically on success, failure, replacement, and cancellation paths. +- Implement `IDisposable`, `IAsyncDisposable`, `SafeHandle`, or try/finally according to the resource owned; do not hide cleanup in unrelated lifecycle methods. +- APIs that start registrations, watches, listeners, or background work must prevent repeated starts from leaking prior instances and define whether the caller or callee owns disposal. +- Use `IFileProvider` for virtual/read-only file access, plus path APIs and platform helpers instead of hard-coded separators, working-directory assumptions, or string concatenation; use `System.IO` or explicit writable abstractions when code must create, write, move, or delete files. +- Treat files, directories, generated outputs, and tool inputs as race-prone: they can be missing, locked, replaced, case-sensitive, URI-shaped, or deleted between an existence check and use. + +### Thread-safety, shared state, and lazy initialization + +- Protect shared mutable state with locks, immutable snapshots, concurrent collections, or one-time initialization that preserves the invariant, not just individual operations. +- Document thread-safety guarantees for caches, options snapshots, pools, file providers, analyzers, and shared singleton services when callers can access them concurrently. +- Do not dispose or null shared `CancellationTokenSource`, watcher, logger, cache, or pooled state while callbacks or lazy work may still observe it; cancel first and coordinate completion. +- Keep lock scopes readable; avoid callbacks, logging fan-out, async continuations, or service resolution while holding a lock unless the reentrancy and deadlock behavior is intentional. +- Use immutable or readonly fields for configuration and shared dependencies after construction; mutable static state needs a concurrency and test-isolation reason. + +### Options, configuration, and dependency injection + +- Use `IConfiguration`, options, and DI for configurable behavior; avoid hard-coded values, environment-specific branches, hidden mutable/environmental static dependencies, or service locators in product APIs, while allowing established factories and BCL shared pools such as `ObjectPool.Create` and `ArrayPool.Shared` when ownership and lifetime semantics are clear. +- Keep configuration keys, option names, defaults, environment-variable mappings, generated element IDs, and casing stable across providers, and document them when users can depend on them. +- Add configuration knobs only for demonstrated scenarios; choose safe defaults and validate options early enough that failures point to the invalid setting. +- Match DI lifetimes to the dependencies they capture; use idempotent `TryAdd`/`TryAddEnumerable` registration when repeated calls should compose with user services. +- Keep compile-time and runtime configuration distinct: MSBuild properties, runtime host configuration, package metadata, and user options must not drift or leak into the wrong layer. + +### Diagnostics, logging, exceptions, and tool output + +- Throw specific exceptions with contextual messages for invalid input, unsupported states, timeouts, external command failures, and configuration errors; catch only exceptions you can handle or enrich. +- Keep diagnostics actionable — include the invalid value, path, key, package, tool, timeout, or operation where useful — without leaking sensitive data or stack traces in normal output. +- Use structured `ILogger`, EventSource, analyzer diagnostics, and console output at levels matching success, warning, failure, and verbose detail; do not add noisy hot-path logs. +- For tools and scripts, separate normal output from diagnostics, preserve readable ordering under parallel execution, handle no-op cases gracefully, and suppress presentation features when output is redirected. +- Analyzer diagnostics need stable IDs, clear messages, help links, generated-code suppression where appropriate, and tests that verify locations and examples. + +### Trust boundaries, security, and sensitive data + +- Treat file-provider inputs, physical paths, generated outputs, and tool/configuration values as untrusted at boundaries; normalize and validate roots before opening files so traversal, symlink escape, URI confusion, or provider mismatch cannot bypass the intended scope. +- Construct process, script, MSBuild, and external tool invocations with argument lists, response files, and repository helpers; do not concatenate untrusted values into shell commands, script fragments, or properties where command/process injection or quoting bugs can change behavior. +- Redact secrets, connection strings, tokens, user secrets, credentials, sensitive environment values, and unnecessary local paths from logs, exceptions, diagnostics, generated files, and test artifacts. +- Keep security-sensitive defaults fail-closed and preserve validation at trust boundaries even when the changed path is primarily configuration, templates, tests, or tooling. + +### Localization, text, paths, and cross-platform behavior + +- Externalize user-facing strings through resource/localization infrastructure and keep culture, UI culture, fallback, satellite-assembly, and formatting behavior explicit. +- Use culture-aware or ordinal string APIs per the contract; avoid locale-specific assumptions in identifiers, paths, configuration keys, analyzer comparisons, and persisted values. +- Handle text encoding, line endings, and persisted or protocol output deliberately, using canonical repo/protocol formatting instead of platform defaults when tools consume the output. +- Detect operating system, architecture, target framework, SDK, and host capabilities through supported APIs or MSBuild metadata; avoid hard-coded platform configuration or unsupported path assumptions. +- Keep platform-specific tests explicit with platform skip conditions, queue conditions, and separate scenarios rather than burying incompatible behavior in conditional test bodies. + +### Analyzers, reflection, source generation, trimming, and AOT + +- Analyzer logic may stay syntax-only when syntax fully proves the diagnostic; add semantic models, symbols, and related or multiple locations only when needed for correctness, symbol identity, partial declarations, or actionable fixes, and avoid false positives in generated code. +- Cache repeated Roslyn symbol, type, and syntax lookups; combine tree traversal with diagnostic construction when it avoids redundant reflection or compilation work. +- Keep analyzer and code-fix packaging lean; avoid heavy workspace dependencies in analyzer assemblies unless necessary for the shipped scenario. +- Prefer explicit reflection lookups, generic constraints, source-generated metadata, and annotated APIs over broad reflection scans that are fragile under trimming or AOT. +- For shared-framework or template changes whose behavior depends on metadata availability, use the repository's [publish-time trimming and Native AOT validation procedure](Trimming.md#validate-trimming-behavior), including source-generated metadata paths. + +### Build, packaging, shared framework, and templates + +- Preserve layouts, package metadata, target names, template identifiers, shared-framework inclusions, reference/runtime asset separation, and SDK/tooling compatibility that downstream consumers already load. +- Keep shared build values single-sourced and narrowly scoped; prefer authoritative project metadata over duplicate opt-in properties, and avoid repository-wide imports or suppressions for local issues. +- Update interrelated dependency versions, feed settings, source-commit metadata, and parent relationships as a coherent set; pin versions when reproducibility or host compatibility matters. +- Validate MSBuild conditions, item metadata, glob depth, command-line escaping, response-file usage, and path normalization carefully, since small mistakes can silently disable build or packaging logic. +- Dependency, package, or license changes must maintain third-party attribution artifacts such as `THIRD-PARTY-NOTICES.txt`; passing builds or tests can still hide a notice, license metadata, or attribution regression. +- In templates and widely used assets, avoid speculative churn; reserve unique identifiers, keep generated output stable, and add behavior changes only for demonstrated scenarios with tests. + +### Tests, determinism, and test utilities + +- Apply the [repository test requirements](../CONTRIBUTING.md#tests) and [faithful-validation requirements](../.github/copilot-instructions.md#running-tests). Add focused unit, integration, analyzer, template, or regression tests for changed behavior, covering success, failure, boundary, platform, and previously broken combinations. +- Assert observable semantics — generated files, diagnostics, logs, configuration keys, exception messages, response headers, package metadata, and resource cleanup — rather than mirroring helper implementation details. +- Keep tests deterministic: avoid timing-sensitive sleeps, current-working-directory assumptions, hard-coded ports, external service dependencies, order-sensitive output, and shared mutable state. +- Test infrastructure should use shared helpers for unique paths, ports, retries, process execution, timeouts, output capture, Helix staging, and cleanup instead of duplicating per-test logic. +- Preserve quarantine, skip conditions, pipeline conditions, and artifact staging until the protected scenario is understood; update the reason or implementation rather than removing the guard. diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolBlockAttribute.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolBlockAttribute.cs new file mode 100644 index 000000000000..aace44de33cc --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolBlockAttribute.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Associates a typed with a tool name. +/// +/// +/// +/// [ToolBlock("get_weather")] +/// public partial class WeatherBlock : FunctionInvocationContentBlock; +/// +/// +[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] +public sealed class ToolBlockAttribute : Attribute +{ + /// + /// Initializes a new instance of . + /// + /// The function name emitted by the model. + public ToolBlockAttribute(string toolName) + { + ArgumentException.ThrowIfNullOrEmpty(toolName); + ToolName = toolName; + } + + /// + /// Gets the function name associated with the block. + /// + public string ToolName { get; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolParameterAttribute.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolParameterAttribute.cs new file mode 100644 index 000000000000..945f0da645b7 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolParameterAttribute.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Populates a typed block property from a function-call argument. +/// +[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] +public sealed class ToolParameterAttribute : Attribute +{ + /// + /// Gets or sets the function argument name. The property name is used when omitted. + /// + public string? Name { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolResultAttribute.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolResultAttribute.cs new file mode 100644 index 000000000000..0a1534c83e20 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolResultAttribute.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Populates a typed block property from a function result. +/// +[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] +public sealed class ToolResultAttribute : Attribute +{ + /// + /// Gets or sets the result property name. The block property name is used when omitted. + /// + public string? Name { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ActivityContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ActivityContentBlock.cs new file mode 100644 index 000000000000..eb271897f57f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ActivityContentBlock.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text.Json; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents activity or progress content that can change while a response streams. +/// +public class ActivityContentBlock : ContentBlock +{ + /// + /// Gets or sets the application-defined activity type. + /// + public string ActivityType { get; set; } = string.Empty; + + /// + /// Gets or sets the current activity payload. + /// + public JsonElement Content { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ApprovalStatus.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ApprovalStatus.cs new file mode 100644 index 000000000000..52fbc2227e09 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ApprovalStatus.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Describes the response to a function approval request. +/// +public enum ApprovalStatus +{ + /// + /// The function is waiting for a response. + /// + Pending, + + /// + /// The function was approved. + /// + Approved, + + /// + /// The function was rejected. + /// + Rejected, +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/BlockLifecycleState.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/BlockLifecycleState.cs new file mode 100644 index 000000000000..5fed8b70873c --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/BlockLifecycleState.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Describes where a is in its streaming lifecycle. +/// +public enum BlockLifecycleState +{ + /// + /// The block has been created but has not been emitted to the conversation yet. + /// + Pending, + + /// + /// The block is part of the conversation and can still receive updates from the model stream. + /// + Active, + + /// + /// The block is complete and will not receive further updates. + /// + Inactive, +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlock.cs new file mode 100644 index 000000000000..d0fccaa4f9bb --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlock.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Base class for a unit of conversation content that the UI renders and that can be +/// updated while the model response is still streaming. +/// +/// +/// Subscribe to updates while a block streams: +/// +/// using var subscription = block.OnChanged(() => StateHasChanged()); +/// +/// +public abstract class ContentBlock +{ + private readonly List _callbacks = new(); + + /// + /// Gets the identifier of this block. Blocks produced by the same model message share the same identifier. + /// + public string Id { get; internal set; } = string.Empty; + + /// + /// Gets the current lifecycle state of this block. + /// + public BlockLifecycleState LifecycleState { get; internal set; } + + /// + /// Gets the role of the conversation participant that produced this block. + /// + public ChatRole? Role { get; internal set; } + + /// + /// Gets the name of the author that produced this block, when the model provides one. + /// + public string? AuthorName { get; internal set; } + + /// + /// Registers a callback that runs whenever this block changes. + /// + /// The callback to invoke when the block changes. + /// A subscription that removes the callback when disposed. + public ContentBlockChangedSubscription OnChanged(Action callback) + { + ArgumentNullException.ThrowIfNull(callback); + _callbacks.Add(callback); + return new ContentBlockChangedSubscription(this, callback); + } + + /// + /// Notifies subscribers that this block changed. + /// + protected void NotifyChanged() + { + // Snapshot the callbacks to allow safe removal during iteration + var snapshot = _callbacks.ToArray(); + for (var i = 0; i < snapshot.Length; i++) + { + snapshot[i](); + } + } + + internal void InvokeNotifyChanged() => NotifyChanged(); + + internal void RemoveCallback(Action callback) + { + _callbacks.Remove(callback); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs new file mode 100644 index 000000000000..1404a6957887 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a subscription to . +/// Disposing the subscription removes the callback from the block. +/// +public readonly struct ContentBlockChangedSubscription : IDisposable +{ + private readonly ContentBlock _owner; + private readonly Action _callback; + + internal ContentBlockChangedSubscription(ContentBlock owner, Action callback) + { + _owner = owner; + _callback = callback; + } + + /// + /// Removes the callback from the block it was registered on. + /// + public void Dispose() + { + _owner?.RemoveCallback(_callback); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs new file mode 100644 index 000000000000..e057416e7f06 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs @@ -0,0 +1,123 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a function invocation that requires approval before the conversation can continue. +/// +/// +/// +/// if (block.Status == ApprovalStatus.Pending) +/// { +/// block.Approve(); +/// } +/// +/// +public class FunctionApprovalBlock : ContentBlock, IInteractiveBlock +{ + private readonly TaskCompletionSource _resultSource = + new(TaskCreationOptions.RunContinuationsAsynchronously); + private readonly object _responseLock = new(); + + internal FunctionApprovalBlock( + ContentBlock innerBlock, + ToolApprovalRequestContent request) + { + ArgumentNullException.ThrowIfNull(innerBlock); + InnerBlock = innerBlock; + ApprovalRequest = request; + } + + /// + /// Gets the wrapped function invocation block. + /// + public ContentBlock InnerBlock { get; } + + /// + /// Gets the function call represented by this block. + /// + public FunctionCallContent? Call => InnerBlock switch + { + FunctionInvocationContentBlock invocation => invocation.Call, + UIActionBlock action => action.Call, + _ => null, + }; + + /// + /// Gets the function result represented by this block. + /// + public FunctionResultContent? Result => InnerBlock switch + { + FunctionInvocationContentBlock invocation => invocation.Result, + UIActionBlock action => action.Result, + _ => null, + }; + + /// + /// Gets the name of the invoked tool. + /// + public string? ToolName => Call?.Name; + + /// + /// Gets the arguments supplied to the tool. + /// + public IDictionary? Arguments => Call?.Arguments; + + /// + /// Gets a value indicating whether the server produced a result. + /// + public bool HasResult => Result is not null; + + /// + /// Gets the current approval status. + /// + public ApprovalStatus Status { get; private set; } + + /// + /// Gets the approval request received from the chat client. + /// + public ToolApprovalRequestContent ApprovalRequest { get; } + + /// + /// Approves the function invocation. Only the first response is applied. + /// + public void Approve() + { + Respond(ApprovalStatus.Approved, reason: null); + } + + /// + /// Rejects the function invocation. Only the first response is applied. + /// + /// An optional explanation for the rejection. + public void Reject(string? reason = null) + { + Respond(ApprovalStatus.Rejected, reason); + } + + /// + public Task GetResultAsync(CancellationToken cancellationToken = default) + => _resultSource.Task.WaitAsync(cancellationToken); + + private void Respond(ApprovalStatus status, string? reason) + { + lock (_responseLock) + { + if (Status != ApprovalStatus.Pending) + { + return; + } + + Status = status; + var response = ApprovalRequest.CreateResponse( + approved: status == ApprovalStatus.Approved, + reason); + _resultSource.SetResult(response); + } + + NotifyChanged(); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs new file mode 100644 index 000000000000..f37022dfff01 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a server-side function invocation and its eventual result. +/// +/// +/// Custom content blocks that represent function invocations should derive from this type +/// and populate . This keeps the call, tool name, and arguments available +/// when other features, such as function approval, wrap the custom block. +/// +/// +/// +/// public sealed class WeatherContentBlock : FunctionInvocationContentBlock +/// { +/// public string? Location { get; set; } +/// } +/// +/// +public class FunctionInvocationContentBlock : ContentBlock +{ + private FunctionCallContent? _call; + + /// + /// Gets or sets the function call represented by this block. + /// + public FunctionCallContent? Call + { + get => _call; + set + { + _call = value; + if (value is not null) + { + Id = value.CallId; + } + } + } + + /// + /// Gets or sets the function result paired with . + /// + public FunctionResultContent? Result { get; set; } + + /// + /// Gets the name of the invoked tool. + /// + public string? ToolName => Call?.Name; + + /// + /// Gets the arguments supplied to the tool. + /// + public IDictionary? Arguments => Call?.Arguments; + + /// + /// Gets a value indicating whether the server produced a result. + /// + public bool HasResult => Result is not null; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs new file mode 100644 index 000000000000..2a67244ace0c --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a content block that pauses a conversation until the user supplies a result. +/// +public interface IInteractiveBlock +{ + /// + /// Waits for the user-supplied result. + /// + /// A token that cancels the wait. + /// The content used to continue the conversation. + Task GetResultAsync(CancellationToken cancellationToken = default); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichContentBlock.cs new file mode 100644 index 000000000000..59887909b337 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichContentBlock.cs @@ -0,0 +1,45 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// A block of conversational text. Text arrives in fragments while the model streams, +/// so the block accumulates the fragments and exposes both the raw text and the +/// paragraphs derived from it. +/// +public class RichContentBlock : ContentBlock +{ + private readonly List _segments = new(); + private string? _cachedText; + + /// + /// Gets the concatenation of every text fragment received so far. + /// + public string RawText => _cachedText ??= string.Concat(_segments); + + /// + /// Gets the structured representation of . + /// + public IReadOnlyList Content { get; internal set; } = Array.Empty(); + + /// + /// Appends a text fragment to this block. + /// + /// The fragment to append. + public void AppendText(string text) + { + ArgumentNullException.ThrowIfNull(text); + + _segments.Add(text); + _cachedText = null; + } + + internal void ReplaceContent(string text, IReadOnlyList content) + { + _segments.Clear(); + _segments.Add(text); + _cachedText = text; + Content = content; + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs new file mode 100644 index 000000000000..d92dfc5066a8 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a block quotation. +/// +public class BlockQuoteNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs new file mode 100644 index 000000000000..34f5f5a674ea --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a block of code. +/// +public class CodeBlockNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public CodeBlockNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The code. + /// The optional language identifier. + public CodeBlockNode(string code, string? language = null) + { + ArgumentNullException.ThrowIfNull(code); + Code = code; + Language = language; + } + + /// + /// Gets or sets the language identifier. + /// + public string? Language { get; set; } + + /// + /// Gets or sets the code. + /// + public string Code { get; set; } = string.Empty; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs new file mode 100644 index 000000000000..a3b9507608b6 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a link or image reference definition. +/// +public class DefinitionNode : RichTextNode +{ + /// + /// Gets or sets the reference label. + /// + public string Label { get; set; } = string.Empty; + + /// + /// Gets or sets the target URL. + /// + public string Url { get; set; } = string.Empty; + + /// + /// Gets or sets the optional title. + /// + public string? Title { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs new file mode 100644 index 000000000000..300932d81b29 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents emphasized text. +/// +public class EmphasisNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs new file mode 100644 index 000000000000..7f12bf111a4d --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a footnote definition. +/// +/// +/// A mapper can use this node for labeled footnote content, such as content represented by +/// a Markdig footnote container. The core library does not parse or resolve footnote syntax. +/// +public class FootnoteDefinitionNode : RichTextNode +{ + /// + /// Gets or sets the footnote label. + /// + public string Label { get; set; } = string.Empty; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs new file mode 100644 index 000000000000..97d4926e368c --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents footnote content supplied by an application's rich-text mapper. +/// +/// +/// Parsers model footnotes differently. For example, Markdig exposes footnote containers, +/// links, and an end-of-document footnote group. A mapper can project those parser-specific +/// objects into the footnote presentation nodes without introducing a parser dependency. +/// +public class FootnoteNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs new file mode 100644 index 000000000000..9c67171555fb --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a footnote reference. +/// +/// +/// A mapper can use this node for a reference such as a Markdig footnote link. The core +/// library does not parse the reference or resolve its label. +/// +public class FootnoteReferenceNode : RichTextNode +{ + /// + /// Gets or sets the footnote label. + /// + public string Label { get; set; } = string.Empty; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HeadingNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HeadingNode.cs new file mode 100644 index 000000000000..bc36c95d3968 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HeadingNode.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a heading. +/// +public class HeadingNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public HeadingNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The heading level. + public HeadingNode(int level) + { + Level = level; + } + + /// + /// Gets or sets the heading level. + /// + public int Level { get; set; } = 1; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HtmlNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HtmlNode.cs new file mode 100644 index 000000000000..8358abe5f750 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HtmlNode.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents HTML source. The default renderer displays the source as text. +/// +public class HtmlNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public HtmlNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The HTML source. + public HtmlNode(string value) + { + ArgumentNullException.ThrowIfNull(value); + Value = value; + } + + /// + /// Gets or sets the HTML source. + /// + public string Value { get; set; } = string.Empty; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageNode.cs new file mode 100644 index 000000000000..e1838c7d1fca --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageNode.cs @@ -0,0 +1,46 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents an image. +/// +public class ImageNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public ImageNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The image URL. + /// The alternative text. + /// The optional title. + public ImageNode(string url, string? alt = null, string? title = null) + { + ArgumentNullException.ThrowIfNull(url); + Url = url; + Alt = alt; + Title = title; + } + + /// + /// Gets or sets the image URL. + /// + public string Url { get; set; } = string.Empty; + + /// + /// Gets or sets the alternative text. + /// + public string? Alt { get; set; } + + /// + /// Gets or sets the optional title. + /// + public string? Title { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs new file mode 100644 index 000000000000..75b3c2af11aa --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a reference-style image. +/// +public class ImageReferenceNode : RichTextNode +{ + /// + /// Gets or sets the reference label. + /// + public string Label { get; set; } = string.Empty; + + /// + /// Gets or sets the alternative text. + /// + public string? Alt { get; set; } + + /// + /// Gets or sets the reference syntax. + /// + public ReferenceKind ReferenceKind { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs new file mode 100644 index 000000000000..4be230f1651d --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents inline code. +/// +public class InlineCodeNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public InlineCodeNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The code. + public InlineCodeNode(string code) + { + ArgumentNullException.ThrowIfNull(code); + Code = code; + } + + /// + /// Gets or sets the code. + /// + public string Code { get; set; } = string.Empty; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs new file mode 100644 index 000000000000..3d62aabab60f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a forced visual line break. +/// +/// +/// This node does not encode a parser-specific soft or hard line-ending distinction. A +/// mapper from Markdig or any other parser decides whether a source line ending becomes +/// whitespace, text, or a . +/// +public class LineBreakNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkNode.cs new file mode 100644 index 000000000000..8542750d2168 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkNode.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a hyperlink. +/// +public class LinkNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public LinkNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The link URL. + /// The optional title. + public LinkNode(string url, string? title = null) + { + ArgumentNullException.ThrowIfNull(url); + Url = url; + Title = title; + } + + /// + /// Gets or sets the link URL. + /// + public string Url { get; set; } = string.Empty; + + /// + /// Gets or sets the optional title. + /// + public string? Title { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs new file mode 100644 index 000000000000..16a71493402f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a reference-style link. +/// +public class LinkReferenceNode : RichTextNode +{ + /// + /// Gets or sets the reference label. + /// + public string Label { get; set; } = string.Empty; + + /// + /// Gets or sets the reference syntax. + /// + public ReferenceKind ReferenceKind { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListItemNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListItemNode.cs new file mode 100644 index 000000000000..a85200b58442 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListItemNode.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a list item. +/// +public class ListItemNode : RichTextNode +{ + /// + /// Gets or sets the checked state when the item is a task. + /// + public bool? Checked { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListNode.cs new file mode 100644 index 000000000000..6c7d263e6143 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListNode.cs @@ -0,0 +1,38 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents an ordered or unordered list. +/// +public class ListNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public ListNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// Whether the list is ordered. + /// The optional starting number. + public ListNode(bool ordered, int? start = null) + { + Ordered = ordered; + Start = start; + } + + /// + /// Gets or sets a value indicating whether the list is ordered. + /// + public bool Ordered { get; set; } + + /// + /// Gets or sets the starting number of an ordered list. + /// + public int? Start { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs new file mode 100644 index 000000000000..7b105148c32d --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a paragraph. +/// +public class ParagraphNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs new file mode 100644 index 000000000000..16486d946fa2 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Describes the syntax used by a reference. +/// +public enum ReferenceKind +{ + /// + /// A shortcut reference. + /// + Shortcut, + + /// + /// A collapsed reference. + /// + Collapsed, + + /// + /// A full reference. + /// + Full, +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextContent.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextContent.cs new file mode 100644 index 000000000000..ea65d1dd4748 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextContent.cs @@ -0,0 +1,45 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a complete snapshot of structured text in a streaming chat response. +/// +/// +/// Providers can emit a new snapshot as text streams. The block mapping pipeline replaces +/// the previous snapshot without exposing a partially mutated tree to renderers. +/// The constructor copies the top-level node list, but the nodes themselves remain shared. +/// Callers must not mutate nodes after publishing the content. +/// +public class RichTextContent : AIContent +{ + /// + /// Initializes a new instance of . + /// + /// The plain-text representation of the content. + /// + /// The structured nodes that represent . The constructor copies this + /// list but does not clone the nodes. + /// + public RichTextContent(string text, IReadOnlyList nodes) + { + ArgumentNullException.ThrowIfNull(text); + ArgumentNullException.ThrowIfNull(nodes); + + Text = text; + Nodes = [.. nodes]; + } + + /// + /// Gets the plain-text representation of the content. + /// + public string Text { get; } + + /// + /// Gets the structured nodes that represent . + /// + public IReadOnlyList Nodes { get; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextNode.cs new file mode 100644 index 000000000000..7c66c897d9fa --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextNode.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a node in structured conversational text. +/// +/// +/// This hierarchy describes presentation semantics and does not prescribe a source format +/// or parser. Applications can map output from Markdig or any other parser into these nodes. +/// The mapper is responsible for interpreting source syntax, resolving references, and +/// deciding which presentation node represents each source construct. +/// +public abstract class RichTextNode +{ + private List? _children; + + /// + /// Gets the child nodes. + /// + public IReadOnlyList Children => + _children ?? (IReadOnlyList)Array.Empty(); + + /// + /// Adds a child node. + /// + /// The child to add. + public void AddChild(RichTextNode child) + { + ArgumentNullException.ThrowIfNull(child); + + _children ??= new(); + _children.Add(child); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs new file mode 100644 index 000000000000..adac69763c9f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents struck-through text. +/// +public class StrikethroughNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrongNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrongNode.cs new file mode 100644 index 000000000000..b2c12926d787 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrongNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents strongly emphasized text. +/// +public class StrongNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableCellNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableCellNode.cs new file mode 100644 index 000000000000..79e42f2743d5 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableCellNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a table cell. +/// +public class TableCellNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs new file mode 100644 index 000000000000..e5bcad07eff7 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Describes the alignment of a table column. +/// +public enum TableColumnAlignment +{ + /// + /// No alignment was specified. + /// + None, + + /// + /// Left-aligned. + /// + Left, + + /// + /// Center-aligned. + /// + Center, + + /// + /// Right-aligned. + /// + Right, +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableNode.cs new file mode 100644 index 000000000000..e819464fe62f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableNode.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a table. +/// +public class TableNode : RichTextNode +{ + /// + /// Gets or sets each column's alignment. + /// + public IReadOnlyList Alignment { get; set; } = + Array.Empty(); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableRowNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableRowNode.cs new file mode 100644 index 000000000000..e09ce01bb34f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableRowNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a table row. +/// +public class TableRowNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TextNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TextNode.cs new file mode 100644 index 000000000000..958be5d930d2 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TextNode.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents plain text. +/// +public class TextNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public TextNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The text. + public TextNode(string text) + { + ArgumentNullException.ThrowIfNull(text); + Text = text; + } + + /// + /// Gets or sets the text. + /// + public string Text { get; set; } = string.Empty; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs new file mode 100644 index 000000000000..e465c724a625 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a thematic break. +/// +public class ThematicBreakNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/UIActionBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/UIActionBlock.cs new file mode 100644 index 000000000000..6389624516e7 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/UIActionBlock.cs @@ -0,0 +1,101 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a function call that must execute in the UI before the conversation can continue. +/// +/// +/// Register the corresponding function with +/// . Renderers can call +/// to execute it in the current UI circuit. +/// +/// +/// +/// <BlockRenderer TBlock="UIActionBlock" Context="action"> +/// <button @onclick="() => action.InvokeAsync()">Run</button> +/// </BlockRenderer> +/// +/// +public class UIActionBlock : ContentBlock, IInteractiveBlock +{ + private readonly AIFunction _function; + private readonly TaskCompletionSource _resultSource = + new(TaskCreationOptions.RunContinuationsAsynchronously); + private readonly object _invocationLock = new(); + private Task? _invocation; + + internal UIActionBlock(AIFunction function, FunctionCallContent call) + { + _function = function; + Call = call; + } + + /// + /// Gets the function call requested by the model. + /// + public FunctionCallContent Call { get; } + + /// + /// Gets the registered UI action name. + /// + public string ToolName => Call.Name; + + /// + /// Gets the function result after the action completes. + /// + public FunctionResultContent? Result { get; private set; } + + /// + /// Gets a value indicating whether the action completed successfully. + /// + public bool IsComplete => Result is not null; + + /// + /// Executes the registered function once using the arguments supplied by the model. + /// + /// + /// A token that cancels the action when this call starts it. Subsequent calls return the + /// existing invocation task and do not replace its cancellation token. + /// + /// A task that completes when the action has finished. + public Task InvokeAsync(CancellationToken cancellationToken = default) + { + lock (_invocationLock) + { + _invocation ??= InvokeCoreAsync(cancellationToken); + return _invocation; + } + } + + /// + public Task GetResultAsync(CancellationToken cancellationToken = default) + => _resultSource.Task.WaitAsync(cancellationToken); + + private async Task InvokeCoreAsync(CancellationToken cancellationToken) + { + try + { + var arguments = Call.Arguments is not null + ? new AIFunctionArguments(Call.Arguments) + : null; + var result = await _function.InvokeAsync(arguments, cancellationToken); + Result = new FunctionResultContent(Call.CallId ?? Id, result); + NotifyChanged(); + _resultSource.TrySetResult(Result); + } + catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) + { + _resultSource.TrySetCanceled(cancellationToken); + throw; + } + catch (Exception exception) + { + _resultSource.TrySetException(exception); + throw; + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/AgentBoundary.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/AgentBoundary.cs new file mode 100644 index 000000000000..11712b97b29f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/AgentBoundary.cs @@ -0,0 +1,78 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.Rendering; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Creates the for a and cascades it to the +/// chat components underneath it. +/// +public class AgentBoundary : ComponentBase, IDisposable +{ + private AgentContext _context = default!; + private UIAgent _currentAgent = default!; + + /// + /// Gets or sets the agent that drives the conversation. + /// + [Parameter, EditorRequired] + public UIAgent Agent { get; set; } = default!; + + /// + /// Gets or sets the content rendered inside the boundary. + /// + [Parameter] + public RenderFragment? ChildContent { get; set; } + + /// + protected override void OnInitialized() + { + _currentAgent = Agent; + _context = new AgentContext(Agent); + } + + /// + protected override void OnParametersSet() + { + if (!ReferenceEquals(Agent, _currentAgent)) + { + // Agent changed — tear down the old context and create a new one. + // BuildRenderTree uses OpenRegion keyed on the context, so Blazor will + // also tear down and recreate all descendant components. + _context?.Dispose(); + _currentAgent = Agent; + _context = new AgentContext(Agent); + } + } + + /// + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + // If Agent changes, the region key changes, causing Blazor to tear down + // and recreate all descendants. This is the same trick EditForm uses with + // EditContext. It lets us safely use IsFixed=true on the CascadingValue. + builder.OpenRegion(_context.GetHashCode()); + + builder.OpenComponent>(0); + builder.AddComponentParameter(1, "Value", _context); + builder.AddComponentParameter(2, "IsFixed", true); + builder.AddComponentParameter(3, "ChildContent", (RenderFragment)(inner => + { + inner.AddContent(10, ChildContent); + })); + builder.CloseComponent(); + + builder.CloseRegion(); + } + + /// + /// Disposes the owned by this boundary. + /// + public void Dispose() + { + _context?.Dispose(); + GC.SuppressFinalize(this); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockContainer.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockContainer.cs new file mode 100644 index 000000000000..f26a04e57ab0 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockContainer.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +// Renders a single block and re-renders the message list when the block changes. +internal class BlockContainer : IDisposable +{ + private readonly ContentBlock _block; + private readonly MessageListContext _listContext; + private readonly ContentBlockChangedSubscription _changedSub; + + internal BlockContainer(ContentBlock block, MessageListContext listContext, Action requestRender) + { + _block = block; + _listContext = listContext; + _changedSub = block.OnChanged(requestRender); + } + + internal void RenderTo(Rendering.RenderTreeBuilder builder, int seq) + { + var fragment = _listContext.RenderBlock(_block); + builder.AddContent(seq, fragment); + } + + public void Dispose() + { + _changedSub.Dispose(); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRenderer.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRenderer.cs new file mode 100644 index 000000000000..7a3492a7255e --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRenderer.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Registers custom markup for a block type inside a . The most +/// recently registered renderer that matches a block wins. +/// +/// The block type this renderer handles. +/// +/// +/// <MessageList> +/// <BlockRenderer TBlock="RichContentBlock" Context="block"> +/// <p>@block.RawText</p> +/// </BlockRenderer> +/// </MessageList> +/// +/// +public class BlockRenderer : IComponent, IDisposable where TBlock : ContentBlock +{ + private RenderHandle _renderHandle; + private bool _initialized; + private BlockRendererRegistration? _registration; + + /// + /// Gets or sets the message list this renderer registers with. + /// + [CascadingParameter] + public MessageListContext ListContext { get; set; } = default!; + + /// + /// Gets or sets the markup rendered for a matching block. + /// + [Parameter] + public RenderFragment? ChildContent { get; set; } + + /// + /// Gets or sets a predicate that narrows which blocks this renderer handles. + /// + [Parameter] + public Func? When { get; set; } + + void IComponent.Attach(RenderHandle renderHandle) + { + _renderHandle = renderHandle; + } + + Task IComponent.SetParametersAsync(ParameterView parameters) + { + parameters.SetParameterProperties(this); + + if (ListContext is null) + { + throw new InvalidOperationException( + "BlockRenderer must be placed inside a MessageList."); + } + + if (ChildContent is null) + { + throw new InvalidOperationException("BlockRenderer requires child content."); + } + + if (!_initialized) + { + _initialized = true; + + _registration = new BlockRendererRegistration + { + BlockType = typeof(TBlock), + // Capture 'this' so the lambda reads the latest When/ChildContent at invocation time + When = block => block is TBlock typed && (When is null || When(typed)), + Render = block => ChildContent((TBlock)block) + }; + + ListContext.AddRegistration(_registration); + } + + return Task.CompletedTask; + } + + /// + /// Removes this renderer from the message list. + /// + public void Dispose() + { + if (_registration is not null) + { + ListContext?.RemoveRegistration(_registration); + } + + GC.SuppressFinalize(this); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRendererRegistration.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRendererRegistration.cs new file mode 100644 index 000000000000..b876c68cb91f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRendererRegistration.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +internal class BlockRendererRegistration +{ + public required Type BlockType { get; init; } + + public Func? When { get; init; } + + public required Func Render { get; init; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ChatPage.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ChatPage.cs new file mode 100644 index 000000000000..e40835a996e1 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ChatPage.cs @@ -0,0 +1,128 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.Rendering; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Full page chat shell: an around a scrollable +/// and a . +/// +/// +/// +/// <ChatPage Agent="agent" Placeholder="Ask me anything" /> +/// +/// +public sealed class ChatPage : ComponentBase +{ + /// + /// Gets or sets the agent that drives the conversation. + /// + [Parameter, EditorRequired] + public UIAgent Agent { get; set; } = default!; + + /// + /// Gets or sets the content rendered above the conversation. + /// + [Parameter] + public RenderFragment? Header { get; set; } + + /// + /// Gets or sets the content rendered when the conversation is empty. + /// + [Parameter] + public RenderFragment? WelcomeContent { get; set; } + + /// + /// Gets or sets the content rendered inside the message list, typically + /// registrations. + /// + [Parameter] + public RenderFragment? MessageListContent { get; set; } + + /// + /// Gets or sets the placeholder text of the message input. + /// + [Parameter] + public string? Placeholder { get; set; } + + /// + /// Gets or sets the content rendered before the message input text area. + /// + [Parameter] + public RenderFragment? InputLeadingActions { get; set; } + + /// + /// Gets or sets the content rendered after the message input text area. + /// + [Parameter] + public RenderFragment? InputTrailingActions { get; set; } + + /// + /// Gets or sets additional attributes applied to the root element. + /// + [Parameter(CaptureUnmatchedValues = true)] + public Dictionary? AdditionalAttributes { get; set; } + + /// + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.OpenElement(0, "div"); + builder.AddMultipleAttributes(1, AdditionalAttributes); + builder.AddAttribute(2, "class", CssClass()); + + if (Header is not null) + { + builder.OpenElement(10, "div"); + builder.AddAttribute(11, "class", "sc-ai-chat-page__header"); + builder.AddContent(12, Header); + builder.CloseElement(); + } + + builder.OpenComponent(20); + builder.AddComponentParameter(21, "Agent", Agent); + builder.AddComponentParameter(22, "ChildContent", (RenderFragment)(inner => + { + // Body (scrollable area) + inner.OpenElement(30, "div"); + inner.AddAttribute(31, "class", "sc-ai-chat-page__body"); + + inner.OpenComponent(32); + inner.AddComponentParameter(33, "ChildContent", MessageListContent); + inner.AddComponentParameter(34, "EmptyContent", WelcomeContent); + inner.CloseComponent(); // MessageList + + inner.CloseElement(); // body + + // Footer (input area) + inner.OpenElement(50, "div"); + inner.AddAttribute(51, "class", "sc-ai-chat-page__footer"); + inner.OpenElement(52, "div"); + inner.AddAttribute(53, "class", "sc-ai-chat-page__input-container"); + + inner.OpenComponent(54); + inner.AddComponentParameter(55, "Placeholder", Placeholder); + inner.AddComponentParameter(56, "LeadingActions", InputLeadingActions); + inner.AddComponentParameter(57, "TrailingActions", InputTrailingActions); + inner.CloseComponent(); // MessageInput + + inner.CloseElement(); // input-container + inner.CloseElement(); // footer + })); + builder.CloseComponent(); // AgentBoundary + + builder.CloseElement(); // root div + } + + private string CssClass() + { + var css = "sc-ai-root sc-ai-chat-page"; + if (AdditionalAttributes?.TryGetValue("class", out var existing) == true && existing is string s) + { + css = $"{css} {s}"; + } + + return css; + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ConversationTurnRenderer.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ConversationTurnRenderer.cs new file mode 100644 index 000000000000..a3666f9aef00 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ConversationTurnRenderer.cs @@ -0,0 +1,74 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.Rendering; + +namespace Microsoft.AspNetCore.Components.AI; + +// Renders one conversation turn: its request blocks followed by its response blocks. +internal class ConversationTurnRenderer : IDisposable +{ + private readonly ConversationTurn _turn; + private readonly MessageListContext _listContext; + private readonly Action _requestRender; + private readonly List _blockContainers = new(); + private readonly IDisposable? _blockAddedSub; + + internal ConversationTurnRenderer( + AgentContext agentContext, + ConversationTurn turn, + MessageListContext listContext, + Action requestRender) + { + _turn = turn; + _listContext = listContext; + _requestRender = requestRender; + + _blockAddedSub = agentContext.RegisterOnBlockAdded((t, block) => + { + if (ReferenceEquals(t, _turn)) + { + OnBlockAdded(block); + } + }); + + foreach (var block in turn.RequestBlocks) + { + _blockContainers.Add(new BlockContainer(block, _listContext, _requestRender)); + } + foreach (var block in turn.ResponseBlocks) + { + _blockContainers.Add(new BlockContainer(block, _listContext, _requestRender)); + } + } + + private void OnBlockAdded(ContentBlock block) + { + _blockContainers.Add(new BlockContainer(block, _listContext, _requestRender)); + _requestRender(); + } + + internal void RenderTo(RenderTreeBuilder builder, int baseSeq) + { + // Determine role from request blocks (user turn) or response blocks + var role = _turn.RequestBlocks.Count > 0 ? "user" : "assistant"; + builder.OpenElement(baseSeq, "div"); + builder.AddAttribute(baseSeq + 1, "class", $"sc-ai-turn sc-ai-turn--{role}"); + var seq = baseSeq + 10; + foreach (var container in _blockContainers) + { + container.RenderTo(builder, seq); + seq += 10; + } + builder.CloseElement(); + } + + public void Dispose() + { + _blockAddedSub?.Dispose(); + foreach (var container in _blockContainers) + { + container.Dispose(); + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageInput.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageInput.cs new file mode 100644 index 000000000000..b61db3c99167 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageInput.cs @@ -0,0 +1,169 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.Web; +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Text input that sends messages to the cascaded and disables +/// itself while a response streams. +/// +public class MessageInput : IComponent, IDisposable +{ + private RenderHandle _renderHandle; + private AgentContext _agentContext = default!; + private string? _placeholder; + private RenderFragment? _leadingActions; + private RenderFragment? _trailingActions; + private string _text = ""; + private bool _isDisabled; + private IDisposable? _statusSub; + + /// + /// Gets or sets the conversation this input sends messages to. + /// + [CascadingParameter] + public AgentContext AgentContext { get; set; } = default!; + + /// + /// Gets or sets the placeholder text of the input. + /// + [Parameter] + public string? Placeholder { get; set; } + + /// + /// Gets or sets the content rendered before the text area. + /// + [Parameter] + public RenderFragment? LeadingActions { get; set; } + + /// + /// Gets or sets the content rendered after the text area. Replaces the default send button. + /// + [Parameter] + public RenderFragment? TrailingActions { get; set; } + + void IComponent.Attach(RenderHandle renderHandle) + { + _renderHandle = renderHandle; + } + + Task IComponent.SetParametersAsync(ParameterView parameters) + { + parameters.SetParameterProperties(this); + _agentContext = AgentContext + ?? throw new InvalidOperationException( + "MessageInput must be inside an AgentBoundary."); + _placeholder = Placeholder; + _leadingActions = LeadingActions; + _trailingActions = TrailingActions; + + // Register once. The AgentContext cascade is fixed for the lifetime of the component, + // so re-registering on every parameter set would accumulate handlers and retain the + // component on each parent re-render. + _statusSub ??= _agentContext.RegisterOnStatusChanged(status => + { + _isDisabled = status is ConversationStatus.Streaming or ConversationStatus.AwaitingInput; + Render(); + }); + + Render(); + return Task.CompletedTask; + } + + private void Render() + { + _renderHandle.Render(builder => + { + builder.OpenElement(0, "div"); + builder.AddAttribute(1, "class", "sc-ai-input"); + + if (_leadingActions is not null) + { + builder.AddContent(2, _leadingActions); + } + + builder.OpenElement(3, "div"); + builder.AddAttribute(4, "class", "sc-ai-input__body"); + + builder.OpenElement(10, "textarea"); + builder.AddAttribute(11, "class", "sc-ai-input__textarea"); + builder.AddAttribute(12, "placeholder", _placeholder ?? "Type a message..."); + builder.AddAttribute(13, "disabled", _isDisabled); + builder.AddAttribute(14, "value", _text); + builder.AddAttribute(15, "aria-label", _placeholder ?? "Type a message..."); + builder.AddAttribute(16, "oninput", + EventCallback.Factory.Create( + this, e => + { + _text = e.Value?.ToString() ?? ""; + // Re-render so the component's rendered value tracks the DOM value. + // Without this, clearing _text on submit produces no diff (the last + // rendered value was already empty) and the textarea is never cleared. + Render(); + })); + builder.SetUpdatesAttributeName("value"); + builder.AddAttribute(17, "onkeydown", + EventCallback.Factory.Create(this, OnKeyDown)); + builder.CloseElement(); // textarea + + builder.CloseElement(); // input body + + if (_trailingActions is not null) + { + builder.AddContent(50, _trailingActions); + } + else + { + builder.OpenElement(50, "button"); + builder.AddAttribute(51, "type", "button"); + builder.AddAttribute(52, "class", "sc-ai-input__send"); + builder.AddAttribute(53, "disabled", _isDisabled); + builder.AddAttribute(54, "aria-label", "Send message"); + builder.AddAttribute(55, "onclick", + EventCallback.Factory.Create(this, SubmitAsync)); + + // Send icon SVG + builder.AddMarkupContent(56, + ""); + + builder.CloseElement(); + } + + builder.CloseElement(); // div + }); + } + + private async Task OnKeyDown(KeyboardEventArgs e) + { + if (e.Key == "Enter" && !e.ShiftKey && !_isDisabled) + { + await SubmitAsync(); + } + } + + private async Task SubmitAsync() + { + if (_isDisabled || string.IsNullOrWhiteSpace(_text)) + { + return; + } + + var text = _text; + _text = ""; + Render(); + + await _agentContext.SendMessageAsync(new ChatMessage(ChatRole.User, text)); + } + + /// + /// Removes the status subscription this input registered on the conversation. + /// + public void Dispose() + { + _statusSub?.Dispose(); + GC.SuppressFinalize(this); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageList.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageList.cs new file mode 100644 index 000000000000..70e703f29806 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageList.cs @@ -0,0 +1,204 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.Rendering; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Renders the turns of the cascaded and updates them as blocks +/// stream in. +/// +[StreamRendering] +public class MessageList : IComponent, IDisposable +{ + private RenderHandle _renderHandle; + private AgentContext _agentContext = default!; + private RenderFragment? _childContent; + private RenderFragment? _footer; + private readonly MessageListContext _listContext = new(); + private readonly List _turnRenderers = new(); + private IDisposable? _turnAddedSub; + private IDisposable? _statusChangedSub; + + /// + /// Gets or sets the conversation rendered by this list. + /// + [CascadingParameter] + public AgentContext AgentContext { get; set; } = default!; + + /// + /// Gets or sets the content rendered above the turns. Use it to register + /// components. + /// + [Parameter] + public RenderFragment? ChildContent { get; set; } + + /// + /// Gets or sets the content rendered when the conversation has no turns. + /// + [Parameter] + public RenderFragment? EmptyContent { get; set; } + + /// + /// Gets or sets the content rendered below the turns. Defaults to the streaming and error + /// indicators. + /// + [Parameter] + public RenderFragment? Footer { get; set; } + + void IComponent.Attach(RenderHandle renderHandle) + { + _renderHandle = renderHandle; + } + + Task IComponent.SetParametersAsync(ParameterView parameters) + { + parameters.SetParameterProperties(this); + var newAgentContext = AgentContext + ?? throw new InvalidOperationException( + "MessageList must be inside an AgentBoundary."); + + if (!ReferenceEquals(_agentContext, newAgentContext)) + { + ResetRegistrations(); + _agentContext = newAgentContext; + _listContext.OnRegistrationsChanged = Render; + + _turnAddedSub = _agentContext.RegisterOnTurnAdded(OnTurnAdded); + _statusChangedSub = _agentContext.RegisterOnStatusChanged(_ => Render()); + + foreach (var turn in _agentContext.Turns) + { + var renderer = new ConversationTurnRenderer( + _agentContext, turn, _listContext, Render); + _turnRenderers.Add(renderer); + } + } + + _childContent = ChildContent; + _footer = Footer; + + Render(); + return Task.CompletedTask; + } + + private void OnTurnAdded(ConversationTurn turn) + { + var renderer = new ConversationTurnRenderer( + _agentContext, turn, _listContext, Render); + _turnRenderers.Add(renderer); + Render(); + } + + private void Render() + { + _renderHandle.Render(builder => + { + builder.OpenComponent>(0); + builder.AddComponentParameter(1, "Value", _listContext); + builder.AddComponentParameter(2, "IsFixed", true); + builder.AddComponentParameter(3, "ChildContent", + (RenderFragment)(inner => + { + inner.OpenElement(3, "div"); + inner.AddAttribute(3, "class", "sc-ai-message-list"); + if (_childContent is not null) + { + inner.AddContent(4, _childContent); + } + + if (_turnRenderers.Count == 0 && EmptyContent is not null) + { + inner.AddContent(5, EmptyContent); + } + + var seq = 100; + foreach (var turnRenderer in _turnRenderers) + { + turnRenderer.RenderTo(inner, seq); + seq += 100; + } + + inner.OpenElement(seq, "div"); + inner.AddAttribute(seq + 1, "class", "sc-ai-message-list__footer"); + if (_footer is not null) + { + inner.AddContent(seq + 2, _footer(_agentContext)); + } + else + { + RenderDefaultFooter(inner, seq + 2); + } + inner.CloseElement(); // footer div + + inner.CloseElement(); // sc-ai-message-list div + })); + builder.CloseComponent(); + }); + } + + private void RenderDefaultFooter(RenderTreeBuilder builder, int seq) + { + switch (_agentContext.Status) + { + case ConversationStatus.Streaming: + builder.OpenElement(seq, "div"); + builder.AddAttribute(seq + 1, "class", "sc-ai-typing"); + builder.AddAttribute(seq + 2, "role", "status"); + builder.AddAttribute(seq + 3, "aria-label", "Agent is typing"); + for (var i = 0; i < 3; i++) + { + builder.OpenElement(seq + 4 + i, "span"); + builder.AddAttribute(seq + 7 + i, "class", "sc-ai-typing__dot"); + builder.CloseElement(); + } + builder.CloseElement(); + break; + + case ConversationStatus.Error: + builder.OpenElement(seq, "div"); + builder.AddAttribute(seq + 1, "class", "sc-ai-error"); + builder.AddAttribute(seq + 2, "role", "alert"); + builder.OpenElement(seq + 3, "span"); + builder.AddAttribute(seq + 4, "class", "sc-ai-error__message"); + builder.AddContent(seq + 5, "Something went wrong. Please try again."); + builder.CloseElement(); // span + builder.OpenElement(seq + 6, "button"); + builder.AddAttribute(seq + 7, "type", "button"); + builder.AddAttribute(seq + 8, "class", "sc-ai-btn sc-ai-btn--secondary"); + builder.AddAttribute(seq + 9, "onclick", + EventCallback.Factory.Create(this, + () => _agentContext.RetryAsync())); + builder.AddContent(seq + 10, "Retry"); + builder.CloseElement(); // button + builder.CloseElement(); // div + break; + } + } + + private void ResetRegistrations() + { + _turnAddedSub?.Dispose(); + _turnAddedSub = null; + + _statusChangedSub?.Dispose(); + _statusChangedSub = null; + + foreach (var renderer in _turnRenderers) + { + renderer.Dispose(); + } + + _turnRenderers.Clear(); + } + + /// + /// Removes the subscriptions this list registered on the conversation. + /// + public void Dispose() + { + ResetRegistrations(); + GC.SuppressFinalize(this); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageListContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageListContext.cs new file mode 100644 index 000000000000..b262655f5864 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageListContext.cs @@ -0,0 +1,451 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.Rendering; +using Microsoft.Extensions.AI; +using System.Text.Json; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Resolves the markup used to render a block inside a . Renderers +/// registered with take precedence over the built-in +/// rendering. +/// +public class MessageListContext +{ + private static readonly JsonSerializerOptions IndentedJsonOptions = new() + { + WriteIndented = true, + }; + + private readonly List _registrations = new(); + + /// + /// Returns the markup for a block. + /// + /// The block to render. + /// The markup that renders . + public RenderFragment RenderBlock(ContentBlock block) + { + ArgumentNullException.ThrowIfNull(block); + + for (var i = _registrations.Count - 1; i >= 0; i--) + { + var reg = _registrations[i]; + if (reg.BlockType.IsAssignableFrom(block.GetType()) + && (reg.When is null || reg.When(block))) + { + return reg.Render(block); + } + } + + return builder => + { + if (block is RichContentBlock rich) + { + var role = block.Role == ChatRole.User ? "user" : "assistant"; + builder.OpenElement(0, "div"); + builder.AddAttribute(1, "class", $"sc-ai-message sc-ai-message--{role}"); + builder.OpenElement(2, "div"); + builder.AddAttribute(3, "class", "sc-ai-message__bubble"); + builder.OpenElement(4, "div"); + var contentClass = block.LifecycleState == BlockLifecycleState.Active + ? "sc-ai-message__content sc-ai-message__content--streaming" + : "sc-ai-message__content"; + builder.AddAttribute(5, "class", contentClass); + if (rich.Content.Count > 0) + { + RenderRichTextNodes(builder, rich.Content); + } + else + { + builder.AddContent(6, rich.RawText); + } + builder.CloseElement(); // content div + builder.CloseElement(); // bubble div + builder.CloseElement(); // message div + } + else if (block is FunctionApprovalBlock approval) + { + RenderApprovalBlock(builder, approval); + } + else if (block is not FunctionInvocationContentBlock) + { + builder.OpenElement(0, "div"); + builder.AddAttribute(1, "class", "sc-ai-unknown-block"); + builder.AddContent(2, block.GetType().Name); + builder.CloseElement(); + } + }; + } + + internal Action? OnRegistrationsChanged { get; set; } + + internal void AddRegistration(BlockRendererRegistration registration) + { + _registrations.Add(registration); + OnRegistrationsChanged?.Invoke(); + } + + internal void RemoveRegistration(BlockRendererRegistration registration) + { + _registrations.Remove(registration); + OnRegistrationsChanged?.Invoke(); + } + + private static void RenderRichTextNodes( + RenderTreeBuilder builder, + IReadOnlyList nodes) + { + foreach (var node in nodes) + { + builder.OpenRegion(0); + RenderRichTextNode(builder, node); + builder.CloseRegion(); + } + } + + private static void RenderRichTextNode(RenderTreeBuilder builder, RichTextNode node) + { + switch (node) + { + case TextNode text: + builder.AddContent(0, text.Text); + break; + case ParagraphNode: + RenderElement(builder, "p", "sc-ai-rich-text__paragraph", node.Children); + break; + case HeadingNode heading: + RenderElement( + builder, + $"h{Math.Clamp(heading.Level, 1, 6)}", + "sc-ai-rich-text__heading", + node.Children); + break; + case EmphasisNode: + RenderElement(builder, "em", null, node.Children); + break; + case StrongNode: + RenderElement(builder, "strong", null, node.Children); + break; + case StrikethroughNode: + RenderElement(builder, "s", null, node.Children); + break; + case InlineCodeNode inlineCode: + builder.OpenElement(0, "code"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__inline-code"); + builder.AddContent(2, inlineCode.Code); + builder.CloseElement(); + break; + case CodeBlockNode codeBlock: + builder.OpenElement(0, "pre"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__code-block"); + builder.OpenElement(2, "code"); + if (!string.IsNullOrEmpty(codeBlock.Language)) + { + builder.AddAttribute(3, "data-language", codeBlock.Language); + } + builder.AddContent(4, codeBlock.Code); + builder.CloseElement(); + builder.CloseElement(); + break; + case BlockQuoteNode: + RenderElement(builder, "blockquote", "sc-ai-rich-text__quote", node.Children); + break; + case LineBreakNode: + builder.OpenElement(0, "br"); + builder.CloseElement(); + break; + case ThematicBreakNode: + builder.OpenElement(0, "hr"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__thematic-break"); + builder.CloseElement(); + break; + case ListNode list: + builder.OpenElement(0, list.Ordered ? "ol" : "ul"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__list"); + if (list.Ordered && list.Start is not null) + { + builder.AddAttribute(2, "start", list.Start.Value); + } + RenderRichTextNodes(builder, list.Children); + builder.CloseElement(); + break; + case ListItemNode item: + builder.OpenElement(0, "li"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__list-item"); + if (item.Checked is not null) + { + builder.OpenElement(2, "input"); + builder.AddAttribute(3, "type", "checkbox"); + builder.AddAttribute(4, "disabled", true); + if (item.Checked.Value) + { + builder.AddAttribute(5, "checked", true); + } + builder.CloseElement(); + } + RenderRichTextNodes(builder, item.Children); + builder.CloseElement(); + break; + case LinkNode link: + RenderLink(builder, link); + break; + case ImageNode image: + RenderImage(builder, image); + break; + case DefinitionNode definition: + builder.OpenElement(0, "span"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__definition"); + builder.AddContent(2, $"[{definition.Label}]: {definition.Url}"); + builder.CloseElement(); + break; + case LinkReferenceNode linkReference: + RenderReference(builder, linkReference.Label, linkReference.Children); + break; + case ImageReferenceNode imageReference: + builder.OpenElement(0, "span"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__image-reference"); + builder.AddContent(2, imageReference.Alt ?? imageReference.Label); + builder.CloseElement(); + break; + case FootnoteNode: + RenderElement(builder, "aside", "sc-ai-rich-text__footnote", node.Children); + break; + case FootnoteReferenceNode footnoteReference: + builder.OpenElement(0, "sup"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__footnote-reference"); + builder.AddContent(2, footnoteReference.Label); + builder.CloseElement(); + break; + case FootnoteDefinitionNode footnoteDefinition: + builder.OpenElement(0, "aside"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__footnote-definition"); + builder.AddAttribute(2, "data-label", footnoteDefinition.Label); + RenderRichTextNodes(builder, footnoteDefinition.Children); + builder.CloseElement(); + break; + case HtmlNode html: + builder.OpenElement(0, "code"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__html"); + builder.AddContent(2, html.Value); + builder.CloseElement(); + break; + case TableNode table: + RenderTable(builder, table); + break; + case TableRowNode: + case TableCellNode: + RenderRichTextNodes(builder, node.Children); + break; + default: + RenderRichTextNodes(builder, node.Children); + break; + } + } + + private static void RenderElement( + RenderTreeBuilder builder, + string elementName, + string? className, + IReadOnlyList children) + { + builder.OpenElement(0, elementName); + if (className is not null) + { + builder.AddAttribute(1, "class", className); + } + RenderRichTextNodes(builder, children); + builder.CloseElement(); + } + + private static void RenderLink(RenderTreeBuilder builder, LinkNode link) + { + var safeUrl = GetSafeUrl(link.Url, allowMailTo: true); + if (safeUrl is null) + { + RenderRichTextNodes(builder, link.Children); + return; + } + + builder.OpenElement(0, "a"); + builder.AddAttribute(1, "href", safeUrl); + if (link.Title is not null) + { + builder.AddAttribute(2, "title", link.Title); + } + RenderRichTextNodes(builder, link.Children); + builder.CloseElement(); + } + + private static void RenderImage(RenderTreeBuilder builder, ImageNode image) + { + var safeUrl = GetSafeUrl(image.Url, allowMailTo: false); + if (safeUrl is null) + { + builder.AddContent(0, image.Alt); + return; + } + + builder.OpenElement(0, "img"); + builder.AddAttribute(1, "src", safeUrl); + builder.AddAttribute(2, "alt", image.Alt ?? string.Empty); + if (image.Title is not null) + { + builder.AddAttribute(3, "title", image.Title); + } + builder.CloseElement(); + } + + private static void RenderReference( + RenderTreeBuilder builder, + string label, + IReadOnlyList children) + { + builder.OpenElement(0, "span"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__link-reference"); + if (children.Count > 0) + { + RenderRichTextNodes(builder, children); + } + else + { + builder.AddContent(2, label); + } + builder.CloseElement(); + } + + private static void RenderTable(RenderTreeBuilder builder, TableNode table) + { + builder.OpenElement(0, "div"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__table-container"); + builder.OpenElement(2, "table"); + builder.AddAttribute(3, "class", "sc-ai-rich-text__table"); + builder.OpenElement(4, "tbody"); + + foreach (var child in table.Children) + { + if (child is not TableRowNode row) + { + continue; + } + + builder.OpenRegion(5); + builder.OpenElement(0, "tr"); + var columnIndex = 0; + foreach (var rowChild in row.Children) + { + if (rowChild is not TableCellNode cell) + { + continue; + } + + builder.OpenRegion(1); + builder.OpenElement(0, "td"); + if (columnIndex < table.Alignment.Count && + table.Alignment[columnIndex] != TableColumnAlignment.None) + { + builder.AddAttribute( + 1, + "class", + $"sc-ai-rich-text__table-cell--{table.Alignment[columnIndex].ToString().ToLowerInvariant()}"); + } + RenderRichTextNodes(builder, cell.Children); + builder.CloseElement(); + builder.CloseRegion(); + columnIndex++; + } + builder.CloseElement(); + builder.CloseRegion(); + } + + builder.CloseElement(); + builder.CloseElement(); + builder.CloseElement(); + } + + private static string? GetSafeUrl(string url, bool allowMailTo) + { + if (!Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out var uri)) + { + return null; + } + + if (!uri.IsAbsoluteUri) + { + return url; + } + + if (uri.Scheme is "http" or "https" || + (allowMailTo && uri.Scheme == "mailto")) + { + return url; + } + + return null; + } + + private static void RenderApprovalBlock( + RenderTreeBuilder builder, + FunctionApprovalBlock block) + { + builder.OpenElement(0, "div"); + builder.AddAttribute(1, "class", "sc-ai-approval"); + + builder.OpenElement(2, "div"); + builder.AddAttribute(3, "class", "sc-ai-approval__header"); + builder.AddContent(4, "Approval required"); + builder.CloseElement(); + + builder.OpenElement(5, "div"); + builder.AddAttribute(6, "class", "sc-ai-approval__tool-name"); + builder.AddContent(7, block.ToolName ?? "Unknown tool"); + builder.CloseElement(); + + if (block.Arguments is { Count: > 0 }) + { + builder.OpenElement(8, "pre"); + builder.AddAttribute(9, "class", "sc-ai-approval__arguments"); + builder.AddContent(10, JsonSerializer.Serialize(block.Arguments, IndentedJsonOptions)); + builder.CloseElement(); + } + + if (block.Status == ApprovalStatus.Pending) + { + builder.OpenElement(11, "div"); + builder.AddAttribute(12, "class", "sc-ai-approval__actions"); + + builder.OpenElement(13, "button"); + builder.AddAttribute(14, "type", "button"); + builder.AddAttribute(15, "class", "sc-ai-btn sc-ai-btn--primary"); + builder.AddAttribute(16, "onclick", (Action)block.Approve); + builder.AddContent(17, "Approve"); + builder.CloseElement(); + + builder.OpenElement(18, "button"); + builder.AddAttribute(19, "type", "button"); + builder.AddAttribute(20, "class", "sc-ai-btn sc-ai-btn--secondary"); + builder.AddAttribute(21, "onclick", (Action)(() => block.Reject())); + builder.AddContent(22, "Reject"); + builder.CloseElement(); + + builder.CloseElement(); + } + else + { + var approved = block.Status == ApprovalStatus.Approved; + builder.OpenElement(23, "div"); + builder.AddAttribute( + 24, + "class", + approved + ? "sc-ai-approval__status sc-ai-approval__status--approved" + : "sc-ai-approval__status sc-ai-approval__status--rejected"); + builder.AddContent(25, approved ? "Approved" : "Rejected"); + builder.CloseElement(); + } + + builder.CloseElement(); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentContext.cs new file mode 100644 index 000000000000..9f3541fd498f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentContext.cs @@ -0,0 +1,389 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Linq; +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Owns the state of a conversation: the turns rendered by the UI, the current +/// , and the notifications the components subscribe to. +/// +/// +/// +/// var context = new AgentContext(agent); +/// using var subscription = context.RegisterOnStatusChanged(status => Console.WriteLine(status)); +/// await context.SendMessageAsync("Hello"); +/// +/// +public class AgentContext : IDisposable +{ + private readonly UIAgent _agent; + private readonly List _turns = new(); + private readonly List> _turnAddedCallbacks = new(); + private readonly List> _statusChangedCallbacks = new(); + private readonly List> _blockAddedCallbacks = new(); + private CancellationTokenSource? _streamingCts; + private ChatMessage? _lastMessage; + private bool _disposed; + + /// + /// Initializes a new instance of the class. + /// + /// The agent that produces the responses for this conversation. + public AgentContext(UIAgent agent) + { + ArgumentNullException.ThrowIfNull(agent); + _agent = agent; + } + + /// + /// Gets the turns of this conversation, oldest first. + /// + public IReadOnlyList Turns => _turns; + + /// + /// Gets the current status of the conversation. + /// + public ConversationStatus Status { get; private set; } + + /// + /// Gets the exception that failed the last turn, when is + /// . + /// + public Exception? Error { get; private set; } + + /// + /// Sends a text message and streams the response into a new turn. + /// + /// The message text. + /// A token that cancels the response. + /// A task that completes when the turn finishes. + public Task SendMessageAsync(string text, CancellationToken cancellationToken = default) + { + return SendMessageAsync(new ChatMessage(ChatRole.User, text), cancellationToken); + } + + /// + /// Sends a message and streams the response into a new turn. + /// + /// The message to send. + /// A token that cancels the response. + /// A task that completes when the turn finishes. + public async Task SendMessageAsync(ChatMessage message, CancellationToken cancellationToken = default) + { + ArgumentNullException.ThrowIfNull(message); + + if (Status is ConversationStatus.Streaming or ConversationStatus.AwaitingInput) + { + throw new InvalidOperationException("A message is already being processed."); + } + + _lastMessage = message; + + var turn = new ConversationTurn(); + _turns.Add(turn); + NotifyTurnAdded(turn); + + _streamingCts?.Dispose(); + _streamingCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + + await StreamIntoTurnAsync(message, turn, _streamingCts.Token, cancellationToken); + } + + /// + /// Restores the committed turns from the agent's configured conversation thread. + /// + /// A token that cancels restoration. + /// A task that completes when the turns have been restored. + public async Task RestoreAsync(CancellationToken cancellationToken = default) + { + if (Status == ConversationStatus.Streaming) + { + throw new InvalidOperationException("A message is already being processed."); + } + + var blocks = await _agent.RestoreAsync(cancellationToken); + _turns.Clear(); + + ConversationTurn? currentTurn = null; + foreach (var block in blocks) + { + if (block.Role == ChatRole.User) + { + currentTurn = new ConversationTurn(); + _turns.Add(currentTurn); + currentTurn.AddRequestBlock(block); + } + else + { + if (currentTurn is null) + { + currentTurn = new ConversationTurn(); + _turns.Add(currentTurn); + } + + currentTurn.AddResponseBlock(block); + } + } + } + + /// + /// Replays the last message after a failed turn. + /// + /// A token that cancels the response. + /// A task that completes when the turn finishes. + public async Task RetryAsync(CancellationToken cancellationToken = default) + { + if (Status != ConversationStatus.Error) + { + throw new InvalidOperationException( + $"RetryAsync requires Status == Error, but Status is {Status}."); + } + + var turn = _turns[^1]; + turn.ClearResponseBlocks(); + + _streamingCts?.Dispose(); + _streamingCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + + await StreamIntoTurnAsync(_lastMessage!, turn, _streamingCts.Token, cancellationToken); + } + + /// + /// Stops the response that is currently streaming, if any. + /// + /// A task that completes once cancellation has been requested. + public Task CancelAsync() + { + if (Status is ConversationStatus.Idle or ConversationStatus.Error) + { + return Task.CompletedTask; + } + + _streamingCts?.Cancel(); + return Task.CompletedTask; + } + + /// + /// Registers a callback invoked when a turn is added to the conversation. + /// + /// The callback to invoke. + /// A registration that removes the callback when disposed. + public IDisposable RegisterOnTurnAdded(Action callback) + { + ArgumentNullException.ThrowIfNull(callback); + _turnAddedCallbacks.Add(callback); + return new CallbackRegistration>(_turnAddedCallbacks, callback); + } + + /// + /// Registers a callback invoked when changes. + /// + /// The callback to invoke. + /// A registration that removes the callback when disposed. + public IDisposable RegisterOnStatusChanged(Action callback) + { + ArgumentNullException.ThrowIfNull(callback); + _statusChangedCallbacks.Add(callback); + return new CallbackRegistration>(_statusChangedCallbacks, callback); + } + + /// + /// Registers a callback invoked when a block is added to a turn. + /// + /// The callback to invoke. + /// A registration that removes the callback when disposed. + public IDisposable RegisterOnBlockAdded(Action callback) + { + ArgumentNullException.ThrowIfNull(callback); + _blockAddedCallbacks.Add(callback); + return new CallbackRegistration>(_blockAddedCallbacks, callback); + } + + /// + /// Releases the resources used by this context and stops any streaming response. + /// + public void Dispose() + { + if (_disposed) + { + return; + } + + _disposed = true; + _streamingCts?.Cancel(); + _streamingCts?.Dispose(); + _agent.RejectPendingPredictiveState(); + _turnAddedCallbacks.Clear(); + _statusChangedCallbacks.Clear(); + _blockAddedCallbacks.Clear(); + GC.SuppressFinalize(this); + } + + private async Task StreamIntoTurnAsync( + ChatMessage message, + ConversationTurn turn, + CancellationToken cancellationToken, + CancellationToken callerToken) + { + Status = ConversationStatus.Streaming; + Error = null; + NotifyStatusChanged(); + + try + { + IReadOnlyList? currentMessages = [message]; + while (currentMessages is not null) + { + var interactiveBlocks = new List(); + + await foreach (var block in _agent.SendMessagesAsync(currentMessages, cancellationToken) + .WithCancellation(cancellationToken)) + { + if (block.Role == message.Role) + { + turn.AddRequestBlock(block); + } + else + { + turn.AddResponseBlock(block); + } + + if (block is IInteractiveBlock interactiveBlock) + { + interactiveBlocks.Add(interactiveBlock); + } + + NotifyBlockAdded(turn, block); + } + + if (interactiveBlocks.Count == 0) + { + currentMessages = null; + continue; + } + + Status = ConversationStatus.AwaitingInput; + NotifyStatusChanged(); + + var results = await Task.WhenAll( + interactiveBlocks.Select(block => block.GetResultAsync(cancellationToken))); + + currentMessages = CreateContinuationMessages(results); + Status = ConversationStatus.Streaming; + NotifyStatusChanged(); + } + + _agent.RejectPendingPredictiveState(); + Status = ConversationStatus.Idle; + if (cancellationToken.IsCancellationRequested) + { + turn.ClearResponseBlocks(); + } + NotifyStatusChanged(); + } + catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) + { + turn.ClearResponseBlocks(); + _agent.RejectPendingPredictiveState(); + Status = ConversationStatus.Idle; + NotifyStatusChanged(); + } + catch (Exception ex) + { + // A failing turn is surfaced as conversation state (Status/Error) rather than a + // faulted Task: the UI renders the error and RetryAsync replays the last message. + // This is the engine's error contract, not a swallowed exception. + _agent.RejectPendingPredictiveState(); + Error = ex; + Status = ConversationStatus.Error; + try + { + _agent.LogProcessingError(ex); + } + catch (Exception) + { + // A logging provider failure must not fault the operation after the processing + // failure has been surfaced through the conversation state. + } + NotifyStatusChanged(); + return; + } + + // If the caller's own token requested cancellation, surface it so the returned Task + // completes as canceled. Cancellation driven by CancelAsync() (the internal token only) + // is a graceful stop and completes normally. + callerToken.ThrowIfCancellationRequested(); + } + + private static IReadOnlyList CreateContinuationMessages( + IReadOnlyList results) + { + var messages = new List(); + foreach (var result in results) + { + var role = result is FunctionResultContent ? ChatRole.Tool : ChatRole.User; + if (messages.Count > 0 && messages[^1].Role == role) + { + messages[^1].Contents.Add(result); + } + else + { + messages.Add(new ChatMessage(role, [result])); + } + } + + return messages; + } + + private void NotifyStatusChanged() + { + var snapshot = _statusChangedCallbacks.ToArray(); + foreach (var callback in snapshot) + { + callback(Status); + } + } + + private void NotifyTurnAdded(ConversationTurn turn) + { + var snapshot = _turnAddedCallbacks.ToArray(); + foreach (var callback in snapshot) + { + callback(turn); + } + } + + private void NotifyBlockAdded(ConversationTurn turn, ContentBlock block) + { + var snapshot = _blockAddedCallbacks.ToArray(); + foreach (var callback in snapshot) + { + callback(turn, block); + } + } + + private sealed class CallbackRegistration : IDisposable + { + private List? _list; + private T? _callback; + + internal CallbackRegistration(List list, T callback) + { + _list = list; + _callback = callback; + } + + public void Dispose() + { + if (_list is not null && _callback is not null) + { + _list.Remove(_callback); + _list = null; + _callback = default; + } + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentState.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentState.cs new file mode 100644 index 000000000000..294bd42fbe1f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentState.cs @@ -0,0 +1,120 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Holds observable state associated with a . +/// +/// The type of state. +public class AgentState where T : class, new() +{ + private readonly List _callbacks = new(); + private T _value; + private T? _valueBeforePrediction; + + internal AgentState(T? initialValue = null) + { + _value = initialValue ?? new T(); + } + + /// + /// Gets or sets the current state value. + /// + public T Value + { + get => _value; + set + { + ArgumentNullException.ThrowIfNull(value); + _valueBeforePrediction = null; + _value = value; + NotifyChanged(); + } + } + + /// + /// Gets a value indicating whether contains provisional predictive state. + /// + public bool HasPendingPredictiveState => _valueBeforePrediction is not null; + + /// + /// Accepts the current predictive state as the committed value. + /// + public void AcceptPredictiveState() + { + if (_valueBeforePrediction is null) + { + return; + } + + _valueBeforePrediction = null; + NotifyChanged(); + } + + /// + /// Rejects the current predictive state and restores the value from before the prediction. + /// + public void RejectPredictiveState() + { + if (_valueBeforePrediction is not { } previousValue) + { + return; + } + + _valueBeforePrediction = null; + _value = previousValue; + NotifyChanged(); + } + + /// + /// Registers a callback invoked when changes. + /// + /// The callback to invoke. + /// A registration that removes the callback when disposed. + public IDisposable OnChanged(Action callback) + { + ArgumentNullException.ThrowIfNull(callback); + _callbacks.Add(callback); + return new CallbackRegistration(_callbacks, callback); + } + + internal void SetPredictiveValue(T value) + { + ArgumentNullException.ThrowIfNull(value); + _valueBeforePrediction ??= _value; + _value = value; + NotifyChanged(); + } + + private void NotifyChanged() + { + var snapshot = _callbacks.ToArray(); + foreach (var callback in snapshot) + { + callback(); + } + } + + private sealed class CallbackRegistration : IDisposable + { + private List? _callbacks; + private Action? _callback; + + internal CallbackRegistration(List callbacks, Action callback) + { + _callbacks = callbacks; + _callback = callback; + } + + public void Dispose() + { + if (_callbacks is not null && _callback is not null) + { + _callbacks.Remove(_callback); + _callbacks = null; + _callback = null; + } + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/ConversationStatus.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/ConversationStatus.cs new file mode 100644 index 000000000000..01cf29c7a29a --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/ConversationStatus.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// The state of a conversation driven by an . +/// +public enum ConversationStatus +{ + /// + /// No response is in flight; the user can send a message. + /// + Idle, + + /// + /// A model response is streaming. + /// + Streaming, + + /// + /// The conversation is waiting for the user to interact with the current response. + /// + AwaitingInput, + + /// + /// The last turn failed. holds the exception and + /// replays the turn. + /// + Error +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/ConversationTurn.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/ConversationTurn.cs new file mode 100644 index 000000000000..736383376c53 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/ConversationTurn.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// A single exchange in a conversation: the blocks produced by the user's message and the +/// blocks produced by the response to it. +/// +public class ConversationTurn +{ + private readonly List _requestBlocks = new(); + private readonly List _responseBlocks = new(); + + /// + /// Gets the identifier of this turn. + /// + public string Id { get; internal set; } = string.Empty; + + /// + /// Gets the blocks produced by the message that started this turn. + /// + public IReadOnlyList RequestBlocks => _requestBlocks; + + /// + /// Gets the blocks produced by the response to this turn. + /// + public IReadOnlyList ResponseBlocks => _responseBlocks; + + internal void AddRequestBlock(ContentBlock block) + { + _requestBlocks.Add(block); + } + + internal void AddResponseBlock(ContentBlock block) + { + _responseBlocks.Add(block); + } + + internal void ClearResponseBlocks() + { + _responseBlocks.Clear(); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/IConversationThread.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/IConversationThread.cs new file mode 100644 index 000000000000..87756edd7d84 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/IConversationThread.cs @@ -0,0 +1,53 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a persistent conversation thread that stores streamed chat updates. +/// +/// +/// Implementations control where and how conversation updates are persisted. +/// +public interface IConversationThread +{ + /// + /// Gets the unique identifier for this thread. + /// + string ThreadId { get; } + + /// + /// Gets a value indicating whether the remote service manages the conversation history. + /// + bool IsStateful { get; } + + /// + /// Gets the conversation identifier returned by a stateful remote service, if any. + /// + string? ConversationId { get; } + + /// + /// Begins a turn by appending the message sent to the chat client. + /// + /// The message that begins the turn. + void AppendUserMessage(ChatMessage message); + + /// + /// Appends an update received from the chat client to the current turn. + /// + /// The streamed update. + void AppendUpdate(ChatResponseUpdate update); + + /// + /// Commits the current turn to the stored history. + /// + void CompleteTurn(); + + /// + /// Gets all committed updates in chronological order. + /// + /// The committed updates. + IReadOnlyList GetUpdates(); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgent.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgent.cs new file mode 100644 index 000000000000..a2d04b63f601 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgent.cs @@ -0,0 +1,362 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Linq; +using System.Runtime.CompilerServices; +using Microsoft.Extensions.AI; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Turns an stream into content blocks the UI can render as they +/// arrive, and keeps the conversation history for subsequent turns. +/// +/// +/// A is protocol- and provider-neutral: it only depends on +/// , so any Microsoft.Extensions.AI client can drive it. +/// +/// +/// +/// var agent = new UIAgent(chatClient); +/// await foreach (var block in agent.SendMessageAsync(new ChatMessage(ChatRole.User, "Hello"))) +/// { +/// Console.WriteLine(block.Id); +/// } +/// +/// +public class UIAgent : IDisposable +{ + private readonly IChatClient _chatClient; + private readonly UIAgentOptions _options; + private readonly ILogger _logger; + private readonly List _history = new(); + private bool _disposed; + + internal UIAgentOptions Options => _options; + + internal virtual void RejectPendingPredictiveState() + { + } + + internal void LogProcessingError(Exception exception) + { + UIAgentLog.ProcessingError(_logger, exception); + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + public UIAgent(IChatClient chatClient) + : this(chatClient, configure: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// The options passed to the chat client. + public UIAgent(IChatClient chatClient, ChatOptions chatOptions) + : this(chatClient, options => options.ChatOptions = chatOptions) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// The options passed to the chat client. + /// The logger factory used to trace block mapping. + public UIAgent(IChatClient chatClient, ChatOptions chatOptions, ILoggerFactory? loggerFactory) + : this(chatClient, options => options.ChatOptions = chatOptions, loggerFactory) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// A callback that configures the agent. + public UIAgent(IChatClient chatClient, Action? configure) + : this(chatClient, configure, loggerFactory: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// A callback that configures the agent. + /// The logger factory used to trace block mapping. + public UIAgent(IChatClient chatClient, Action? configure, ILoggerFactory? loggerFactory) + { + ArgumentNullException.ThrowIfNull(chatClient); + _chatClient = chatClient; + _options = new UIAgentOptions(); + configure?.Invoke(_options); + _logger = (ILogger?)loggerFactory?.CreateLogger() ?? NullLogger.Instance; + } + + internal UIAgent(IChatClient chatClient, UIAgentOptions options, ILoggerFactory? loggerFactory) + { + ArgumentNullException.ThrowIfNull(chatClient); + _chatClient = chatClient; + _options = options; + _logger = (ILogger?)loggerFactory?.CreateLogger() ?? NullLogger.Instance; + } + + /// + /// Sends a message and streams the resulting content blocks. Blocks are yielded as soon as + /// they are created; a block keeps changing (raising ) + /// until it becomes . + /// + /// The message to send. + /// A token that cancels the response. + /// The blocks produced by the message and by the model response to it. + public async IAsyncEnumerable SendMessageAsync( + ChatMessage message, + [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + ArgumentNullException.ThrowIfNull(message); + + await foreach (var block in SendMessagesAsync([message], cancellationToken).ConfigureAwait(false)) + { + yield return block; + } + } + + internal async IAsyncEnumerable SendMessagesAsync( + IReadOnlyList messages, + [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + ObjectDisposedException.ThrowIf(_disposed, this); + + var thread = _options.Thread; + foreach (var message in messages) + { + ArgumentNullException.ThrowIfNull(message); + _history.Add(message); + } + + var pipeline = new BlockMappingPipeline(_options, _logger); + + // Process user messages through pipeline + foreach (var message in messages) + { + var userUpdate = new ChatResponseUpdate + { + Role = message.Role, + Contents = [.. message.Contents] + }; + await foreach (var block in pipeline.Process(userUpdate, cancellationToken).ConfigureAwait(false)) + { + yield return block; + } + } + + foreach (var block in pipeline.Finalize()) + { + yield return block; + } + + // Stream assistant response + UIAgentLog.StreamingAssistantResponse(_logger); + var responseUpdates = new List(); + var assistantUpdates = new List(); + var updateIndex = 0; + var chatOptions = BuildChatOptions(); + IEnumerable requestMessages = _history; + if (thread is { IsStateful: true, ConversationId: not null }) + { + chatOptions = chatOptions?.Clone() ?? new ChatOptions(); + chatOptions.ConversationId = thread.ConversationId; + requestMessages = messages; + } + + await foreach (var update in _chatClient.GetStreamingResponseAsync( + requestMessages, chatOptions, cancellationToken).ConfigureAwait(false)) + { + var contentTypes = string.Join(", ", update.Contents.Select(c => c.GetType().Name)); + UIAgentLog.ReceivedUpdate(_logger, updateIndex++, update.Role?.Value, contentTypes); + + responseUpdates.Add(update); + var processUpdate = ApplyStateMapper(update); + assistantUpdates.Add(processUpdate); + + if (processUpdate.Contents.Count == 0 && update.Contents.Count > 0) + { + continue; + } + + await foreach (var block in pipeline.Process(processUpdate, cancellationToken).ConfigureAwait(false)) + { + yield return block; + } + } + + UIAgentLog.StreamComplete(_logger, assistantUpdates.Count); + + foreach (var block in pipeline.Finalize()) + { + yield return block; + } + + // Add assistant response to history + var response = assistantUpdates.ToChatResponse(); + foreach (var msg in response.Messages) + { + _history.Add(msg); + } + + if (thread is not null && messages.Count > 0) + { + thread.AppendUserMessage(messages[0]); + foreach (var message in messages.Skip(1)) + { + thread.AppendUpdate(new ChatResponseUpdate + { + Role = message.Role, + Contents = [.. message.Contents], + }); + } + + foreach (var update in responseUpdates) + { + thread.AppendUpdate(update); + } + + thread.CompleteTurn(); + } + + UIAgentLog.AddedToHistory(_logger, response.Messages.Count); + } + + /// + /// Restores the committed conversation and typed state from the configured thread. + /// + /// A token that cancels restoration. + /// The restored content blocks in chronological order. + public async Task> RestoreAsync( + CancellationToken cancellationToken = default) + { + ObjectDisposedException.ThrowIf(_disposed, this); + + var updates = _options.Thread?.GetUpdates(); + if (updates is not { Count: > 0 }) + { + return []; + } + + _history.Clear(); + + var blocks = new List(); + var pipeline = new BlockMappingPipeline(_options, _logger); + var assistantUpdates = new List(); + + foreach (var update in updates) + { + cancellationToken.ThrowIfCancellationRequested(); + + if (update.Role == ChatRole.User) + { + if (assistantUpdates.Count > 0) + { + AddResponseToHistory(assistantUpdates); + assistantUpdates.Clear(); + + blocks.AddRange(pipeline.Finalize()); + pipeline = new BlockMappingPipeline(_options, _logger); + } + + _history.Add(new ChatMessage(update.Role.Value, [.. update.Contents])); + await foreach (var block in pipeline.Process(update, cancellationToken).ConfigureAwait(false)) + { + blocks.Add(block); + } + + blocks.AddRange(pipeline.Finalize()); + pipeline = new BlockMappingPipeline(_options, _logger); + } + else + { + assistantUpdates.Add(update); + + var processUpdate = ApplyStateMapper(update); + if (processUpdate.Contents.Count == 0 && update.Contents.Count > 0) + { + continue; + } + + await foreach (var block in pipeline.Process(processUpdate, cancellationToken).ConfigureAwait(false)) + { + blocks.Add(block); + } + } + } + + if (assistantUpdates.Count > 0) + { + AddResponseToHistory(assistantUpdates); + } + + blocks.AddRange(pipeline.Finalize()); + RejectPendingPredictiveState(); + + return blocks; + } + + internal virtual ChatResponseUpdate ApplyStateMapper(ChatResponseUpdate update) + { + if (_options.StateMapper is null) + { + return update; + } + + var context = new StateMapperContext(update); + _options.StateMapper(context); + + return context.HasHandledContent ? context.GetFilteredUpdate() : update; + } + + private void AddResponseToHistory(List updates) + { + var response = updates.ToChatResponse(); + foreach (var message in response.Messages) + { + _history.Add(message); + } + } + + private ChatOptions? BuildChatOptions() + { + if (_options.UIActions.Count == 0) + { + return _options.ChatOptions; + } + + var chatOptions = _options.ChatOptions?.Clone() ?? new ChatOptions(); + var tools = chatOptions.Tools is null + ? new List() + : [.. chatOptions.Tools]; + + foreach (var action in _options.UIActions.Values) + { + tools.Add(action.AsDeclarationOnly()); + } + + chatOptions.Tools = tools; + return chatOptions; + } + + /// + /// Releases the resources used by this agent. + /// + public void Dispose() + { + _disposed = true; + GC.SuppressFinalize(this); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentLog.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentLog.cs new file mode 100644 index 000000000000..ee08e0abedb3 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentLog.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.Components.AI; + +internal static partial class UIAgentLog +{ + [LoggerMessage(100, LogLevel.Information, "SendMessageAsync: Streaming assistant response")] + internal static partial void StreamingAssistantResponse(ILogger logger); + + [LoggerMessage(101, LogLevel.Debug, "SendMessageAsync: Received update #{Index} Role={Role}, ContentTypes=[{ContentTypes}]")] + internal static partial void ReceivedUpdate(ILogger logger, int index, string? role, string contentTypes); + + [LoggerMessage(102, LogLevel.Information, "SendMessageAsync: Stream complete. Total updates={UpdateCount}")] + internal static partial void StreamComplete(ILogger logger, int updateCount); + + [LoggerMessage(103, LogLevel.Debug, "SendMessageAsync: Added {MessageCount} messages to history")] + internal static partial void AddedToHistory(ILogger logger, int messageCount); + + [LoggerMessage(104, LogLevel.Error, "SendMessageAsync: An error occurred while processing the response")] + internal static partial void ProcessingError(ILogger logger, Exception exception); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentOfT.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentOfT.cs new file mode 100644 index 000000000000..5f10a5b1548a --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentOfT.cs @@ -0,0 +1,122 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Turns an stream into renderable content blocks and typed observable state. +/// +/// The type of state associated with the agent. +public class UIAgent : UIAgent where TState : class, new() +{ + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// The initial state value. + public UIAgent(IChatClient chatClient, TState? initialState = null) + : this(chatClient, new UIAgentOptions(initialState), configure: null, loggerFactory: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// The options passed to the chat client. + /// The initial state value. + public UIAgent(IChatClient chatClient, ChatOptions chatOptions, TState? initialState = null) + : this( + chatClient, + new UIAgentOptions(initialState), + options => options.ChatOptions = chatOptions, + loggerFactory: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// A callback that configures the agent. + /// The initial state value. + public UIAgent( + IChatClient chatClient, + Action> configure, + TState? initialState = null) + : this(chatClient, new UIAgentOptions(initialState), configure, loggerFactory: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// A callback that configures the agent. + /// The logger factory used to trace block mapping. + /// The initial state value. + public UIAgent( + IChatClient chatClient, + Action> configure, + ILoggerFactory? loggerFactory, + TState? initialState = null) + : this(chatClient, new UIAgentOptions(initialState), configure, loggerFactory) + { + } + + private UIAgent( + IChatClient chatClient, + UIAgentOptions options, + Action>? configure, + ILoggerFactory? loggerFactory) + : base(chatClient, options, loggerFactory) + { + State = options.State; + configure?.Invoke(options); + } + + /// + /// Gets the observable state associated with this agent. + /// + public AgentState State { get; } + + internal override ChatResponseUpdate ApplyStateMapper(ChatResponseUpdate update) + { + if (Options.StateMapper is null) + { + return update; + } + + var context = new StateMapperContext(update); + Options.StateMapper(context); + + if (context.StateValue is not null) + { + if (context.StateValue is not TState typedState) + { + throw new InvalidOperationException( + $"The state mapper returned a value of type '{context.StateValue.GetType()}', " + + $"but this agent requires state of type '{typeof(TState)}'."); + } + + if (context.IsPredictiveState) + { + State.SetPredictiveValue(typedState); + } + else + { + State.Value = typedState; + } + } + + return context.HasHandledContent ? context.GetFilteredUpdate() : update; + } + + internal override void RejectPendingPredictiveState() + { + State.RejectPredictiveState(); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj new file mode 100644 index 000000000000..06236046177b --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj @@ -0,0 +1,45 @@ + + + + $(DefaultNetCoreTargetFramework) + 0.1.0 + + $(AspNetCoreMajorMinorVersion).0.0 + enable + enable + true + true + true + Blazor component library for building AI conversational UIs on top of Microsoft.Extensions.AI. + blazor;ai;chat;components + + $(NoWarn);RS0026 + true + preview + 1 + + + + + + + + + + + + + + + + + + + + + diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ActivityHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ActivityHandler.cs new file mode 100644 index 000000000000..dd9488839c26 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ActivityHandler.cs @@ -0,0 +1,72 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Maps activity snapshots and updates into a mutable content block. +/// +/// The activity block type. +public abstract class ActivityHandler : ContentBlockHandler + where TBlock : ActivityContentBlock, new() +{ + /// + public sealed override BlockMappingResult Handle( + BlockMappingContext context, + TBlock state) + { + if (state.Id == string.Empty) + { + if (TryCreateBlock(context, state)) + { + if (state.Id.Length == 0) + { + state.Id = context.Update.MessageId ?? Guid.NewGuid().ToString("N"); + } + + OnContentUpdated(state); + return BlockMappingResult.Emit(state, state); + } + + return BlockMappingResult.Pass(); + } + + if (TryUpdateBlock(context, state, out var isCompleted)) + { + OnContentUpdated(state); + return isCompleted + ? BlockMappingResult.Complete() + : BlockMappingResult.Update(state); + } + + return BlockMappingResult.Pass(); + } + + /// + /// Attempts to initialize a block from an activity snapshot. + /// + /// The update being mapped. + /// The block to initialize. + /// when the update created the block. + protected abstract bool TryCreateBlock(BlockMappingContext context, TBlock state); + + /// + /// Attempts to update an existing activity block. + /// + /// The update being mapped. + /// The block to update. + /// Whether the update completes the activity. + /// when the update belongs to the block. + protected abstract bool TryUpdateBlock( + BlockMappingContext context, + TBlock state, + out bool isCompleted); + + /// + /// Updates derived block state after the activity payload changes. + /// + /// The updated activity block. + protected virtual void OnContentUpdated(TBlock state) + { + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingContext.cs new file mode 100644 index 000000000000..c2262e228e97 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingContext.cs @@ -0,0 +1,171 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Carries a single model update through the block mapping pipeline and tracks which +/// parts of the update handlers have already claimed. +/// +public class BlockMappingContext +{ + private readonly bool[] _handled; + private readonly IReadOnlyList? _handlers; + private int _handledCount; + private bool _updateHandled; + + internal BlockMappingContext( + ChatResponseUpdate update, + IReadOnlyList? handlers = null) + { + Update = update; + _handled = new bool[update.Contents.Count]; + _handlers = handlers; + } + + /// + /// Gets the update being mapped. + /// + public ChatResponseUpdate Update { get; } + + /// + /// Gets the contents of that no handler has claimed yet. + /// + public UnhandledContentsEnumerable UnhandledContents => new(Update.Contents, _handled); + + /// + /// Marks a content item as claimed so that later handlers do not see it. + /// + /// The content item that was handled. + public void MarkHandled(AIContent content) + { + var contents = Update.Contents; + for (var i = 0; i < contents.Count; i++) + { + if (ReferenceEquals(contents[i], content)) + { + if (!_handled[i]) + { + _handled[i] = true; + _handledCount++; + } + return; + } + } + } + + /// + /// Marks the update itself as handled. Use this for updates that carry no content items. + /// + public void MarkUpdateHandled() + { + _updateHandled = true; + } + + /// + /// Gets a value indicating whether every part of the update has been claimed. + /// + public bool AllHandled => + _handledCount >= Update.Contents.Count && (Update.Contents.Count > 0 || _updateHandled); + + internal int HandledProgress => _handledCount + (_updateHandled ? 1 : 0); + + /// + /// Maps content through the available handlers to create a nested block. + /// + /// The content to map. + /// The mapped block, or when no handler accepts the content. + public ContentBlock? CreateInnerBlock(AIContent content) + { + ArgumentNullException.ThrowIfNull(content); + + if (_handlers is null) + { + return null; + } + + var update = new ChatResponseUpdate + { + Role = Update.Role, + AuthorName = Update.AuthorName, + MessageId = Update.MessageId, + Contents = [content], + }; + var context = new BlockMappingContext(update, _handlers); + + foreach (var handler in _handlers) + { + var entry = handler.TryHandle(context); + if (entry is not null) + { + entry.Block.Role = update.Role; + entry.Block.AuthorName = update.AuthorName; + entry.Block.LifecycleState = BlockLifecycleState.Inactive; + return entry.Block; + } + } + + return null; + } + + /// + /// Enumerates the content items of an update that have not been claimed by a handler. + /// + public readonly struct UnhandledContentsEnumerable + { + private readonly IList _contents; + private readonly bool[] _handled; + + internal UnhandledContentsEnumerable(IList contents, bool[] handled) + { + _contents = contents; + _handled = handled; + } + + /// + /// Returns an enumerator over the unclaimed content items. + /// + /// An enumerator over the unclaimed content items. + public UnhandledContentsEnumerator GetEnumerator() => new(_contents, _handled); + } + + /// + /// Enumerator over the content items of an update that have not been claimed by a handler. + /// + public struct UnhandledContentsEnumerator + { + private readonly IList _contents; + private readonly bool[] _handled; + private int _index; + + internal UnhandledContentsEnumerator(IList contents, bool[] handled) + { + _contents = contents; + _handled = handled; + _index = -1; + } + + /// + /// Gets the content item at the current position. + /// + public AIContent Current => _contents[_index]; + + /// + /// Advances to the next unclaimed content item. + /// + /// if another unclaimed item exists; otherwise . + public bool MoveNext() + { + while (++_index < _contents.Count) + { + if (!_handled[_index]) + { + return true; + } + } + return false; + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs new file mode 100644 index 000000000000..46228004cf49 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs @@ -0,0 +1,182 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Linq; +using System.Runtime.CompilerServices; +using Microsoft.Extensions.AI; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; + +namespace Microsoft.AspNetCore.Components.AI; + +// Routes model updates to handlers in two phases: +// 1. Blocks that are still active get first refusal on the update, most recent first. +// This keeps a streaming block accumulating instead of emitting a new block per token. +// 2. Whatever is left is offered to inactive handlers, which may emit new blocks. +internal class BlockMappingPipeline +{ + private readonly List _handlers = new(); + private readonly List _activeStack = new(); + private readonly ILogger _logger; + + internal BlockMappingPipeline(UIAgentOptions options, ILogger? logger = null) + { + _logger = logger ?? NullLogger.Instance; + + // User-registered handlers go first so they can customize behavior + foreach (var registration in options.HandlerRegistrations) + { + _handlers.Add(registration.CreateEntry()); + } + + if (options.UIActions.Count > 0) + { + _handlers.Add(new HandlerEntry( + new UIActionHandler(options.UIActions))); + } + + _handlers.Add(new HandlerEntry( + new FunctionApprovalHandler())); + + _handlers.Add(new HandlerEntry( + new FunctionInvocationHandler())); + + // Structured snapshots take precedence over the plain-text fallback. + _handlers.Add(new HandlerEntry(new RichTextContentHandler())); + + // Built-in plain-text handler is always last (fallback). + _handlers.Add(new HandlerEntry(new TextBlockHandler())); + } + + internal async IAsyncEnumerable Process( + ChatResponseUpdate update, +#pragma warning disable IDE0060 // cancellationToken reserved for future use + [EnumeratorCancellation] CancellationToken cancellationToken = default) +#pragma warning restore IDE0060 + { + var contentTypes = string.Join(", ", update.Contents.Select(c => c.GetType().Name)); + BlockMappingPipelineLog.ProcessingUpdate(_logger, update.Role?.Value, update.Contents.Count, contentTypes); + + var context = new BlockMappingContext(update, _handlers); + + // Phase 1: Active entries get priority (most recent first) + for (var i = _activeStack.Count - 1; i >= 0; i--) + { + if (context.AllHandled) + { + break; + } + + var active = _activeStack[i]; + var result = active.Invoke(context); + + BlockMappingPipelineLog.ActiveHandlerResult(_logger, active.Block.GetType().Name, result.Kind.ToString(), active.Block.Id); + + switch (result.Kind) + { + case HandleResult.ResultKind.Pass: + break; + + case HandleResult.ResultKind.Update: + active.Block.InvokeNotifyChanged(); + break; + + case HandleResult.ResultKind.Complete: + active.Block.LifecycleState = BlockLifecycleState.Inactive; + active.Block.InvokeNotifyChanged(); + _activeStack.RemoveAt(i); + break; + } + } + + // Phase 2: Inactive handlers try to claim remaining content + if (!context.AllHandled) + { + for (var i = 0; i < _handlers.Count; i++) + { + if (context.AllHandled) + { + break; + } + + var handler = _handlers[i]; + BlockMappingPipelineLog.TryingInactiveHandler(_logger, handler.GetType().Name); + + while (!context.AllHandled) + { + var progressBefore = context.HandledProgress; + var activeEntry = handler.TryHandle(context); + if (activeEntry is null) + { + break; + } + + var emitBlock = activeEntry.Block; + emitBlock.Role = update.Role; + emitBlock.AuthorName = update.AuthorName; + emitBlock.LifecycleState = BlockLifecycleState.Active; + ThrowIfIdMissing(emitBlock); + + var keepActive = true; + if (emitBlock is FunctionInvocationContentBlock) + { + var catchUpResult = activeEntry.Invoke(context); + + BlockMappingPipelineLog.ActiveHandlerResult(_logger, emitBlock.GetType().Name, catchUpResult.Kind.ToString(), emitBlock.Id); + + if (catchUpResult.Kind == HandleResult.ResultKind.Complete) + { + emitBlock.LifecycleState = BlockLifecycleState.Inactive; + keepActive = false; + } + } + + if (keepActive) + { + _activeStack.Add(activeEntry); + } + + BlockMappingPipelineLog.EmittingBlock(_logger, emitBlock.GetType().Name, emitBlock.Id, emitBlock.Role?.Value); + + yield return emitBlock; + + // If the handler emitted without consuming any content, stop + // re-invoking it to prevent infinite loops. + if (context.HandledProgress == progressBefore) + { + break; + } + } + } + } + else + { + BlockMappingPipelineLog.AllContentHandledAfterPhase1(_logger); + } + + await Task.CompletedTask; + } + + internal IReadOnlyList Finalize() + { + BlockMappingPipelineLog.Finalizing(_logger, _activeStack.Count); + + foreach (var active in _activeStack) + { + active.Block.LifecycleState = BlockLifecycleState.Inactive; + active.Block.InvokeNotifyChanged(); + } + _activeStack.Clear(); + + return Array.Empty(); + } + + private static void ThrowIfIdMissing(ContentBlock block) + { + if (string.IsNullOrEmpty(block.Id)) + { + throw new InvalidOperationException( + $"Block handler emitted a {block.GetType().Name} without assigning an Id."); + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs new file mode 100644 index 000000000000..a526003ac207 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.Components.AI; + +internal static partial class BlockMappingPipelineLog +{ + [LoggerMessage(1, LogLevel.Debug, "Processing update: Role={Role}, ContentCount={ContentCount}, ContentTypes=[{ContentTypes}]")] + internal static partial void ProcessingUpdate(ILogger logger, string? role, int contentCount, string contentTypes); + + [LoggerMessage(2, LogLevel.Debug, "Active handler {HandlerType} returned {ResultKind} for block {BlockId}")] + internal static partial void ActiveHandlerResult(ILogger logger, string handlerType, string resultKind, string? blockId); + + [LoggerMessage(3, LogLevel.Information, "Emitting new block: {BlockType} Id={BlockId} Role={Role}")] + internal static partial void EmittingBlock(ILogger logger, string blockType, string? blockId, string? role); + + [LoggerMessage(4, LogLevel.Debug, "Phase 2: Trying inactive handler {HandlerType} to claim remaining content")] + internal static partial void TryingInactiveHandler(ILogger logger, string handlerType); + + [LoggerMessage(5, LogLevel.Debug, "Finalize: Deactivating {ActiveCount} active blocks")] + internal static partial void Finalizing(ILogger logger, int activeCount); + + [LoggerMessage(6, LogLevel.Debug, "All content handled after active handlers, skipping Phase 2")] + internal static partial void AllContentHandledAfterPhase1(ILogger logger); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingResult.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingResult.cs new file mode 100644 index 000000000000..4d02957ef03b --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingResult.cs @@ -0,0 +1,57 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// The outcome of a invocation. +/// +/// The state the handler keeps across updates. +public readonly struct BlockMappingResult +{ + internal enum ResultKind { Pass, Emit, Update, Complete } + + internal ResultKind Kind { get; } + + internal ContentBlock? Block { get; } + + internal TState? State { get; } + + private BlockMappingResult(ResultKind kind, ContentBlock? block, TState? state) + { + Kind = kind; + Block = block; + State = state; + } + + /// + /// Indicates that the handler did not claim anything from the update. + /// + /// A result that leaves the update for other handlers. + public static BlockMappingResult Pass() => new(ResultKind.Pass, null, default); + + /// + /// Indicates that the handler produced a new block for the conversation. + /// + /// The block to add to the conversation. + /// The state to carry into subsequent updates. + /// A result that emits . + public static BlockMappingResult Emit(ContentBlock block, TState state) + { + ArgumentNullException.ThrowIfNull(block); + return new(ResultKind.Emit, block, state); + } + + /// + /// Indicates that the handler updated the block it previously emitted. + /// + /// The updated state. + /// A result that notifies the UI that the block changed. + public static BlockMappingResult Update(TState state) => new(ResultKind.Update, null, state); + + /// + /// Indicates that the block the handler emitted is complete. + /// + /// A result that deactivates the block. + public static BlockMappingResult Complete() => new(ResultKind.Complete, null, default); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ContentBlockHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ContentBlockHandler.cs new file mode 100644 index 000000000000..514980c728b3 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ContentBlockHandler.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Maps model updates into content blocks. A handler is invoked for every update until it +/// completes the block it emitted. +/// +/// The state the handler keeps across updates for a single block. +/// +/// +/// internal sealed class EchoHandler : ContentBlockHandler<RichContentBlock> +/// { +/// public override BlockMappingResult<RichContentBlock> Handle( +/// BlockMappingContext context, RichContentBlock state) +/// => BlockMappingResult<RichContentBlock>.Pass(); +/// } +/// +/// +public abstract class ContentBlockHandler where TState : new() +{ + /// + /// Handles an update. + /// + /// The update being mapped. + /// The state for the block this handler owns. + /// The outcome of the invocation. + public abstract BlockMappingResult Handle(BlockMappingContext context, TState state); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs new file mode 100644 index 000000000000..d5ff5164a434 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs @@ -0,0 +1,60 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +internal sealed class FunctionApprovalHandler : + ContentBlockHandler +{ + public override BlockMappingResult Handle(BlockMappingContext context, State state) + { + if (state.Emitted) + { + return BlockMappingResult.Complete(); + } + + foreach (var content in context.UnhandledContents) + { + if (content is not ToolApprovalRequestContent approvalRequest) + { + continue; + } + + context.MarkHandled(approvalRequest); + + var innerBlock = context.CreateInnerBlock(approvalRequest.ToolCall) + ?? CreateFallbackInnerBlock(approvalRequest.ToolCall); + + state.Emitted = true; + return BlockMappingResult.Emit( + new FunctionApprovalBlock(innerBlock, approvalRequest) + { + Id = approvalRequest.ToolCall is FunctionCallContent functionCall + ? functionCall.CallId ?? approvalRequest.RequestId + : approvalRequest.RequestId + }, + state); + } + + return BlockMappingResult.Pass(); + } + + private static FunctionInvocationContentBlock CreateFallbackInnerBlock( + ToolCallContent toolCall) + { + var block = new FunctionInvocationContentBlock(); + if (toolCall is FunctionCallContent functionCall) + { + block.Call = functionCall; + } + + return block; + } + + internal sealed class State + { + internal bool Emitted { get; set; } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs new file mode 100644 index 000000000000..367fd0063a1b --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +internal sealed class FunctionInvocationHandler : ContentBlockHandler +{ + public override BlockMappingResult Handle( + BlockMappingContext context, + FunctionInvocationContentBlock state) + { + if (state.Result is not null) + { + return BlockMappingResult.Complete(); + } + + var shouldEmit = false; + if (state.Call is null) + { + foreach (var content in context.UnhandledContents) + { + if (content is FunctionCallContent call) + { + context.MarkHandled(call); + state.Call = call; + shouldEmit = true; + break; + } + } + } + + if (state.Call is not null) + { + foreach (var content in context.UnhandledContents) + { + if (content is FunctionResultContent result && + result.CallId == state.Call.CallId) + { + context.MarkHandled(result); + state.Result = result; + return shouldEmit + ? BlockMappingResult.Emit(state, state) + : BlockMappingResult.Complete(); + } + } + } + + return shouldEmit + ? BlockMappingResult.Emit(state, state) + : BlockMappingResult.Pass(); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandleResult.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandleResult.cs new file mode 100644 index 000000000000..c48b3795f68b --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandleResult.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +internal readonly struct HandleResult +{ + internal enum ResultKind { Pass, Update, Complete } + + internal ResultKind Kind { get; } + + private HandleResult(ResultKind kind) + { + Kind = kind; + } + + internal static HandleResult Pass() => new(ResultKind.Pass); + + internal static HandleResult Update() => new(ResultKind.Update); + + internal static HandleResult Complete() => new(ResultKind.Complete); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandlerEntry.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandlerEntry.cs new file mode 100644 index 000000000000..9b2fd5764871 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandlerEntry.cs @@ -0,0 +1,61 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +internal sealed class HandlerEntry : IHandlerEntry where TState : new() +{ + private readonly ContentBlockHandler _handler; + + internal HandlerEntry(ContentBlockHandler handler) + { + _handler = handler; + } + + public IActiveEntry? TryHandle(BlockMappingContext context) + { + var state = new TState(); + var result = _handler.Handle(context, state); + if (result.Kind == BlockMappingResult.ResultKind.Emit) + { + return new ActiveEntry(_handler, result.State!, result.Block!); + } + + return null; + } + + private sealed class ActiveEntry : IActiveEntry + { + private readonly ContentBlockHandler _handler; + private TState _state; + + internal ActiveEntry( + ContentBlockHandler handler, + TState state, + ContentBlock block) + { + _handler = handler; + _state = state; + Block = block; + } + + public ContentBlock Block { get; } + + public HandleResult Invoke(BlockMappingContext context) + { + var result = _handler.Handle(context, _state); + switch (result.Kind) + { + case BlockMappingResult.ResultKind.Update: + _state = result.State!; + return HandleResult.Update(); + + case BlockMappingResult.ResultKind.Complete: + return HandleResult.Complete(); + + default: + return HandleResult.Pass(); + } + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IActiveEntry.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IActiveEntry.cs new file mode 100644 index 000000000000..555f43c83993 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IActiveEntry.cs @@ -0,0 +1,11 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +internal interface IActiveEntry +{ + ContentBlock Block { get; } + + HandleResult Invoke(BlockMappingContext context); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IHandlerEntry.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IHandlerEntry.cs new file mode 100644 index 000000000000..89d58b292ee8 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IHandlerEntry.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +internal interface IHandlerEntry +{ + IActiveEntry? TryHandle(BlockMappingContext context); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/RichTextContentHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/RichTextContentHandler.cs new file mode 100644 index 000000000000..acad1a443a7e --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/RichTextContentHandler.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +internal sealed class RichTextContentHandler : ContentBlockHandler +{ + public override BlockMappingResult Handle( + BlockMappingContext context, RichContentBlock state) + { + RichTextContent? snapshot = null; + foreach (var content in context.UnhandledContents) + { + if (content is RichTextContent richText) + { + snapshot = richText; + } + } + + if (snapshot is null) + { + return state.Id.Length > 0 + ? BlockMappingResult.Complete() + : BlockMappingResult.Pass(); + } + + if (state.Id.Length > 0 && + context.Update.MessageId is { Length: > 0 } messageId && + !string.Equals(state.Id, messageId, StringComparison.Ordinal)) + { + return BlockMappingResult.Complete(); + } + + foreach (var content in context.UnhandledContents) + { + if (content is RichTextContent or TextContent) + { + context.MarkHandled(content); + } + } + + state.ReplaceContent(snapshot.Text, snapshot.Nodes); + + if (state.Id.Length == 0) + { + state.Id = context.Update.MessageId ?? Guid.NewGuid().ToString("N"); + return BlockMappingResult.Emit(state, state); + } + + return BlockMappingResult.Update(state); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/StateMapperContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/StateMapperContext.cs new file mode 100644 index 000000000000..fb1cce621d74 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/StateMapperContext.cs @@ -0,0 +1,131 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Carries a model update through typed state mapping and tracks content consumed as state. +/// +public class StateMapperContext +{ + private readonly bool[] _handled; + private int _handledCount; + + internal StateMapperContext(ChatResponseUpdate update) + { + Update = update; + _handled = new bool[update.Contents.Count]; + } + + /// + /// Gets the update being mapped. + /// + public ChatResponseUpdate Update { get; } + + /// + /// Gets content items that have not been consumed by the state mapper. + /// + public IEnumerable UnhandledContents + { + get + { + var contents = Update.Contents; + for (var i = 0; i < contents.Count; i++) + { + if (!_handled[i]) + { + yield return contents[i]; + } + } + } + } + + /// + /// Marks a content item as consumed by the state mapper. + /// + /// The content item that was handled. + public void MarkHandled(AIContent content) + { + ArgumentNullException.ThrowIfNull(content); + + var contents = Update.Contents; + for (var i = 0; i < contents.Count; i++) + { + if (ReferenceEquals(contents[i], content)) + { + if (!_handled[i]) + { + _handled[i] = true; + _handledCount++; + } + + return; + } + } + } + + internal object? StateValue { get; private set; } + + internal bool IsPredictiveState { get; private set; } + + /// + /// Sets the next typed state value. + /// + /// The next state value. + public void SetState(object value) + { + ArgumentNullException.ThrowIfNull(value); + StateValue = value; + IsPredictiveState = false; + } + + /// + /// Sets a provisional typed state value that must be accepted or rejected before the turn + /// completes. + /// + /// The next provisional state value. + public void SetPredictiveState(object value) + { + ArgumentNullException.ThrowIfNull(value); + StateValue = value; + IsPredictiveState = true; + } + + internal bool HasHandledContent => _handledCount > 0; + + internal ChatResponseUpdate GetFilteredUpdate() + { + if (_handledCount == 0) + { + return Update; + } + + var filtered = new List(); + var contents = Update.Contents; + for (var i = 0; i < contents.Count; i++) + { + if (!_handled[i]) + { + filtered.Add(contents[i]); + } + } + + return new ChatResponseUpdate + { + Role = Update.Role, + AuthorName = Update.AuthorName, + MessageId = Update.MessageId, + ResponseId = Update.ResponseId, + ConversationId = Update.ConversationId, + CreatedAt = Update.CreatedAt, + FinishReason = Update.FinishReason, + ModelId = Update.ModelId, + ContinuationToken = Update.ContinuationToken, + RawRepresentation = Update.RawRepresentation, + AdditionalProperties = Update.AdditionalProperties, + Contents = filtered, + }; + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/TextBlockHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/TextBlockHandler.cs new file mode 100644 index 000000000000..b8b5c04113f8 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/TextBlockHandler.cs @@ -0,0 +1,91 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +// Fallback handler: claims TextContent and accumulates it into a single block for the +// duration of a model message. It runs last so more specific handlers get first refusal. +internal sealed class TextBlockHandler : ContentBlockHandler +{ + public override BlockMappingResult Handle( + BlockMappingContext context, RichContentBlock state) + { + TextContent? textContent = null; + foreach (var content in context.UnhandledContents) + { + if (content is TextContent tc) + { + textContent = tc; + break; + } + } + + if (textContent is null) + { + if (state.Id != string.Empty) + { + return BlockMappingResult.Complete(); + } + + return BlockMappingResult.Pass(); + } + + context.MarkHandled(textContent); + state.AppendText(textContent.Text ?? string.Empty); + RebuildParagraphs(state); + + if (state.Id == string.Empty) + { + state.Id = context.Update.MessageId ?? Guid.NewGuid().ToString("N"); + return BlockMappingResult.Emit(state, state); + } + + return BlockMappingResult.Update(state); + } + + internal static void RebuildParagraphs(RichContentBlock state) + { + var rawText = state.RawText; + if (rawText.Length == 0) + { + state.Content = Array.Empty(); + return; + } + + var paragraphs = new List(); + var start = 0; + while (start < rawText.Length) + { + var breakIndex = rawText.IndexOf("\n\n", start, StringComparison.Ordinal); + if (breakIndex < 0) + { + AddParagraph(paragraphs, rawText.AsSpan(start)); + break; + } + + if (breakIndex > start) + { + AddParagraph(paragraphs, rawText.AsSpan(start, breakIndex - start)); + } + + start = breakIndex + 2; + } + + state.Content = paragraphs; + } + + private static void AddParagraph(List paragraphs, ReadOnlySpan text) + { + var trimmed = text.TrimEnd("\r\n".AsSpan()); + if (trimmed.Length == 0) + { + return; + } + + var paragraph = new ParagraphNode(); + paragraph.AddChild(new TextNode(trimmed.ToString())); + paragraphs.Add(paragraph); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIActionHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIActionHandler.cs new file mode 100644 index 000000000000..f1c2ee27c9fe --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIActionHandler.cs @@ -0,0 +1,48 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +internal sealed class UIActionHandler : ContentBlockHandler +{ + private readonly IReadOnlyDictionary _actions; + + internal UIActionHandler(IReadOnlyDictionary actions) + { + _actions = actions; + } + + public override BlockMappingResult Handle(BlockMappingContext context, State state) + { + if (state.HasEmitted) + { + return BlockMappingResult.Pass(); + } + + foreach (var content in context.UnhandledContents) + { + if (content is FunctionCallContent call && + !call.InformationalOnly && + _actions.TryGetValue(call.Name, out var function)) + { + context.MarkHandled(call); + state.HasEmitted = true; + return BlockMappingResult.Emit( + new UIActionBlock(function, call) + { + Id = call.CallId ?? Guid.NewGuid().ToString("N") + }, + state); + } + } + + return BlockMappingResult.Pass(); + } + + internal sealed class State + { + public bool HasEmitted { get; set; } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIAgentOptions.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIAgentOptions.cs new file mode 100644 index 000000000000..546e27e5e4ed --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIAgentOptions.cs @@ -0,0 +1,104 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Configures a . +/// +/// +/// +/// var agent = new UIAgent(chatClient, options => +/// { +/// options.ChatOptions = new ChatOptions { Instructions = "You are a helpful assistant." }; +/// }); +/// +/// +public class UIAgentOptions +{ + /// + /// Gets or sets the options passed to the underlying . + /// + public ChatOptions? ChatOptions { get; set; } + + /// + /// Gets or sets a callback that maps model updates into typed agent state. + /// + public Action? StateMapper { get; set; } + + /// + /// Gets or sets the persistent conversation thread that receives completed turns. + /// + public IConversationThread? Thread { get; set; } + + internal List HandlerRegistrations { get; } = new(); + + internal Dictionary UIActions { get; } = + new(StringComparer.Ordinal); + + /// + /// Registers a handler that maps model updates into content blocks. Registered handlers + /// run before the built-in ones, so they can claim content the built-in handlers would + /// otherwise map. + /// + /// The state the handler keeps across updates. + /// The handler to register. + public void AddBlockHandler(ContentBlockHandler handler) + where TState : new() + { + ArgumentNullException.ThrowIfNull(handler); + HandlerRegistrations.Add(new HandlerRegistration(handler)); + } + + /// + /// Registers a function that a matching model tool call executes in the UI. + /// The function is sent to the chat client as a declaration, not as an executable server tool. + /// + /// + /// The function to execute in the UI. Its name must be unique among the registered UI actions. + /// + /// + /// An action with the same name is already registered. + /// + public void RegisterUIAction(AIFunction function) + { + ArgumentNullException.ThrowIfNull(function); + UIActions.Add(function.Name, function); + } + + internal interface IHandlerRegistration + { + IHandlerEntry CreateEntry(); + } + + private sealed class HandlerRegistration : IHandlerRegistration where TState : new() + { + private readonly ContentBlockHandler _handler; + + internal HandlerRegistration(ContentBlockHandler handler) + { + _handler = handler; + } + + public IHandlerEntry CreateEntry() => new HandlerEntry(_handler); + } +} + +/// +/// Configures a . +/// +/// The type of state associated with the agent. +public sealed class UIAgentOptions : UIAgentOptions where TState : class, new() +{ + internal UIAgentOptions(TState? initialState) + { + State = new AgentState(initialState); + } + + /// + /// Gets the observable state associated with the agent. + /// + public AgentState State { get; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Shipped.txt b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Shipped.txt new file mode 100644 index 000000000000..7dc5c58110bf --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Unshipped.txt b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Unshipped.txt new file mode 100644 index 000000000000..2241a1e6ba68 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Unshipped.txt @@ -0,0 +1,360 @@ +#nullable enable +Microsoft.AspNetCore.Components.AI.AgentBoundary +Microsoft.AspNetCore.Components.AI.AgentBoundary.Agent.get -> Microsoft.AspNetCore.Components.AI.UIAgent! +Microsoft.AspNetCore.Components.AI.AgentBoundary.Agent.set -> void +Microsoft.AspNetCore.Components.AI.AgentBoundary.AgentBoundary() -> void +Microsoft.AspNetCore.Components.AI.AgentBoundary.ChildContent.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.AgentBoundary.ChildContent.set -> void +Microsoft.AspNetCore.Components.AI.AgentBoundary.Dispose() -> void +Microsoft.AspNetCore.Components.AI.AgentState +Microsoft.AspNetCore.Components.AI.AgentState.AcceptPredictiveState() -> void +Microsoft.AspNetCore.Components.AI.AgentState.HasPendingPredictiveState.get -> bool +Microsoft.AspNetCore.Components.AI.AgentState.OnChanged(System.Action! callback) -> System.IDisposable! +Microsoft.AspNetCore.Components.AI.AgentState.RejectPredictiveState() -> void +Microsoft.AspNetCore.Components.AI.AgentState.Value.get -> T! +Microsoft.AspNetCore.Components.AI.AgentState.Value.set -> void +Microsoft.AspNetCore.Components.AI.AgentContext +Microsoft.AspNetCore.Components.AI.AgentContext.AgentContext(Microsoft.AspNetCore.Components.AI.UIAgent! agent) -> void +Microsoft.AspNetCore.Components.AI.AgentContext.CancelAsync() -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.AgentContext.Dispose() -> void +Microsoft.AspNetCore.Components.AI.AgentContext.Error.get -> System.Exception? +Microsoft.AspNetCore.Components.AI.AgentContext.RegisterOnBlockAdded(System.Action! callback) -> System.IDisposable! +Microsoft.AspNetCore.Components.AI.AgentContext.RegisterOnStatusChanged(System.Action! callback) -> System.IDisposable! +Microsoft.AspNetCore.Components.AI.AgentContext.RegisterOnTurnAdded(System.Action! callback) -> System.IDisposable! +Microsoft.AspNetCore.Components.AI.AgentContext.RetryAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.AgentContext.RestoreAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.AgentContext.SendMessageAsync(Microsoft.Extensions.AI.ChatMessage! message, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.AgentContext.SendMessageAsync(string! text, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.AgentContext.Status.get -> Microsoft.AspNetCore.Components.AI.ConversationStatus +Microsoft.AspNetCore.Components.AI.AgentContext.Turns.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.ApprovalStatus +Microsoft.AspNetCore.Components.AI.ApprovalStatus.Approved = 1 -> Microsoft.AspNetCore.Components.AI.ApprovalStatus +Microsoft.AspNetCore.Components.AI.ApprovalStatus.Pending = 0 -> Microsoft.AspNetCore.Components.AI.ApprovalStatus +Microsoft.AspNetCore.Components.AI.ApprovalStatus.Rejected = 2 -> Microsoft.AspNetCore.Components.AI.ApprovalStatus +Microsoft.AspNetCore.Components.AI.ActivityContentBlock +Microsoft.AspNetCore.Components.AI.ActivityContentBlock.ActivityContentBlock() -> void +Microsoft.AspNetCore.Components.AI.ActivityContentBlock.ActivityType.get -> string! +Microsoft.AspNetCore.Components.AI.ActivityContentBlock.ActivityType.set -> void +Microsoft.AspNetCore.Components.AI.ActivityContentBlock.Content.get -> System.Text.Json.JsonElement +Microsoft.AspNetCore.Components.AI.ActivityContentBlock.Content.set -> void +Microsoft.AspNetCore.Components.AI.ActivityHandler +Microsoft.AspNetCore.Components.AI.ActivityHandler.ActivityHandler() -> void +Microsoft.AspNetCore.Components.AI.BlockLifecycleState +Microsoft.AspNetCore.Components.AI.BlockLifecycleState.Active = 1 -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState +Microsoft.AspNetCore.Components.AI.BlockLifecycleState.Inactive = 2 -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState +Microsoft.AspNetCore.Components.AI.BlockLifecycleState.Pending = 0 -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState +Microsoft.AspNetCore.Components.AI.BlockMappingContext +Microsoft.AspNetCore.Components.AI.BlockMappingContext.AllHandled.get -> bool +Microsoft.AspNetCore.Components.AI.BlockMappingContext.CreateInnerBlock(Microsoft.Extensions.AI.AIContent! content) -> Microsoft.AspNetCore.Components.AI.ContentBlock? +Microsoft.AspNetCore.Components.AI.BlockMappingContext.MarkHandled(Microsoft.Extensions.AI.AIContent! content) -> void +Microsoft.AspNetCore.Components.AI.BlockMappingContext.MarkUpdateHandled() -> void +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContents.get -> Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable.GetEnumerator() -> Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable.UnhandledContentsEnumerable() -> void +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator.Current.get -> Microsoft.Extensions.AI.AIContent! +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator.MoveNext() -> bool +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator.UnhandledContentsEnumerator() -> void +Microsoft.AspNetCore.Components.AI.BlockMappingContext.Update.get -> Microsoft.Extensions.AI.ChatResponseUpdate! +Microsoft.AspNetCore.Components.AI.BlockMappingResult +Microsoft.AspNetCore.Components.AI.BlockMappingResult.BlockMappingResult() -> void +Microsoft.AspNetCore.Components.AI.BlockQuoteNode +Microsoft.AspNetCore.Components.AI.BlockQuoteNode.BlockQuoteNode() -> void +Microsoft.AspNetCore.Components.AI.BlockRenderer +Microsoft.AspNetCore.Components.AI.BlockRenderer.BlockRenderer() -> void +Microsoft.AspNetCore.Components.AI.BlockRenderer.ChildContent.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.BlockRenderer.ChildContent.set -> void +Microsoft.AspNetCore.Components.AI.BlockRenderer.Dispose() -> void +Microsoft.AspNetCore.Components.AI.BlockRenderer.ListContext.get -> Microsoft.AspNetCore.Components.AI.MessageListContext! +Microsoft.AspNetCore.Components.AI.BlockRenderer.ListContext.set -> void +Microsoft.AspNetCore.Components.AI.BlockRenderer.When.get -> System.Func? +Microsoft.AspNetCore.Components.AI.BlockRenderer.When.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage +Microsoft.AspNetCore.Components.AI.ChatPage.AdditionalAttributes.get -> System.Collections.Generic.Dictionary? +Microsoft.AspNetCore.Components.AI.ChatPage.AdditionalAttributes.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.Agent.get -> Microsoft.AspNetCore.Components.AI.UIAgent! +Microsoft.AspNetCore.Components.AI.ChatPage.Agent.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.ChatPage() -> void +Microsoft.AspNetCore.Components.AI.ChatPage.Header.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.ChatPage.Header.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.InputLeadingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.ChatPage.InputLeadingActions.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.InputTrailingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.ChatPage.InputTrailingActions.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.MessageListContent.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.ChatPage.MessageListContent.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.Placeholder.get -> string? +Microsoft.AspNetCore.Components.AI.ChatPage.Placeholder.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.WelcomeContent.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.ChatPage.WelcomeContent.set -> void +Microsoft.AspNetCore.Components.AI.CodeBlockNode +Microsoft.AspNetCore.Components.AI.CodeBlockNode.Code.get -> string! +Microsoft.AspNetCore.Components.AI.CodeBlockNode.Code.set -> void +Microsoft.AspNetCore.Components.AI.CodeBlockNode.CodeBlockNode() -> void +Microsoft.AspNetCore.Components.AI.CodeBlockNode.CodeBlockNode(string! code, string? language = null) -> void +Microsoft.AspNetCore.Components.AI.CodeBlockNode.Language.get -> string? +Microsoft.AspNetCore.Components.AI.CodeBlockNode.Language.set -> void +Microsoft.AspNetCore.Components.AI.ContentBlock +Microsoft.AspNetCore.Components.AI.ContentBlock.AuthorName.get -> string? +Microsoft.AspNetCore.Components.AI.ContentBlock.ContentBlock() -> void +Microsoft.AspNetCore.Components.AI.ContentBlock.Id.get -> string! +Microsoft.AspNetCore.Components.AI.ContentBlock.LifecycleState.get -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState +Microsoft.AspNetCore.Components.AI.ContentBlock.NotifyChanged() -> void +Microsoft.AspNetCore.Components.AI.ContentBlock.OnChanged(System.Action! callback) -> Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription +Microsoft.AspNetCore.Components.AI.ContentBlock.Role.get -> Microsoft.Extensions.AI.ChatRole? +Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription +Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription.ContentBlockChangedSubscription() -> void +Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription.Dispose() -> void +Microsoft.AspNetCore.Components.AI.ContentBlockHandler +Microsoft.AspNetCore.Components.AI.ContentBlockHandler.ContentBlockHandler() -> void +Microsoft.AspNetCore.Components.AI.ConversationStatus +Microsoft.AspNetCore.Components.AI.ConversationStatus.AwaitingInput = 2 -> Microsoft.AspNetCore.Components.AI.ConversationStatus +Microsoft.AspNetCore.Components.AI.ConversationStatus.Error = 3 -> Microsoft.AspNetCore.Components.AI.ConversationStatus +Microsoft.AspNetCore.Components.AI.ConversationStatus.Idle = 0 -> Microsoft.AspNetCore.Components.AI.ConversationStatus +Microsoft.AspNetCore.Components.AI.ConversationStatus.Streaming = 1 -> Microsoft.AspNetCore.Components.AI.ConversationStatus +Microsoft.AspNetCore.Components.AI.ConversationTurn +Microsoft.AspNetCore.Components.AI.ConversationTurn.ConversationTurn() -> void +Microsoft.AspNetCore.Components.AI.ConversationTurn.Id.get -> string! +Microsoft.AspNetCore.Components.AI.ConversationTurn.RequestBlocks.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.ConversationTurn.ResponseBlocks.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.DefinitionNode +Microsoft.AspNetCore.Components.AI.DefinitionNode.DefinitionNode() -> void +Microsoft.AspNetCore.Components.AI.DefinitionNode.Label.get -> string! +Microsoft.AspNetCore.Components.AI.DefinitionNode.Label.set -> void +Microsoft.AspNetCore.Components.AI.DefinitionNode.Title.get -> string? +Microsoft.AspNetCore.Components.AI.DefinitionNode.Title.set -> void +Microsoft.AspNetCore.Components.AI.DefinitionNode.Url.get -> string! +Microsoft.AspNetCore.Components.AI.DefinitionNode.Url.set -> void +Microsoft.AspNetCore.Components.AI.EmphasisNode +Microsoft.AspNetCore.Components.AI.EmphasisNode.EmphasisNode() -> void +Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode +Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode.FootnoteDefinitionNode() -> void +Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode.Label.get -> string! +Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode.Label.set -> void +Microsoft.AspNetCore.Components.AI.FootnoteNode +Microsoft.AspNetCore.Components.AI.FootnoteNode.FootnoteNode() -> void +Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode +Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode.FootnoteReferenceNode() -> void +Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode.Label.get -> string! +Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode.Label.set -> void +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Arguments.get -> System.Collections.Generic.IDictionary? +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.ApprovalRequest.get -> Microsoft.Extensions.AI.ToolApprovalRequestContent! +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Approve() -> void +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Call.get -> Microsoft.Extensions.AI.FunctionCallContent? +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.GetResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.HasResult.get -> bool +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.InnerBlock.get -> Microsoft.AspNetCore.Components.AI.ContentBlock! +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Reject(string? reason = null) -> void +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Result.get -> Microsoft.Extensions.AI.FunctionResultContent? +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Status.get -> Microsoft.AspNetCore.Components.AI.ApprovalStatus +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.ToolName.get -> string? +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Arguments.get -> System.Collections.Generic.IDictionary? +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Call.get -> Microsoft.Extensions.AI.FunctionCallContent? +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Call.set -> void +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.FunctionInvocationContentBlock() -> void +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.HasResult.get -> bool +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Result.get -> Microsoft.Extensions.AI.FunctionResultContent? +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Result.set -> void +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.ToolName.get -> string? +Microsoft.AspNetCore.Components.AI.HeadingNode +Microsoft.AspNetCore.Components.AI.HeadingNode.HeadingNode() -> void +Microsoft.AspNetCore.Components.AI.HeadingNode.HeadingNode(int level) -> void +Microsoft.AspNetCore.Components.AI.HeadingNode.Level.get -> int +Microsoft.AspNetCore.Components.AI.HeadingNode.Level.set -> void +Microsoft.AspNetCore.Components.AI.HtmlNode +Microsoft.AspNetCore.Components.AI.HtmlNode.HtmlNode() -> void +Microsoft.AspNetCore.Components.AI.HtmlNode.HtmlNode(string! value) -> void +Microsoft.AspNetCore.Components.AI.HtmlNode.Value.get -> string! +Microsoft.AspNetCore.Components.AI.HtmlNode.Value.set -> void +Microsoft.AspNetCore.Components.AI.IInteractiveBlock +Microsoft.AspNetCore.Components.AI.IInteractiveBlock.GetResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.IConversationThread +Microsoft.AspNetCore.Components.AI.IConversationThread.AppendUpdate(Microsoft.Extensions.AI.ChatResponseUpdate! update) -> void +Microsoft.AspNetCore.Components.AI.IConversationThread.AppendUserMessage(Microsoft.Extensions.AI.ChatMessage! message) -> void +Microsoft.AspNetCore.Components.AI.IConversationThread.CompleteTurn() -> void +Microsoft.AspNetCore.Components.AI.IConversationThread.ConversationId.get -> string? +Microsoft.AspNetCore.Components.AI.IConversationThread.GetUpdates() -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.IConversationThread.IsStateful.get -> bool +Microsoft.AspNetCore.Components.AI.IConversationThread.ThreadId.get -> string! +Microsoft.AspNetCore.Components.AI.ImageNode +Microsoft.AspNetCore.Components.AI.ImageNode.Alt.get -> string? +Microsoft.AspNetCore.Components.AI.ImageNode.Alt.set -> void +Microsoft.AspNetCore.Components.AI.ImageNode.ImageNode() -> void +Microsoft.AspNetCore.Components.AI.ImageNode.ImageNode(string! url, string? alt = null, string? title = null) -> void +Microsoft.AspNetCore.Components.AI.ImageNode.Title.get -> string? +Microsoft.AspNetCore.Components.AI.ImageNode.Title.set -> void +Microsoft.AspNetCore.Components.AI.ImageNode.Url.get -> string! +Microsoft.AspNetCore.Components.AI.ImageNode.Url.set -> void +Microsoft.AspNetCore.Components.AI.ImageReferenceNode +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Alt.get -> string? +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Alt.set -> void +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.ImageReferenceNode() -> void +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Label.get -> string! +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Label.set -> void +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.ReferenceKind.get -> Microsoft.AspNetCore.Components.AI.ReferenceKind +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.ReferenceKind.set -> void +Microsoft.AspNetCore.Components.AI.InlineCodeNode +Microsoft.AspNetCore.Components.AI.InlineCodeNode.Code.get -> string! +Microsoft.AspNetCore.Components.AI.InlineCodeNode.Code.set -> void +Microsoft.AspNetCore.Components.AI.InlineCodeNode.InlineCodeNode() -> void +Microsoft.AspNetCore.Components.AI.InlineCodeNode.InlineCodeNode(string! code) -> void +Microsoft.AspNetCore.Components.AI.LineBreakNode +Microsoft.AspNetCore.Components.AI.LineBreakNode.LineBreakNode() -> void +Microsoft.AspNetCore.Components.AI.LinkNode +Microsoft.AspNetCore.Components.AI.LinkNode.LinkNode() -> void +Microsoft.AspNetCore.Components.AI.LinkNode.LinkNode(string! url, string? title = null) -> void +Microsoft.AspNetCore.Components.AI.LinkNode.Title.get -> string? +Microsoft.AspNetCore.Components.AI.LinkNode.Title.set -> void +Microsoft.AspNetCore.Components.AI.LinkNode.Url.get -> string! +Microsoft.AspNetCore.Components.AI.LinkNode.Url.set -> void +Microsoft.AspNetCore.Components.AI.LinkReferenceNode +Microsoft.AspNetCore.Components.AI.LinkReferenceNode.Label.get -> string! +Microsoft.AspNetCore.Components.AI.LinkReferenceNode.Label.set -> void +Microsoft.AspNetCore.Components.AI.LinkReferenceNode.LinkReferenceNode() -> void +Microsoft.AspNetCore.Components.AI.LinkReferenceNode.ReferenceKind.get -> Microsoft.AspNetCore.Components.AI.ReferenceKind +Microsoft.AspNetCore.Components.AI.LinkReferenceNode.ReferenceKind.set -> void +Microsoft.AspNetCore.Components.AI.ListItemNode +Microsoft.AspNetCore.Components.AI.ListItemNode.Checked.get -> bool? +Microsoft.AspNetCore.Components.AI.ListItemNode.Checked.set -> void +Microsoft.AspNetCore.Components.AI.ListItemNode.ListItemNode() -> void +Microsoft.AspNetCore.Components.AI.ListNode +Microsoft.AspNetCore.Components.AI.ListNode.ListNode() -> void +Microsoft.AspNetCore.Components.AI.ListNode.ListNode(bool ordered, int? start = null) -> void +Microsoft.AspNetCore.Components.AI.ListNode.Ordered.get -> bool +Microsoft.AspNetCore.Components.AI.ListNode.Ordered.set -> void +Microsoft.AspNetCore.Components.AI.ListNode.Start.get -> int? +Microsoft.AspNetCore.Components.AI.ListNode.Start.set -> void +Microsoft.AspNetCore.Components.AI.MessageInput +Microsoft.AspNetCore.Components.AI.MessageInput.AgentContext.get -> Microsoft.AspNetCore.Components.AI.AgentContext! +Microsoft.AspNetCore.Components.AI.MessageInput.AgentContext.set -> void +Microsoft.AspNetCore.Components.AI.MessageInput.Dispose() -> void +Microsoft.AspNetCore.Components.AI.MessageInput.LeadingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.MessageInput.LeadingActions.set -> void +Microsoft.AspNetCore.Components.AI.MessageInput.MessageInput() -> void +Microsoft.AspNetCore.Components.AI.MessageInput.Placeholder.get -> string? +Microsoft.AspNetCore.Components.AI.MessageInput.Placeholder.set -> void +Microsoft.AspNetCore.Components.AI.MessageInput.TrailingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.MessageInput.TrailingActions.set -> void +Microsoft.AspNetCore.Components.AI.MessageList +Microsoft.AspNetCore.Components.AI.MessageList.AgentContext.get -> Microsoft.AspNetCore.Components.AI.AgentContext! +Microsoft.AspNetCore.Components.AI.MessageList.AgentContext.set -> void +Microsoft.AspNetCore.Components.AI.MessageList.ChildContent.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.MessageList.ChildContent.set -> void +Microsoft.AspNetCore.Components.AI.MessageList.Dispose() -> void +Microsoft.AspNetCore.Components.AI.MessageList.EmptyContent.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.MessageList.EmptyContent.set -> void +Microsoft.AspNetCore.Components.AI.MessageList.Footer.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.MessageList.Footer.set -> void +Microsoft.AspNetCore.Components.AI.MessageList.MessageList() -> void +Microsoft.AspNetCore.Components.AI.MessageListContext +Microsoft.AspNetCore.Components.AI.MessageListContext.MessageListContext() -> void +Microsoft.AspNetCore.Components.AI.MessageListContext.RenderBlock(Microsoft.AspNetCore.Components.AI.ContentBlock! block) -> Microsoft.AspNetCore.Components.RenderFragment! +Microsoft.AspNetCore.Components.AI.ParagraphNode +Microsoft.AspNetCore.Components.AI.ParagraphNode.ParagraphNode() -> void +Microsoft.AspNetCore.Components.AI.ReferenceKind +Microsoft.AspNetCore.Components.AI.ReferenceKind.Collapsed = 1 -> Microsoft.AspNetCore.Components.AI.ReferenceKind +Microsoft.AspNetCore.Components.AI.ReferenceKind.Full = 2 -> Microsoft.AspNetCore.Components.AI.ReferenceKind +Microsoft.AspNetCore.Components.AI.ReferenceKind.Shortcut = 0 -> Microsoft.AspNetCore.Components.AI.ReferenceKind +Microsoft.AspNetCore.Components.AI.RichContentBlock +Microsoft.AspNetCore.Components.AI.RichContentBlock.AppendText(string! text) -> void +Microsoft.AspNetCore.Components.AI.RichContentBlock.Content.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.RichContentBlock.RawText.get -> string! +Microsoft.AspNetCore.Components.AI.RichContentBlock.RichContentBlock() -> void +Microsoft.AspNetCore.Components.AI.RichTextContent +Microsoft.AspNetCore.Components.AI.RichTextContent.Nodes.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.RichTextContent.RichTextContent(string! text, System.Collections.Generic.IReadOnlyList! nodes) -> void +Microsoft.AspNetCore.Components.AI.RichTextContent.Text.get -> string! +Microsoft.AspNetCore.Components.AI.RichTextNode +Microsoft.AspNetCore.Components.AI.RichTextNode.AddChild(Microsoft.AspNetCore.Components.AI.RichTextNode! child) -> void +Microsoft.AspNetCore.Components.AI.RichTextNode.Children.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.RichTextNode.RichTextNode() -> void +Microsoft.AspNetCore.Components.AI.StrikethroughNode +Microsoft.AspNetCore.Components.AI.StrikethroughNode.StrikethroughNode() -> void +Microsoft.AspNetCore.Components.AI.StrongNode +Microsoft.AspNetCore.Components.AI.StrongNode.StrongNode() -> void +Microsoft.AspNetCore.Components.AI.StateMapperContext +Microsoft.AspNetCore.Components.AI.StateMapperContext.MarkHandled(Microsoft.Extensions.AI.AIContent! content) -> void +Microsoft.AspNetCore.Components.AI.StateMapperContext.SetPredictiveState(object! value) -> void +Microsoft.AspNetCore.Components.AI.StateMapperContext.SetState(object! value) -> void +Microsoft.AspNetCore.Components.AI.StateMapperContext.UnhandledContents.get -> System.Collections.Generic.IEnumerable! +Microsoft.AspNetCore.Components.AI.StateMapperContext.Update.get -> Microsoft.Extensions.AI.ChatResponseUpdate! +Microsoft.AspNetCore.Components.AI.TableCellNode +Microsoft.AspNetCore.Components.AI.TableCellNode.TableCellNode() -> void +Microsoft.AspNetCore.Components.AI.TableColumnAlignment +Microsoft.AspNetCore.Components.AI.TableColumnAlignment.Center = 2 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment +Microsoft.AspNetCore.Components.AI.TableColumnAlignment.Left = 1 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment +Microsoft.AspNetCore.Components.AI.TableColumnAlignment.None = 0 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment +Microsoft.AspNetCore.Components.AI.TableColumnAlignment.Right = 3 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment +Microsoft.AspNetCore.Components.AI.TableNode +Microsoft.AspNetCore.Components.AI.TableNode.Alignment.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.TableNode.Alignment.set -> void +Microsoft.AspNetCore.Components.AI.TableNode.TableNode() -> void +Microsoft.AspNetCore.Components.AI.TableRowNode +Microsoft.AspNetCore.Components.AI.TableRowNode.TableRowNode() -> void +Microsoft.AspNetCore.Components.AI.TextNode +Microsoft.AspNetCore.Components.AI.TextNode.Text.get -> string! +Microsoft.AspNetCore.Components.AI.TextNode.Text.set -> void +Microsoft.AspNetCore.Components.AI.TextNode.TextNode() -> void +Microsoft.AspNetCore.Components.AI.TextNode.TextNode(string! text) -> void +Microsoft.AspNetCore.Components.AI.ThematicBreakNode +Microsoft.AspNetCore.Components.AI.ThematicBreakNode.ThematicBreakNode() -> void +Microsoft.AspNetCore.Components.AI.ToolBlockAttribute +Microsoft.AspNetCore.Components.AI.ToolBlockAttribute.ToolBlockAttribute(string! toolName) -> void +Microsoft.AspNetCore.Components.AI.ToolBlockAttribute.ToolName.get -> string! +Microsoft.AspNetCore.Components.AI.ToolParameterAttribute +Microsoft.AspNetCore.Components.AI.ToolParameterAttribute.Name.get -> string? +Microsoft.AspNetCore.Components.AI.ToolParameterAttribute.Name.set -> void +Microsoft.AspNetCore.Components.AI.ToolParameterAttribute.ToolParameterAttribute() -> void +Microsoft.AspNetCore.Components.AI.ToolResultAttribute +Microsoft.AspNetCore.Components.AI.ToolResultAttribute.Name.get -> string? +Microsoft.AspNetCore.Components.AI.ToolResultAttribute.Name.set -> void +Microsoft.AspNetCore.Components.AI.ToolResultAttribute.ToolResultAttribute() -> void +Microsoft.AspNetCore.Components.AI.UIAgent +Microsoft.AspNetCore.Components.AI.UIAgent.Dispose() -> void +Microsoft.AspNetCore.Components.AI.UIAgent.RestoreAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!>! +Microsoft.AspNetCore.Components.AI.UIAgent.SendMessageAsync(Microsoft.Extensions.AI.ChatMessage! message, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, Microsoft.Extensions.AI.ChatOptions! chatOptions) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, Microsoft.Extensions.AI.ChatOptions! chatOptions, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action? configure) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action? configure, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) -> void +Microsoft.AspNetCore.Components.AI.UIAgent +Microsoft.AspNetCore.Components.AI.UIAgent.State.get -> Microsoft.AspNetCore.Components.AI.AgentState! +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, Microsoft.Extensions.AI.ChatOptions! chatOptions, TState? initialState = null) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action!>! configure, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory, TState? initialState = null) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action!>! configure, TState? initialState = null) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, TState? initialState = null) -> void +Microsoft.AspNetCore.Components.AI.UIAgentOptions +Microsoft.AspNetCore.Components.AI.UIAgentOptions.AddBlockHandler(Microsoft.AspNetCore.Components.AI.ContentBlockHandler! handler) -> void +Microsoft.AspNetCore.Components.AI.UIAgentOptions.ChatOptions.get -> Microsoft.Extensions.AI.ChatOptions? +Microsoft.AspNetCore.Components.AI.UIAgentOptions.ChatOptions.set -> void +Microsoft.AspNetCore.Components.AI.UIAgentOptions.RegisterUIAction(Microsoft.Extensions.AI.AIFunction! function) -> void +Microsoft.AspNetCore.Components.AI.UIAgentOptions +Microsoft.AspNetCore.Components.AI.UIAgentOptions.State.get -> Microsoft.AspNetCore.Components.AI.AgentState! +Microsoft.AspNetCore.Components.AI.UIAgentOptions.StateMapper.get -> System.Action? +Microsoft.AspNetCore.Components.AI.UIAgentOptions.StateMapper.set -> void +Microsoft.AspNetCore.Components.AI.UIAgentOptions.Thread.get -> Microsoft.AspNetCore.Components.AI.IConversationThread? +Microsoft.AspNetCore.Components.AI.UIAgentOptions.Thread.set -> void +Microsoft.AspNetCore.Components.AI.UIAgentOptions.UIAgentOptions() -> void +Microsoft.AspNetCore.Components.AI.UIActionBlock +Microsoft.AspNetCore.Components.AI.UIActionBlock.Call.get -> Microsoft.Extensions.AI.FunctionCallContent! +Microsoft.AspNetCore.Components.AI.UIActionBlock.GetResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.UIActionBlock.InvokeAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.UIActionBlock.IsComplete.get -> bool +Microsoft.AspNetCore.Components.AI.UIActionBlock.Result.get -> Microsoft.Extensions.AI.FunctionResultContent? +Microsoft.AspNetCore.Components.AI.UIActionBlock.ToolName.get -> string! +abstract Microsoft.AspNetCore.Components.AI.ContentBlockHandler.Handle(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TState state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult +abstract Microsoft.AspNetCore.Components.AI.ActivityHandler.TryCreateBlock(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TBlock! state) -> bool +abstract Microsoft.AspNetCore.Components.AI.ActivityHandler.TryUpdateBlock(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TBlock! state, out bool isCompleted) -> bool +override sealed Microsoft.AspNetCore.Components.AI.ActivityHandler.Handle(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TBlock! state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult +override Microsoft.AspNetCore.Components.AI.AgentBoundary.BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder! builder) -> void +override Microsoft.AspNetCore.Components.AI.AgentBoundary.OnInitialized() -> void +override Microsoft.AspNetCore.Components.AI.AgentBoundary.OnParametersSet() -> void +virtual Microsoft.AspNetCore.Components.AI.ActivityHandler.OnContentUpdated(TBlock! state) -> void +static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Complete() -> Microsoft.AspNetCore.Components.AI.BlockMappingResult +static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Emit(Microsoft.AspNetCore.Components.AI.ContentBlock! block, TState state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult +static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Pass() -> Microsoft.AspNetCore.Components.AI.BlockMappingResult +static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Update(TState state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/wwwroot/ai-chat.css b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/wwwroot/ai-chat.css new file mode 100644 index 000000000000..83877fb4d07a --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/wwwroot/ai-chat.css @@ -0,0 +1,457 @@ +/* ========================================================================== + Microsoft.AspNetCore.Components.AI — Design Tokens & Default Styles + ========================================================================== */ + +/* ---------- Root scope ---------- */ +.sc-ai-root { + /* ---- Typography ---- */ + --sc-ai-font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; + --sc-ai-font-size: 0.9375rem; + --sc-ai-font-size-sm: 0.8125rem; + --sc-ai-font-size-lg: 1.125rem; + --sc-ai-line-height: 1.5; + --sc-ai-font-weight-normal: 400; + --sc-ai-font-weight-medium: 500; + --sc-ai-font-weight-bold: 600; + + /* ---- Colors — Surface & Background ---- */ + --sc-ai-color-bg: #ffffff; + --sc-ai-color-surface: #ffffff; + --sc-ai-color-surface-hover: #f8f9fa; + --sc-ai-color-text: #212529; + --sc-ai-color-text-secondary: #6c757d; + --sc-ai-color-text-on-accent: #ffffff; + --sc-ai-color-accent: #0d6efd; + --sc-ai-color-accent-hover: #0b5ed7; + --sc-ai-color-border: #dee2e6; + --sc-ai-color-success: #198754; + --sc-ai-color-error: #dc3545; + --sc-ai-color-error-bg: #f8d7da; + + /* ---- Colors — Message Bubbles ---- */ + --sc-ai-color-bubble-user: #e9ecef; + --sc-ai-color-bubble-user-text: #212529; + --sc-ai-color-bubble-assistant: transparent; + --sc-ai-color-bubble-assistant-text: #212529; + + /* ---- Layout & Spacing ---- */ + --sc-ai-spacing-xs: 0.25rem; + --sc-ai-spacing-sm: 0.5rem; + --sc-ai-spacing-md: 1rem; + --sc-ai-spacing-lg: 1.5rem; + --sc-ai-max-width: 48rem; + --sc-ai-border-radius-sm: 0.375rem; + --sc-ai-border-radius-lg: 1.5rem; + --sc-ai-input-height: 3rem; + + /* ---- Transitions ---- */ + --sc-ai-transition-fast: 120ms ease; + + /* ---- Focus & States ---- */ + --sc-ai-focus-ring: 0 0 0 2px var(--sc-ai-color-accent); + --sc-ai-disabled-opacity: 0.5; + + /* Apply base typography */ + font-family: var(--sc-ai-font-family); + font-size: var(--sc-ai-font-size); + line-height: var(--sc-ai-line-height); + color: var(--sc-ai-color-text); + box-sizing: border-box; +} + +.sc-ai-root *, +.sc-ai-root *::before, +.sc-ai-root *::after { + box-sizing: inherit; +} + +/* ---------- Buttons ---------- */ +.sc-ai-btn { + display: inline-flex; + align-items: center; + justify-content: center; + gap: var(--sc-ai-spacing-xs); + padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); + border: 1px solid transparent; + border-radius: var(--sc-ai-border-radius-sm); + font-family: inherit; + font-size: var(--sc-ai-font-size-sm); + font-weight: var(--sc-ai-font-weight-medium); + cursor: pointer; + transition: background var(--sc-ai-transition-fast), + color var(--sc-ai-transition-fast), + border-color var(--sc-ai-transition-fast), + opacity var(--sc-ai-transition-fast); + line-height: 1; +} + +.sc-ai-btn:focus-visible { + outline: none; + box-shadow: var(--sc-ai-focus-ring); +} + +.sc-ai-btn:disabled { + opacity: var(--sc-ai-disabled-opacity); + cursor: not-allowed; +} + +.sc-ai-btn--primary { + background: var(--sc-ai-color-accent); + color: var(--sc-ai-color-text-on-accent); +} + +.sc-ai-btn--primary:hover:not(:disabled) { + background: var(--sc-ai-color-accent-hover); +} + +.sc-ai-btn--secondary { + background: var(--sc-ai-color-surface); + color: var(--sc-ai-color-text); + border-color: var(--sc-ai-color-border); +} + +.sc-ai-btn--secondary:hover:not(:disabled) { + background: var(--sc-ai-color-surface-hover); +} + +/* ---------- Message List ---------- */ +.sc-ai-message-list { + display: flex; + flex-direction: column; + gap: var(--sc-ai-spacing-md); + max-width: var(--sc-ai-max-width); + margin: 0 auto; + padding: var(--sc-ai-spacing-lg); + width: 100%; +} + +.sc-ai-message-list__footer { + min-height: var(--sc-ai-spacing-lg); +} + +/* ---------- Turn ---------- */ +.sc-ai-turn { + display: flex; + flex-direction: column; + gap: var(--sc-ai-spacing-sm); +} + +/* ---------- Message Bubbles ---------- */ +.sc-ai-message { + display: flex; +} + +.sc-ai-message--user { + justify-content: flex-end; +} + +.sc-ai-message--assistant { + justify-content: flex-start; +} + +.sc-ai-message__bubble { + max-width: 85%; + padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); + border-radius: var(--sc-ai-border-radius-lg); + word-break: break-word; +} + +.sc-ai-message--user .sc-ai-message__bubble { + background: var(--sc-ai-color-bubble-user); + color: var(--sc-ai-color-bubble-user-text); + border-bottom-right-radius: var(--sc-ai-border-radius-sm); +} + +.sc-ai-message--assistant .sc-ai-message__bubble { + background: var(--sc-ai-color-bubble-assistant); + color: var(--sc-ai-color-bubble-assistant-text); + border-bottom-left-radius: var(--sc-ai-border-radius-sm); +} + +.sc-ai-message__content { + white-space: pre-wrap; +} + +.sc-ai-rich-text__paragraph, +.sc-ai-rich-text__heading, +.sc-ai-rich-text__quote, +.sc-ai-rich-text__list, +.sc-ai-rich-text__code-block, +.sc-ai-rich-text__table-container { + margin-block: 0 0.75em; +} + +.sc-ai-message__content > :last-child { + margin-bottom: 0; +} + +.sc-ai-rich-text__heading { + line-height: 1.25; +} + +.sc-ai-rich-text__inline-code, +.sc-ai-rich-text__code-block { + font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; + background: var(--sc-ai-color-surface-hover); + border-radius: var(--sc-ai-border-radius-sm); +} + +.sc-ai-rich-text__inline-code { + padding: 0.1em 0.3em; +} + +.sc-ai-rich-text__code-block { + overflow-x: auto; + padding: var(--sc-ai-spacing-sm); +} + +.sc-ai-rich-text__quote { + border-left: 0.25rem solid var(--sc-ai-color-border); + padding-left: var(--sc-ai-spacing-md); +} + +.sc-ai-rich-text__list-item > .sc-ai-rich-text__paragraph { + display: inline; +} + +.sc-ai-rich-text__table-container { + overflow-x: auto; +} + +.sc-ai-rich-text__table { + border-collapse: collapse; + width: 100%; +} + +.sc-ai-rich-text__table td { + border: 1px solid var(--sc-ai-color-border); + padding: var(--sc-ai-spacing-xs) var(--sc-ai-spacing-sm); +} + +.sc-ai-rich-text__table-cell--center { + text-align: center; +} + +.sc-ai-rich-text__table-cell--right { + text-align: right; +} + +/* Streaming cursor */ +.sc-ai-message__content--streaming::after { + content: ""; + display: inline-block; + width: 2px; + height: 1em; + background: currentColor; + margin-left: 1px; + vertical-align: text-bottom; + animation: sc-ai-blink 1s step-end infinite; +} + +@keyframes sc-ai-blink { + 0%, 100% { opacity: 1; } + 50% { opacity: 0; } +} + +/* ---------- Approval ---------- */ +.sc-ai-approval { + border: 1px solid var(--sc-ai-color-border); + border-radius: var(--sc-ai-border-radius-sm); + padding: var(--sc-ai-spacing-md); +} + +.sc-ai-approval__header { + margin-bottom: var(--sc-ai-spacing-sm); + font-weight: var(--sc-ai-font-weight-medium); +} + +.sc-ai-approval__tool-name, +.sc-ai-approval__status { + font-size: var(--sc-ai-font-size-sm); +} + +.sc-ai-approval__tool-name { + color: var(--sc-ai-color-text-secondary); + margin-bottom: var(--sc-ai-spacing-sm); +} + +.sc-ai-approval__arguments { + overflow-x: auto; + padding: var(--sc-ai-spacing-sm); + background: var(--sc-ai-color-surface-hover); + border-radius: var(--sc-ai-border-radius-sm); +} + +.sc-ai-approval__actions { + display: flex; + gap: var(--sc-ai-spacing-sm); +} + +.sc-ai-approval__status { + font-weight: var(--sc-ai-font-weight-medium); +} + +.sc-ai-approval__status--approved { + color: var(--sc-ai-color-success); +} + +.sc-ai-approval__status--rejected { + color: var(--sc-ai-color-error); +} + +/* ---------- Typing Indicator ---------- */ +.sc-ai-typing { + display: inline-flex; + align-items: center; + gap: 4px; + padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); +} + +.sc-ai-typing__dot { + width: 6px; + height: 6px; + border-radius: 50%; + background: var(--sc-ai-color-text-secondary); + animation: sc-ai-bounce 1.4s ease-in-out infinite; +} + +.sc-ai-typing__dot:nth-child(2) { + animation-delay: 0.2s; +} + +.sc-ai-typing__dot:nth-child(3) { + animation-delay: 0.4s; +} + +@keyframes sc-ai-bounce { + 0%, 80%, 100% { transform: translateY(0); } + 40% { transform: translateY(-6px); } +} + +/* ---------- Error Banner ---------- */ +.sc-ai-error { + display: flex; + align-items: center; + gap: var(--sc-ai-spacing-sm); + padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); + background: var(--sc-ai-color-error-bg); + color: var(--sc-ai-color-error); + border-radius: var(--sc-ai-border-radius-sm); + font-size: var(--sc-ai-font-size-sm); +} + +.sc-ai-error__message { + flex: 1; +} + +/* ---------- Message Input ---------- */ +.sc-ai-input { + display: flex; + align-items: flex-end; + gap: var(--sc-ai-spacing-sm); + padding: var(--sc-ai-spacing-sm); + background: var(--sc-ai-color-surface); + border: 1px solid var(--sc-ai-color-border); + border-radius: var(--sc-ai-border-radius-lg); + transition: border-color var(--sc-ai-transition-fast); +} + +.sc-ai-input:focus-within { + border-color: var(--sc-ai-color-accent); +} + +.sc-ai-input__body { + flex: 1; + display: flex; + flex-direction: column; +} + +.sc-ai-input__textarea { + flex: 1; + border: none; + outline: none; + resize: none; + font-family: inherit; + font-size: inherit; + line-height: var(--sc-ai-line-height); + color: var(--sc-ai-color-text); + background: transparent; + min-height: var(--sc-ai-input-height); + max-height: 10rem; + padding: var(--sc-ai-spacing-sm); +} + +.sc-ai-input__textarea::placeholder { + color: var(--sc-ai-color-text-secondary); +} + +.sc-ai-input__textarea:disabled { + opacity: var(--sc-ai-disabled-opacity); +} + +.sc-ai-input__send { + width: 2.25rem; + height: 2.25rem; + padding: 0; + border: none; + border-radius: 50%; + background: var(--sc-ai-color-accent); + color: var(--sc-ai-color-text-on-accent); + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + flex-shrink: 0; + transition: background var(--sc-ai-transition-fast), + opacity var(--sc-ai-transition-fast); +} + +.sc-ai-input__send:hover:not(:disabled) { + background: var(--sc-ai-color-accent-hover); +} + +.sc-ai-input__send:focus-visible { + outline: none; + box-shadow: var(--sc-ai-focus-ring); +} + +.sc-ai-input__send:disabled { + opacity: var(--sc-ai-disabled-opacity); + cursor: not-allowed; +} + +.sc-ai-input__send svg { + width: 1.125rem; + height: 1.125rem; +} + +/* ---------- Chat Page Shell ---------- */ +.sc-ai-chat-page { + display: flex; + flex-direction: column; + height: 100vh; + height: 100dvh; + background: var(--sc-ai-color-bg); +} + +.sc-ai-chat-page__header { + flex-shrink: 0; +} + +.sc-ai-chat-page__body { + flex: 1; + overflow-y: auto; + -webkit-overflow-scrolling: touch; +} + +.sc-ai-chat-page__footer { + flex-shrink: 0; + border-top: 1px solid var(--sc-ai-color-border); + background: var(--sc-ai-color-surface); + padding: var(--sc-ai-spacing-md); +} + +.sc-ai-chat-page__input-container { + max-width: var(--sc-ai-max-width); + margin: 0 auto; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Engine/Conversation.mjs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Engine/Conversation.mjs new file mode 100644 index 000000000000..d94121c7f80b --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Engine/Conversation.mjs @@ -0,0 +1,40 @@ +export class Conversation +{ + status = "Idle"; + observers = []; + + constructor(log) + { + this.log = log; + } + + onStatusChanged(observer) + { + this.observers.push(observer); + } + + process(work) + { + this.status = "Running"; + try + { + work(); + this.status = "Idle"; + } + catch (processingError) + { + try + { + this.log(processingError); + this.status = "Error"; + for (const observer of this.observers) + { + observer(this.status); + } + } + catch + { + } + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolBlockAttribute.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolBlockAttribute.cs new file mode 100644 index 000000000000..aace44de33cc --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolBlockAttribute.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Associates a typed with a tool name. +/// +/// +/// +/// [ToolBlock("get_weather")] +/// public partial class WeatherBlock : FunctionInvocationContentBlock; +/// +/// +[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] +public sealed class ToolBlockAttribute : Attribute +{ + /// + /// Initializes a new instance of . + /// + /// The function name emitted by the model. + public ToolBlockAttribute(string toolName) + { + ArgumentException.ThrowIfNullOrEmpty(toolName); + ToolName = toolName; + } + + /// + /// Gets the function name associated with the block. + /// + public string ToolName { get; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolParameterAttribute.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolParameterAttribute.cs new file mode 100644 index 000000000000..945f0da645b7 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolParameterAttribute.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Populates a typed block property from a function-call argument. +/// +[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] +public sealed class ToolParameterAttribute : Attribute +{ + /// + /// Gets or sets the function argument name. The property name is used when omitted. + /// + public string? Name { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolResultAttribute.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolResultAttribute.cs new file mode 100644 index 000000000000..0a1534c83e20 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolResultAttribute.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Populates a typed block property from a function result. +/// +[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] +public sealed class ToolResultAttribute : Attribute +{ + /// + /// Gets or sets the result property name. The block property name is used when omitted. + /// + public string? Name { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ActivityContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ActivityContentBlock.cs new file mode 100644 index 000000000000..eb271897f57f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ActivityContentBlock.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text.Json; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents activity or progress content that can change while a response streams. +/// +public class ActivityContentBlock : ContentBlock +{ + /// + /// Gets or sets the application-defined activity type. + /// + public string ActivityType { get; set; } = string.Empty; + + /// + /// Gets or sets the current activity payload. + /// + public JsonElement Content { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ApprovalStatus.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ApprovalStatus.cs new file mode 100644 index 000000000000..52fbc2227e09 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ApprovalStatus.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Describes the response to a function approval request. +/// +public enum ApprovalStatus +{ + /// + /// The function is waiting for a response. + /// + Pending, + + /// + /// The function was approved. + /// + Approved, + + /// + /// The function was rejected. + /// + Rejected, +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/BlockLifecycleState.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/BlockLifecycleState.cs new file mode 100644 index 000000000000..5fed8b70873c --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/BlockLifecycleState.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Describes where a is in its streaming lifecycle. +/// +public enum BlockLifecycleState +{ + /// + /// The block has been created but has not been emitted to the conversation yet. + /// + Pending, + + /// + /// The block is part of the conversation and can still receive updates from the model stream. + /// + Active, + + /// + /// The block is complete and will not receive further updates. + /// + Inactive, +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs new file mode 100644 index 000000000000..d0fccaa4f9bb --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Base class for a unit of conversation content that the UI renders and that can be +/// updated while the model response is still streaming. +/// +/// +/// Subscribe to updates while a block streams: +/// +/// using var subscription = block.OnChanged(() => StateHasChanged()); +/// +/// +public abstract class ContentBlock +{ + private readonly List _callbacks = new(); + + /// + /// Gets the identifier of this block. Blocks produced by the same model message share the same identifier. + /// + public string Id { get; internal set; } = string.Empty; + + /// + /// Gets the current lifecycle state of this block. + /// + public BlockLifecycleState LifecycleState { get; internal set; } + + /// + /// Gets the role of the conversation participant that produced this block. + /// + public ChatRole? Role { get; internal set; } + + /// + /// Gets the name of the author that produced this block, when the model provides one. + /// + public string? AuthorName { get; internal set; } + + /// + /// Registers a callback that runs whenever this block changes. + /// + /// The callback to invoke when the block changes. + /// A subscription that removes the callback when disposed. + public ContentBlockChangedSubscription OnChanged(Action callback) + { + ArgumentNullException.ThrowIfNull(callback); + _callbacks.Add(callback); + return new ContentBlockChangedSubscription(this, callback); + } + + /// + /// Notifies subscribers that this block changed. + /// + protected void NotifyChanged() + { + // Snapshot the callbacks to allow safe removal during iteration + var snapshot = _callbacks.ToArray(); + for (var i = 0; i < snapshot.Length; i++) + { + snapshot[i](); + } + } + + internal void InvokeNotifyChanged() => NotifyChanged(); + + internal void RemoveCallback(Action callback) + { + _callbacks.Remove(callback); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs new file mode 100644 index 000000000000..1404a6957887 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a subscription to . +/// Disposing the subscription removes the callback from the block. +/// +public readonly struct ContentBlockChangedSubscription : IDisposable +{ + private readonly ContentBlock _owner; + private readonly Action _callback; + + internal ContentBlockChangedSubscription(ContentBlock owner, Action callback) + { + _owner = owner; + _callback = callback; + } + + /// + /// Removes the callback from the block it was registered on. + /// + public void Dispose() + { + _owner?.RemoveCallback(_callback); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs new file mode 100644 index 000000000000..e057416e7f06 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs @@ -0,0 +1,123 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a function invocation that requires approval before the conversation can continue. +/// +/// +/// +/// if (block.Status == ApprovalStatus.Pending) +/// { +/// block.Approve(); +/// } +/// +/// +public class FunctionApprovalBlock : ContentBlock, IInteractiveBlock +{ + private readonly TaskCompletionSource _resultSource = + new(TaskCreationOptions.RunContinuationsAsynchronously); + private readonly object _responseLock = new(); + + internal FunctionApprovalBlock( + ContentBlock innerBlock, + ToolApprovalRequestContent request) + { + ArgumentNullException.ThrowIfNull(innerBlock); + InnerBlock = innerBlock; + ApprovalRequest = request; + } + + /// + /// Gets the wrapped function invocation block. + /// + public ContentBlock InnerBlock { get; } + + /// + /// Gets the function call represented by this block. + /// + public FunctionCallContent? Call => InnerBlock switch + { + FunctionInvocationContentBlock invocation => invocation.Call, + UIActionBlock action => action.Call, + _ => null, + }; + + /// + /// Gets the function result represented by this block. + /// + public FunctionResultContent? Result => InnerBlock switch + { + FunctionInvocationContentBlock invocation => invocation.Result, + UIActionBlock action => action.Result, + _ => null, + }; + + /// + /// Gets the name of the invoked tool. + /// + public string? ToolName => Call?.Name; + + /// + /// Gets the arguments supplied to the tool. + /// + public IDictionary? Arguments => Call?.Arguments; + + /// + /// Gets a value indicating whether the server produced a result. + /// + public bool HasResult => Result is not null; + + /// + /// Gets the current approval status. + /// + public ApprovalStatus Status { get; private set; } + + /// + /// Gets the approval request received from the chat client. + /// + public ToolApprovalRequestContent ApprovalRequest { get; } + + /// + /// Approves the function invocation. Only the first response is applied. + /// + public void Approve() + { + Respond(ApprovalStatus.Approved, reason: null); + } + + /// + /// Rejects the function invocation. Only the first response is applied. + /// + /// An optional explanation for the rejection. + public void Reject(string? reason = null) + { + Respond(ApprovalStatus.Rejected, reason); + } + + /// + public Task GetResultAsync(CancellationToken cancellationToken = default) + => _resultSource.Task.WaitAsync(cancellationToken); + + private void Respond(ApprovalStatus status, string? reason) + { + lock (_responseLock) + { + if (Status != ApprovalStatus.Pending) + { + return; + } + + Status = status; + var response = ApprovalRequest.CreateResponse( + approved: status == ApprovalStatus.Approved, + reason); + _resultSource.SetResult(response); + } + + NotifyChanged(); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs new file mode 100644 index 000000000000..f37022dfff01 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a server-side function invocation and its eventual result. +/// +/// +/// Custom content blocks that represent function invocations should derive from this type +/// and populate . This keeps the call, tool name, and arguments available +/// when other features, such as function approval, wrap the custom block. +/// +/// +/// +/// public sealed class WeatherContentBlock : FunctionInvocationContentBlock +/// { +/// public string? Location { get; set; } +/// } +/// +/// +public class FunctionInvocationContentBlock : ContentBlock +{ + private FunctionCallContent? _call; + + /// + /// Gets or sets the function call represented by this block. + /// + public FunctionCallContent? Call + { + get => _call; + set + { + _call = value; + if (value is not null) + { + Id = value.CallId; + } + } + } + + /// + /// Gets or sets the function result paired with . + /// + public FunctionResultContent? Result { get; set; } + + /// + /// Gets the name of the invoked tool. + /// + public string? ToolName => Call?.Name; + + /// + /// Gets the arguments supplied to the tool. + /// + public IDictionary? Arguments => Call?.Arguments; + + /// + /// Gets a value indicating whether the server produced a result. + /// + public bool HasResult => Result is not null; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs new file mode 100644 index 000000000000..2a67244ace0c --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a content block that pauses a conversation until the user supplies a result. +/// +public interface IInteractiveBlock +{ + /// + /// Waits for the user-supplied result. + /// + /// A token that cancels the wait. + /// The content used to continue the conversation. + Task GetResultAsync(CancellationToken cancellationToken = default); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichContentBlock.cs new file mode 100644 index 000000000000..59887909b337 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichContentBlock.cs @@ -0,0 +1,45 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// A block of conversational text. Text arrives in fragments while the model streams, +/// so the block accumulates the fragments and exposes both the raw text and the +/// paragraphs derived from it. +/// +public class RichContentBlock : ContentBlock +{ + private readonly List _segments = new(); + private string? _cachedText; + + /// + /// Gets the concatenation of every text fragment received so far. + /// + public string RawText => _cachedText ??= string.Concat(_segments); + + /// + /// Gets the structured representation of . + /// + public IReadOnlyList Content { get; internal set; } = Array.Empty(); + + /// + /// Appends a text fragment to this block. + /// + /// The fragment to append. + public void AppendText(string text) + { + ArgumentNullException.ThrowIfNull(text); + + _segments.Add(text); + _cachedText = null; + } + + internal void ReplaceContent(string text, IReadOnlyList content) + { + _segments.Clear(); + _segments.Add(text); + _cachedText = text; + Content = content; + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs new file mode 100644 index 000000000000..d92dfc5066a8 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a block quotation. +/// +public class BlockQuoteNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs new file mode 100644 index 000000000000..34f5f5a674ea --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a block of code. +/// +public class CodeBlockNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public CodeBlockNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The code. + /// The optional language identifier. + public CodeBlockNode(string code, string? language = null) + { + ArgumentNullException.ThrowIfNull(code); + Code = code; + Language = language; + } + + /// + /// Gets or sets the language identifier. + /// + public string? Language { get; set; } + + /// + /// Gets or sets the code. + /// + public string Code { get; set; } = string.Empty; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs new file mode 100644 index 000000000000..a3b9507608b6 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a link or image reference definition. +/// +public class DefinitionNode : RichTextNode +{ + /// + /// Gets or sets the reference label. + /// + public string Label { get; set; } = string.Empty; + + /// + /// Gets or sets the target URL. + /// + public string Url { get; set; } = string.Empty; + + /// + /// Gets or sets the optional title. + /// + public string? Title { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs new file mode 100644 index 000000000000..300932d81b29 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents emphasized text. +/// +public class EmphasisNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs new file mode 100644 index 000000000000..7f12bf111a4d --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a footnote definition. +/// +/// +/// A mapper can use this node for labeled footnote content, such as content represented by +/// a Markdig footnote container. The core library does not parse or resolve footnote syntax. +/// +public class FootnoteDefinitionNode : RichTextNode +{ + /// + /// Gets or sets the footnote label. + /// + public string Label { get; set; } = string.Empty; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs new file mode 100644 index 000000000000..97d4926e368c --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents footnote content supplied by an application's rich-text mapper. +/// +/// +/// Parsers model footnotes differently. For example, Markdig exposes footnote containers, +/// links, and an end-of-document footnote group. A mapper can project those parser-specific +/// objects into the footnote presentation nodes without introducing a parser dependency. +/// +public class FootnoteNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs new file mode 100644 index 000000000000..9c67171555fb --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a footnote reference. +/// +/// +/// A mapper can use this node for a reference such as a Markdig footnote link. The core +/// library does not parse the reference or resolve its label. +/// +public class FootnoteReferenceNode : RichTextNode +{ + /// + /// Gets or sets the footnote label. + /// + public string Label { get; set; } = string.Empty; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HeadingNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HeadingNode.cs new file mode 100644 index 000000000000..bc36c95d3968 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HeadingNode.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a heading. +/// +public class HeadingNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public HeadingNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The heading level. + public HeadingNode(int level) + { + Level = level; + } + + /// + /// Gets or sets the heading level. + /// + public int Level { get; set; } = 1; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HtmlNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HtmlNode.cs new file mode 100644 index 000000000000..8358abe5f750 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HtmlNode.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents HTML source. The default renderer displays the source as text. +/// +public class HtmlNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public HtmlNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The HTML source. + public HtmlNode(string value) + { + ArgumentNullException.ThrowIfNull(value); + Value = value; + } + + /// + /// Gets or sets the HTML source. + /// + public string Value { get; set; } = string.Empty; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageNode.cs new file mode 100644 index 000000000000..e1838c7d1fca --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageNode.cs @@ -0,0 +1,46 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents an image. +/// +public class ImageNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public ImageNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The image URL. + /// The alternative text. + /// The optional title. + public ImageNode(string url, string? alt = null, string? title = null) + { + ArgumentNullException.ThrowIfNull(url); + Url = url; + Alt = alt; + Title = title; + } + + /// + /// Gets or sets the image URL. + /// + public string Url { get; set; } = string.Empty; + + /// + /// Gets or sets the alternative text. + /// + public string? Alt { get; set; } + + /// + /// Gets or sets the optional title. + /// + public string? Title { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs new file mode 100644 index 000000000000..75b3c2af11aa --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a reference-style image. +/// +public class ImageReferenceNode : RichTextNode +{ + /// + /// Gets or sets the reference label. + /// + public string Label { get; set; } = string.Empty; + + /// + /// Gets or sets the alternative text. + /// + public string? Alt { get; set; } + + /// + /// Gets or sets the reference syntax. + /// + public ReferenceKind ReferenceKind { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs new file mode 100644 index 000000000000..4be230f1651d --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents inline code. +/// +public class InlineCodeNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public InlineCodeNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The code. + public InlineCodeNode(string code) + { + ArgumentNullException.ThrowIfNull(code); + Code = code; + } + + /// + /// Gets or sets the code. + /// + public string Code { get; set; } = string.Empty; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs new file mode 100644 index 000000000000..3d62aabab60f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a forced visual line break. +/// +/// +/// This node does not encode a parser-specific soft or hard line-ending distinction. A +/// mapper from Markdig or any other parser decides whether a source line ending becomes +/// whitespace, text, or a . +/// +public class LineBreakNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkNode.cs new file mode 100644 index 000000000000..8542750d2168 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkNode.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a hyperlink. +/// +public class LinkNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public LinkNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The link URL. + /// The optional title. + public LinkNode(string url, string? title = null) + { + ArgumentNullException.ThrowIfNull(url); + Url = url; + Title = title; + } + + /// + /// Gets or sets the link URL. + /// + public string Url { get; set; } = string.Empty; + + /// + /// Gets or sets the optional title. + /// + public string? Title { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs new file mode 100644 index 000000000000..16a71493402f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a reference-style link. +/// +public class LinkReferenceNode : RichTextNode +{ + /// + /// Gets or sets the reference label. + /// + public string Label { get; set; } = string.Empty; + + /// + /// Gets or sets the reference syntax. + /// + public ReferenceKind ReferenceKind { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListItemNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListItemNode.cs new file mode 100644 index 000000000000..a85200b58442 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListItemNode.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a list item. +/// +public class ListItemNode : RichTextNode +{ + /// + /// Gets or sets the checked state when the item is a task. + /// + public bool? Checked { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListNode.cs new file mode 100644 index 000000000000..6c7d263e6143 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListNode.cs @@ -0,0 +1,38 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents an ordered or unordered list. +/// +public class ListNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public ListNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// Whether the list is ordered. + /// The optional starting number. + public ListNode(bool ordered, int? start = null) + { + Ordered = ordered; + Start = start; + } + + /// + /// Gets or sets a value indicating whether the list is ordered. + /// + public bool Ordered { get; set; } + + /// + /// Gets or sets the starting number of an ordered list. + /// + public int? Start { get; set; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs new file mode 100644 index 000000000000..7b105148c32d --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a paragraph. +/// +public class ParagraphNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs new file mode 100644 index 000000000000..16486d946fa2 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs @@ -0,0 +1,25 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Describes the syntax used by a reference. +/// +public enum ReferenceKind +{ + /// + /// A shortcut reference. + /// + Shortcut, + + /// + /// A collapsed reference. + /// + Collapsed, + + /// + /// A full reference. + /// + Full, +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextContent.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextContent.cs new file mode 100644 index 000000000000..ea65d1dd4748 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextContent.cs @@ -0,0 +1,45 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a complete snapshot of structured text in a streaming chat response. +/// +/// +/// Providers can emit a new snapshot as text streams. The block mapping pipeline replaces +/// the previous snapshot without exposing a partially mutated tree to renderers. +/// The constructor copies the top-level node list, but the nodes themselves remain shared. +/// Callers must not mutate nodes after publishing the content. +/// +public class RichTextContent : AIContent +{ + /// + /// Initializes a new instance of . + /// + /// The plain-text representation of the content. + /// + /// The structured nodes that represent . The constructor copies this + /// list but does not clone the nodes. + /// + public RichTextContent(string text, IReadOnlyList nodes) + { + ArgumentNullException.ThrowIfNull(text); + ArgumentNullException.ThrowIfNull(nodes); + + Text = text; + Nodes = [.. nodes]; + } + + /// + /// Gets the plain-text representation of the content. + /// + public string Text { get; } + + /// + /// Gets the structured nodes that represent . + /// + public IReadOnlyList Nodes { get; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextNode.cs new file mode 100644 index 000000000000..7c66c897d9fa --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextNode.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a node in structured conversational text. +/// +/// +/// This hierarchy describes presentation semantics and does not prescribe a source format +/// or parser. Applications can map output from Markdig or any other parser into these nodes. +/// The mapper is responsible for interpreting source syntax, resolving references, and +/// deciding which presentation node represents each source construct. +/// +public abstract class RichTextNode +{ + private List? _children; + + /// + /// Gets the child nodes. + /// + public IReadOnlyList Children => + _children ?? (IReadOnlyList)Array.Empty(); + + /// + /// Adds a child node. + /// + /// The child to add. + public void AddChild(RichTextNode child) + { + ArgumentNullException.ThrowIfNull(child); + + _children ??= new(); + _children.Add(child); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs new file mode 100644 index 000000000000..adac69763c9f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents struck-through text. +/// +public class StrikethroughNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrongNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrongNode.cs new file mode 100644 index 000000000000..b2c12926d787 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrongNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents strongly emphasized text. +/// +public class StrongNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableCellNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableCellNode.cs new file mode 100644 index 000000000000..79e42f2743d5 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableCellNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a table cell. +/// +public class TableCellNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs new file mode 100644 index 000000000000..e5bcad07eff7 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Describes the alignment of a table column. +/// +public enum TableColumnAlignment +{ + /// + /// No alignment was specified. + /// + None, + + /// + /// Left-aligned. + /// + Left, + + /// + /// Center-aligned. + /// + Center, + + /// + /// Right-aligned. + /// + Right, +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableNode.cs new file mode 100644 index 000000000000..e819464fe62f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableNode.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a table. +/// +public class TableNode : RichTextNode +{ + /// + /// Gets or sets each column's alignment. + /// + public IReadOnlyList Alignment { get; set; } = + Array.Empty(); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableRowNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableRowNode.cs new file mode 100644 index 000000000000..e09ce01bb34f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableRowNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a table row. +/// +public class TableRowNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TextNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TextNode.cs new file mode 100644 index 000000000000..958be5d930d2 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TextNode.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents plain text. +/// +public class TextNode : RichTextNode +{ + /// + /// Initializes a new instance of . + /// + public TextNode() + { + } + + /// + /// Initializes a new instance of . + /// + /// The text. + public TextNode(string text) + { + ArgumentNullException.ThrowIfNull(text); + Text = text; + } + + /// + /// Gets or sets the text. + /// + public string Text { get; set; } = string.Empty; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs new file mode 100644 index 000000000000..e465c724a625 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a thematic break. +/// +public class ThematicBreakNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/UIActionBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/UIActionBlock.cs new file mode 100644 index 000000000000..6389624516e7 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/UIActionBlock.cs @@ -0,0 +1,101 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a function call that must execute in the UI before the conversation can continue. +/// +/// +/// Register the corresponding function with +/// . Renderers can call +/// to execute it in the current UI circuit. +/// +/// +/// +/// <BlockRenderer TBlock="UIActionBlock" Context="action"> +/// <button @onclick="() => action.InvokeAsync()">Run</button> +/// </BlockRenderer> +/// +/// +public class UIActionBlock : ContentBlock, IInteractiveBlock +{ + private readonly AIFunction _function; + private readonly TaskCompletionSource _resultSource = + new(TaskCreationOptions.RunContinuationsAsynchronously); + private readonly object _invocationLock = new(); + private Task? _invocation; + + internal UIActionBlock(AIFunction function, FunctionCallContent call) + { + _function = function; + Call = call; + } + + /// + /// Gets the function call requested by the model. + /// + public FunctionCallContent Call { get; } + + /// + /// Gets the registered UI action name. + /// + public string ToolName => Call.Name; + + /// + /// Gets the function result after the action completes. + /// + public FunctionResultContent? Result { get; private set; } + + /// + /// Gets a value indicating whether the action completed successfully. + /// + public bool IsComplete => Result is not null; + + /// + /// Executes the registered function once using the arguments supplied by the model. + /// + /// + /// A token that cancels the action when this call starts it. Subsequent calls return the + /// existing invocation task and do not replace its cancellation token. + /// + /// A task that completes when the action has finished. + public Task InvokeAsync(CancellationToken cancellationToken = default) + { + lock (_invocationLock) + { + _invocation ??= InvokeCoreAsync(cancellationToken); + return _invocation; + } + } + + /// + public Task GetResultAsync(CancellationToken cancellationToken = default) + => _resultSource.Task.WaitAsync(cancellationToken); + + private async Task InvokeCoreAsync(CancellationToken cancellationToken) + { + try + { + var arguments = Call.Arguments is not null + ? new AIFunctionArguments(Call.Arguments) + : null; + var result = await _function.InvokeAsync(arguments, cancellationToken); + Result = new FunctionResultContent(Call.CallId ?? Id, result); + NotifyChanged(); + _resultSource.TrySetResult(Result); + } + catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) + { + _resultSource.TrySetCanceled(cancellationToken); + throw; + } + catch (Exception exception) + { + _resultSource.TrySetException(exception); + throw; + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/AgentBoundary.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/AgentBoundary.cs new file mode 100644 index 000000000000..11712b97b29f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/AgentBoundary.cs @@ -0,0 +1,78 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.Rendering; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Creates the for a and cascades it to the +/// chat components underneath it. +/// +public class AgentBoundary : ComponentBase, IDisposable +{ + private AgentContext _context = default!; + private UIAgent _currentAgent = default!; + + /// + /// Gets or sets the agent that drives the conversation. + /// + [Parameter, EditorRequired] + public UIAgent Agent { get; set; } = default!; + + /// + /// Gets or sets the content rendered inside the boundary. + /// + [Parameter] + public RenderFragment? ChildContent { get; set; } + + /// + protected override void OnInitialized() + { + _currentAgent = Agent; + _context = new AgentContext(Agent); + } + + /// + protected override void OnParametersSet() + { + if (!ReferenceEquals(Agent, _currentAgent)) + { + // Agent changed — tear down the old context and create a new one. + // BuildRenderTree uses OpenRegion keyed on the context, so Blazor will + // also tear down and recreate all descendant components. + _context?.Dispose(); + _currentAgent = Agent; + _context = new AgentContext(Agent); + } + } + + /// + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + // If Agent changes, the region key changes, causing Blazor to tear down + // and recreate all descendants. This is the same trick EditForm uses with + // EditContext. It lets us safely use IsFixed=true on the CascadingValue. + builder.OpenRegion(_context.GetHashCode()); + + builder.OpenComponent>(0); + builder.AddComponentParameter(1, "Value", _context); + builder.AddComponentParameter(2, "IsFixed", true); + builder.AddComponentParameter(3, "ChildContent", (RenderFragment)(inner => + { + inner.AddContent(10, ChildContent); + })); + builder.CloseComponent(); + + builder.CloseRegion(); + } + + /// + /// Disposes the owned by this boundary. + /// + public void Dispose() + { + _context?.Dispose(); + GC.SuppressFinalize(this); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockContainer.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockContainer.cs new file mode 100644 index 000000000000..f26a04e57ab0 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockContainer.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +// Renders a single block and re-renders the message list when the block changes. +internal class BlockContainer : IDisposable +{ + private readonly ContentBlock _block; + private readonly MessageListContext _listContext; + private readonly ContentBlockChangedSubscription _changedSub; + + internal BlockContainer(ContentBlock block, MessageListContext listContext, Action requestRender) + { + _block = block; + _listContext = listContext; + _changedSub = block.OnChanged(requestRender); + } + + internal void RenderTo(Rendering.RenderTreeBuilder builder, int seq) + { + var fragment = _listContext.RenderBlock(_block); + builder.AddContent(seq, fragment); + } + + public void Dispose() + { + _changedSub.Dispose(); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRenderer.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRenderer.cs new file mode 100644 index 000000000000..7a3492a7255e --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRenderer.cs @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Registers custom markup for a block type inside a . The most +/// recently registered renderer that matches a block wins. +/// +/// The block type this renderer handles. +/// +/// +/// <MessageList> +/// <BlockRenderer TBlock="RichContentBlock" Context="block"> +/// <p>@block.RawText</p> +/// </BlockRenderer> +/// </MessageList> +/// +/// +public class BlockRenderer : IComponent, IDisposable where TBlock : ContentBlock +{ + private RenderHandle _renderHandle; + private bool _initialized; + private BlockRendererRegistration? _registration; + + /// + /// Gets or sets the message list this renderer registers with. + /// + [CascadingParameter] + public MessageListContext ListContext { get; set; } = default!; + + /// + /// Gets or sets the markup rendered for a matching block. + /// + [Parameter] + public RenderFragment? ChildContent { get; set; } + + /// + /// Gets or sets a predicate that narrows which blocks this renderer handles. + /// + [Parameter] + public Func? When { get; set; } + + void IComponent.Attach(RenderHandle renderHandle) + { + _renderHandle = renderHandle; + } + + Task IComponent.SetParametersAsync(ParameterView parameters) + { + parameters.SetParameterProperties(this); + + if (ListContext is null) + { + throw new InvalidOperationException( + "BlockRenderer must be placed inside a MessageList."); + } + + if (ChildContent is null) + { + throw new InvalidOperationException("BlockRenderer requires child content."); + } + + if (!_initialized) + { + _initialized = true; + + _registration = new BlockRendererRegistration + { + BlockType = typeof(TBlock), + // Capture 'this' so the lambda reads the latest When/ChildContent at invocation time + When = block => block is TBlock typed && (When is null || When(typed)), + Render = block => ChildContent((TBlock)block) + }; + + ListContext.AddRegistration(_registration); + } + + return Task.CompletedTask; + } + + /// + /// Removes this renderer from the message list. + /// + public void Dispose() + { + if (_registration is not null) + { + ListContext?.RemoveRegistration(_registration); + } + + GC.SuppressFinalize(this); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRendererRegistration.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRendererRegistration.cs new file mode 100644 index 000000000000..b876c68cb91f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRendererRegistration.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +internal class BlockRendererRegistration +{ + public required Type BlockType { get; init; } + + public Func? When { get; init; } + + public required Func Render { get; init; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ChatPage.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ChatPage.cs new file mode 100644 index 000000000000..e40835a996e1 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ChatPage.cs @@ -0,0 +1,128 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.Rendering; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Full page chat shell: an around a scrollable +/// and a . +/// +/// +/// +/// <ChatPage Agent="agent" Placeholder="Ask me anything" /> +/// +/// +public sealed class ChatPage : ComponentBase +{ + /// + /// Gets or sets the agent that drives the conversation. + /// + [Parameter, EditorRequired] + public UIAgent Agent { get; set; } = default!; + + /// + /// Gets or sets the content rendered above the conversation. + /// + [Parameter] + public RenderFragment? Header { get; set; } + + /// + /// Gets or sets the content rendered when the conversation is empty. + /// + [Parameter] + public RenderFragment? WelcomeContent { get; set; } + + /// + /// Gets or sets the content rendered inside the message list, typically + /// registrations. + /// + [Parameter] + public RenderFragment? MessageListContent { get; set; } + + /// + /// Gets or sets the placeholder text of the message input. + /// + [Parameter] + public string? Placeholder { get; set; } + + /// + /// Gets or sets the content rendered before the message input text area. + /// + [Parameter] + public RenderFragment? InputLeadingActions { get; set; } + + /// + /// Gets or sets the content rendered after the message input text area. + /// + [Parameter] + public RenderFragment? InputTrailingActions { get; set; } + + /// + /// Gets or sets additional attributes applied to the root element. + /// + [Parameter(CaptureUnmatchedValues = true)] + public Dictionary? AdditionalAttributes { get; set; } + + /// + protected override void BuildRenderTree(RenderTreeBuilder builder) + { + builder.OpenElement(0, "div"); + builder.AddMultipleAttributes(1, AdditionalAttributes); + builder.AddAttribute(2, "class", CssClass()); + + if (Header is not null) + { + builder.OpenElement(10, "div"); + builder.AddAttribute(11, "class", "sc-ai-chat-page__header"); + builder.AddContent(12, Header); + builder.CloseElement(); + } + + builder.OpenComponent(20); + builder.AddComponentParameter(21, "Agent", Agent); + builder.AddComponentParameter(22, "ChildContent", (RenderFragment)(inner => + { + // Body (scrollable area) + inner.OpenElement(30, "div"); + inner.AddAttribute(31, "class", "sc-ai-chat-page__body"); + + inner.OpenComponent(32); + inner.AddComponentParameter(33, "ChildContent", MessageListContent); + inner.AddComponentParameter(34, "EmptyContent", WelcomeContent); + inner.CloseComponent(); // MessageList + + inner.CloseElement(); // body + + // Footer (input area) + inner.OpenElement(50, "div"); + inner.AddAttribute(51, "class", "sc-ai-chat-page__footer"); + inner.OpenElement(52, "div"); + inner.AddAttribute(53, "class", "sc-ai-chat-page__input-container"); + + inner.OpenComponent(54); + inner.AddComponentParameter(55, "Placeholder", Placeholder); + inner.AddComponentParameter(56, "LeadingActions", InputLeadingActions); + inner.AddComponentParameter(57, "TrailingActions", InputTrailingActions); + inner.CloseComponent(); // MessageInput + + inner.CloseElement(); // input-container + inner.CloseElement(); // footer + })); + builder.CloseComponent(); // AgentBoundary + + builder.CloseElement(); // root div + } + + private string CssClass() + { + var css = "sc-ai-root sc-ai-chat-page"; + if (AdditionalAttributes?.TryGetValue("class", out var existing) == true && existing is string s) + { + css = $"{css} {s}"; + } + + return css; + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ConversationTurnRenderer.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ConversationTurnRenderer.cs new file mode 100644 index 000000000000..a3666f9aef00 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ConversationTurnRenderer.cs @@ -0,0 +1,74 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.Rendering; + +namespace Microsoft.AspNetCore.Components.AI; + +// Renders one conversation turn: its request blocks followed by its response blocks. +internal class ConversationTurnRenderer : IDisposable +{ + private readonly ConversationTurn _turn; + private readonly MessageListContext _listContext; + private readonly Action _requestRender; + private readonly List _blockContainers = new(); + private readonly IDisposable? _blockAddedSub; + + internal ConversationTurnRenderer( + AgentContext agentContext, + ConversationTurn turn, + MessageListContext listContext, + Action requestRender) + { + _turn = turn; + _listContext = listContext; + _requestRender = requestRender; + + _blockAddedSub = agentContext.RegisterOnBlockAdded((t, block) => + { + if (ReferenceEquals(t, _turn)) + { + OnBlockAdded(block); + } + }); + + foreach (var block in turn.RequestBlocks) + { + _blockContainers.Add(new BlockContainer(block, _listContext, _requestRender)); + } + foreach (var block in turn.ResponseBlocks) + { + _blockContainers.Add(new BlockContainer(block, _listContext, _requestRender)); + } + } + + private void OnBlockAdded(ContentBlock block) + { + _blockContainers.Add(new BlockContainer(block, _listContext, _requestRender)); + _requestRender(); + } + + internal void RenderTo(RenderTreeBuilder builder, int baseSeq) + { + // Determine role from request blocks (user turn) or response blocks + var role = _turn.RequestBlocks.Count > 0 ? "user" : "assistant"; + builder.OpenElement(baseSeq, "div"); + builder.AddAttribute(baseSeq + 1, "class", $"sc-ai-turn sc-ai-turn--{role}"); + var seq = baseSeq + 10; + foreach (var container in _blockContainers) + { + container.RenderTo(builder, seq); + seq += 10; + } + builder.CloseElement(); + } + + public void Dispose() + { + _blockAddedSub?.Dispose(); + foreach (var container in _blockContainers) + { + container.Dispose(); + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs new file mode 100644 index 000000000000..b61db3c99167 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs @@ -0,0 +1,169 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.Web; +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Text input that sends messages to the cascaded and disables +/// itself while a response streams. +/// +public class MessageInput : IComponent, IDisposable +{ + private RenderHandle _renderHandle; + private AgentContext _agentContext = default!; + private string? _placeholder; + private RenderFragment? _leadingActions; + private RenderFragment? _trailingActions; + private string _text = ""; + private bool _isDisabled; + private IDisposable? _statusSub; + + /// + /// Gets or sets the conversation this input sends messages to. + /// + [CascadingParameter] + public AgentContext AgentContext { get; set; } = default!; + + /// + /// Gets or sets the placeholder text of the input. + /// + [Parameter] + public string? Placeholder { get; set; } + + /// + /// Gets or sets the content rendered before the text area. + /// + [Parameter] + public RenderFragment? LeadingActions { get; set; } + + /// + /// Gets or sets the content rendered after the text area. Replaces the default send button. + /// + [Parameter] + public RenderFragment? TrailingActions { get; set; } + + void IComponent.Attach(RenderHandle renderHandle) + { + _renderHandle = renderHandle; + } + + Task IComponent.SetParametersAsync(ParameterView parameters) + { + parameters.SetParameterProperties(this); + _agentContext = AgentContext + ?? throw new InvalidOperationException( + "MessageInput must be inside an AgentBoundary."); + _placeholder = Placeholder; + _leadingActions = LeadingActions; + _trailingActions = TrailingActions; + + // Register once. The AgentContext cascade is fixed for the lifetime of the component, + // so re-registering on every parameter set would accumulate handlers and retain the + // component on each parent re-render. + _statusSub ??= _agentContext.RegisterOnStatusChanged(status => + { + _isDisabled = status is ConversationStatus.Streaming or ConversationStatus.AwaitingInput; + Render(); + }); + + Render(); + return Task.CompletedTask; + } + + private void Render() + { + _renderHandle.Render(builder => + { + builder.OpenElement(0, "div"); + builder.AddAttribute(1, "class", "sc-ai-input"); + + if (_leadingActions is not null) + { + builder.AddContent(2, _leadingActions); + } + + builder.OpenElement(3, "div"); + builder.AddAttribute(4, "class", "sc-ai-input__body"); + + builder.OpenElement(10, "textarea"); + builder.AddAttribute(11, "class", "sc-ai-input__textarea"); + builder.AddAttribute(12, "placeholder", _placeholder ?? "Type a message..."); + builder.AddAttribute(13, "disabled", _isDisabled); + builder.AddAttribute(14, "value", _text); + builder.AddAttribute(15, "aria-label", _placeholder ?? "Type a message..."); + builder.AddAttribute(16, "oninput", + EventCallback.Factory.Create( + this, e => + { + _text = e.Value?.ToString() ?? ""; + // Re-render so the component's rendered value tracks the DOM value. + // Without this, clearing _text on submit produces no diff (the last + // rendered value was already empty) and the textarea is never cleared. + Render(); + })); + builder.SetUpdatesAttributeName("value"); + builder.AddAttribute(17, "onkeydown", + EventCallback.Factory.Create(this, OnKeyDown)); + builder.CloseElement(); // textarea + + builder.CloseElement(); // input body + + if (_trailingActions is not null) + { + builder.AddContent(50, _trailingActions); + } + else + { + builder.OpenElement(50, "button"); + builder.AddAttribute(51, "type", "button"); + builder.AddAttribute(52, "class", "sc-ai-input__send"); + builder.AddAttribute(53, "disabled", _isDisabled); + builder.AddAttribute(54, "aria-label", "Send message"); + builder.AddAttribute(55, "onclick", + EventCallback.Factory.Create(this, SubmitAsync)); + + // Send icon SVG + builder.AddMarkupContent(56, + ""); + + builder.CloseElement(); + } + + builder.CloseElement(); // div + }); + } + + private async Task OnKeyDown(KeyboardEventArgs e) + { + if (e.Key == "Enter" && !e.ShiftKey && !_isDisabled) + { + await SubmitAsync(); + } + } + + private async Task SubmitAsync() + { + if (_isDisabled || string.IsNullOrWhiteSpace(_text)) + { + return; + } + + var text = _text; + _text = ""; + Render(); + + await _agentContext.SendMessageAsync(new ChatMessage(ChatRole.User, text)); + } + + /// + /// Removes the status subscription this input registered on the conversation. + /// + public void Dispose() + { + _statusSub?.Dispose(); + GC.SuppressFinalize(this); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageList.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageList.cs new file mode 100644 index 000000000000..70e703f29806 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageList.cs @@ -0,0 +1,204 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.Rendering; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Renders the turns of the cascaded and updates them as blocks +/// stream in. +/// +[StreamRendering] +public class MessageList : IComponent, IDisposable +{ + private RenderHandle _renderHandle; + private AgentContext _agentContext = default!; + private RenderFragment? _childContent; + private RenderFragment? _footer; + private readonly MessageListContext _listContext = new(); + private readonly List _turnRenderers = new(); + private IDisposable? _turnAddedSub; + private IDisposable? _statusChangedSub; + + /// + /// Gets or sets the conversation rendered by this list. + /// + [CascadingParameter] + public AgentContext AgentContext { get; set; } = default!; + + /// + /// Gets or sets the content rendered above the turns. Use it to register + /// components. + /// + [Parameter] + public RenderFragment? ChildContent { get; set; } + + /// + /// Gets or sets the content rendered when the conversation has no turns. + /// + [Parameter] + public RenderFragment? EmptyContent { get; set; } + + /// + /// Gets or sets the content rendered below the turns. Defaults to the streaming and error + /// indicators. + /// + [Parameter] + public RenderFragment? Footer { get; set; } + + void IComponent.Attach(RenderHandle renderHandle) + { + _renderHandle = renderHandle; + } + + Task IComponent.SetParametersAsync(ParameterView parameters) + { + parameters.SetParameterProperties(this); + var newAgentContext = AgentContext + ?? throw new InvalidOperationException( + "MessageList must be inside an AgentBoundary."); + + if (!ReferenceEquals(_agentContext, newAgentContext)) + { + ResetRegistrations(); + _agentContext = newAgentContext; + _listContext.OnRegistrationsChanged = Render; + + _turnAddedSub = _agentContext.RegisterOnTurnAdded(OnTurnAdded); + _statusChangedSub = _agentContext.RegisterOnStatusChanged(_ => Render()); + + foreach (var turn in _agentContext.Turns) + { + var renderer = new ConversationTurnRenderer( + _agentContext, turn, _listContext, Render); + _turnRenderers.Add(renderer); + } + } + + _childContent = ChildContent; + _footer = Footer; + + Render(); + return Task.CompletedTask; + } + + private void OnTurnAdded(ConversationTurn turn) + { + var renderer = new ConversationTurnRenderer( + _agentContext, turn, _listContext, Render); + _turnRenderers.Add(renderer); + Render(); + } + + private void Render() + { + _renderHandle.Render(builder => + { + builder.OpenComponent>(0); + builder.AddComponentParameter(1, "Value", _listContext); + builder.AddComponentParameter(2, "IsFixed", true); + builder.AddComponentParameter(3, "ChildContent", + (RenderFragment)(inner => + { + inner.OpenElement(3, "div"); + inner.AddAttribute(3, "class", "sc-ai-message-list"); + if (_childContent is not null) + { + inner.AddContent(4, _childContent); + } + + if (_turnRenderers.Count == 0 && EmptyContent is not null) + { + inner.AddContent(5, EmptyContent); + } + + var seq = 100; + foreach (var turnRenderer in _turnRenderers) + { + turnRenderer.RenderTo(inner, seq); + seq += 100; + } + + inner.OpenElement(seq, "div"); + inner.AddAttribute(seq + 1, "class", "sc-ai-message-list__footer"); + if (_footer is not null) + { + inner.AddContent(seq + 2, _footer(_agentContext)); + } + else + { + RenderDefaultFooter(inner, seq + 2); + } + inner.CloseElement(); // footer div + + inner.CloseElement(); // sc-ai-message-list div + })); + builder.CloseComponent(); + }); + } + + private void RenderDefaultFooter(RenderTreeBuilder builder, int seq) + { + switch (_agentContext.Status) + { + case ConversationStatus.Streaming: + builder.OpenElement(seq, "div"); + builder.AddAttribute(seq + 1, "class", "sc-ai-typing"); + builder.AddAttribute(seq + 2, "role", "status"); + builder.AddAttribute(seq + 3, "aria-label", "Agent is typing"); + for (var i = 0; i < 3; i++) + { + builder.OpenElement(seq + 4 + i, "span"); + builder.AddAttribute(seq + 7 + i, "class", "sc-ai-typing__dot"); + builder.CloseElement(); + } + builder.CloseElement(); + break; + + case ConversationStatus.Error: + builder.OpenElement(seq, "div"); + builder.AddAttribute(seq + 1, "class", "sc-ai-error"); + builder.AddAttribute(seq + 2, "role", "alert"); + builder.OpenElement(seq + 3, "span"); + builder.AddAttribute(seq + 4, "class", "sc-ai-error__message"); + builder.AddContent(seq + 5, "Something went wrong. Please try again."); + builder.CloseElement(); // span + builder.OpenElement(seq + 6, "button"); + builder.AddAttribute(seq + 7, "type", "button"); + builder.AddAttribute(seq + 8, "class", "sc-ai-btn sc-ai-btn--secondary"); + builder.AddAttribute(seq + 9, "onclick", + EventCallback.Factory.Create(this, + () => _agentContext.RetryAsync())); + builder.AddContent(seq + 10, "Retry"); + builder.CloseElement(); // button + builder.CloseElement(); // div + break; + } + } + + private void ResetRegistrations() + { + _turnAddedSub?.Dispose(); + _turnAddedSub = null; + + _statusChangedSub?.Dispose(); + _statusChangedSub = null; + + foreach (var renderer in _turnRenderers) + { + renderer.Dispose(); + } + + _turnRenderers.Clear(); + } + + /// + /// Removes the subscriptions this list registered on the conversation. + /// + public void Dispose() + { + ResetRegistrations(); + GC.SuppressFinalize(this); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageListContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageListContext.cs new file mode 100644 index 000000000000..b262655f5864 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageListContext.cs @@ -0,0 +1,451 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.Rendering; +using Microsoft.Extensions.AI; +using System.Text.Json; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Resolves the markup used to render a block inside a . Renderers +/// registered with take precedence over the built-in +/// rendering. +/// +public class MessageListContext +{ + private static readonly JsonSerializerOptions IndentedJsonOptions = new() + { + WriteIndented = true, + }; + + private readonly List _registrations = new(); + + /// + /// Returns the markup for a block. + /// + /// The block to render. + /// The markup that renders . + public RenderFragment RenderBlock(ContentBlock block) + { + ArgumentNullException.ThrowIfNull(block); + + for (var i = _registrations.Count - 1; i >= 0; i--) + { + var reg = _registrations[i]; + if (reg.BlockType.IsAssignableFrom(block.GetType()) + && (reg.When is null || reg.When(block))) + { + return reg.Render(block); + } + } + + return builder => + { + if (block is RichContentBlock rich) + { + var role = block.Role == ChatRole.User ? "user" : "assistant"; + builder.OpenElement(0, "div"); + builder.AddAttribute(1, "class", $"sc-ai-message sc-ai-message--{role}"); + builder.OpenElement(2, "div"); + builder.AddAttribute(3, "class", "sc-ai-message__bubble"); + builder.OpenElement(4, "div"); + var contentClass = block.LifecycleState == BlockLifecycleState.Active + ? "sc-ai-message__content sc-ai-message__content--streaming" + : "sc-ai-message__content"; + builder.AddAttribute(5, "class", contentClass); + if (rich.Content.Count > 0) + { + RenderRichTextNodes(builder, rich.Content); + } + else + { + builder.AddContent(6, rich.RawText); + } + builder.CloseElement(); // content div + builder.CloseElement(); // bubble div + builder.CloseElement(); // message div + } + else if (block is FunctionApprovalBlock approval) + { + RenderApprovalBlock(builder, approval); + } + else if (block is not FunctionInvocationContentBlock) + { + builder.OpenElement(0, "div"); + builder.AddAttribute(1, "class", "sc-ai-unknown-block"); + builder.AddContent(2, block.GetType().Name); + builder.CloseElement(); + } + }; + } + + internal Action? OnRegistrationsChanged { get; set; } + + internal void AddRegistration(BlockRendererRegistration registration) + { + _registrations.Add(registration); + OnRegistrationsChanged?.Invoke(); + } + + internal void RemoveRegistration(BlockRendererRegistration registration) + { + _registrations.Remove(registration); + OnRegistrationsChanged?.Invoke(); + } + + private static void RenderRichTextNodes( + RenderTreeBuilder builder, + IReadOnlyList nodes) + { + foreach (var node in nodes) + { + builder.OpenRegion(0); + RenderRichTextNode(builder, node); + builder.CloseRegion(); + } + } + + private static void RenderRichTextNode(RenderTreeBuilder builder, RichTextNode node) + { + switch (node) + { + case TextNode text: + builder.AddContent(0, text.Text); + break; + case ParagraphNode: + RenderElement(builder, "p", "sc-ai-rich-text__paragraph", node.Children); + break; + case HeadingNode heading: + RenderElement( + builder, + $"h{Math.Clamp(heading.Level, 1, 6)}", + "sc-ai-rich-text__heading", + node.Children); + break; + case EmphasisNode: + RenderElement(builder, "em", null, node.Children); + break; + case StrongNode: + RenderElement(builder, "strong", null, node.Children); + break; + case StrikethroughNode: + RenderElement(builder, "s", null, node.Children); + break; + case InlineCodeNode inlineCode: + builder.OpenElement(0, "code"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__inline-code"); + builder.AddContent(2, inlineCode.Code); + builder.CloseElement(); + break; + case CodeBlockNode codeBlock: + builder.OpenElement(0, "pre"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__code-block"); + builder.OpenElement(2, "code"); + if (!string.IsNullOrEmpty(codeBlock.Language)) + { + builder.AddAttribute(3, "data-language", codeBlock.Language); + } + builder.AddContent(4, codeBlock.Code); + builder.CloseElement(); + builder.CloseElement(); + break; + case BlockQuoteNode: + RenderElement(builder, "blockquote", "sc-ai-rich-text__quote", node.Children); + break; + case LineBreakNode: + builder.OpenElement(0, "br"); + builder.CloseElement(); + break; + case ThematicBreakNode: + builder.OpenElement(0, "hr"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__thematic-break"); + builder.CloseElement(); + break; + case ListNode list: + builder.OpenElement(0, list.Ordered ? "ol" : "ul"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__list"); + if (list.Ordered && list.Start is not null) + { + builder.AddAttribute(2, "start", list.Start.Value); + } + RenderRichTextNodes(builder, list.Children); + builder.CloseElement(); + break; + case ListItemNode item: + builder.OpenElement(0, "li"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__list-item"); + if (item.Checked is not null) + { + builder.OpenElement(2, "input"); + builder.AddAttribute(3, "type", "checkbox"); + builder.AddAttribute(4, "disabled", true); + if (item.Checked.Value) + { + builder.AddAttribute(5, "checked", true); + } + builder.CloseElement(); + } + RenderRichTextNodes(builder, item.Children); + builder.CloseElement(); + break; + case LinkNode link: + RenderLink(builder, link); + break; + case ImageNode image: + RenderImage(builder, image); + break; + case DefinitionNode definition: + builder.OpenElement(0, "span"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__definition"); + builder.AddContent(2, $"[{definition.Label}]: {definition.Url}"); + builder.CloseElement(); + break; + case LinkReferenceNode linkReference: + RenderReference(builder, linkReference.Label, linkReference.Children); + break; + case ImageReferenceNode imageReference: + builder.OpenElement(0, "span"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__image-reference"); + builder.AddContent(2, imageReference.Alt ?? imageReference.Label); + builder.CloseElement(); + break; + case FootnoteNode: + RenderElement(builder, "aside", "sc-ai-rich-text__footnote", node.Children); + break; + case FootnoteReferenceNode footnoteReference: + builder.OpenElement(0, "sup"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__footnote-reference"); + builder.AddContent(2, footnoteReference.Label); + builder.CloseElement(); + break; + case FootnoteDefinitionNode footnoteDefinition: + builder.OpenElement(0, "aside"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__footnote-definition"); + builder.AddAttribute(2, "data-label", footnoteDefinition.Label); + RenderRichTextNodes(builder, footnoteDefinition.Children); + builder.CloseElement(); + break; + case HtmlNode html: + builder.OpenElement(0, "code"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__html"); + builder.AddContent(2, html.Value); + builder.CloseElement(); + break; + case TableNode table: + RenderTable(builder, table); + break; + case TableRowNode: + case TableCellNode: + RenderRichTextNodes(builder, node.Children); + break; + default: + RenderRichTextNodes(builder, node.Children); + break; + } + } + + private static void RenderElement( + RenderTreeBuilder builder, + string elementName, + string? className, + IReadOnlyList children) + { + builder.OpenElement(0, elementName); + if (className is not null) + { + builder.AddAttribute(1, "class", className); + } + RenderRichTextNodes(builder, children); + builder.CloseElement(); + } + + private static void RenderLink(RenderTreeBuilder builder, LinkNode link) + { + var safeUrl = GetSafeUrl(link.Url, allowMailTo: true); + if (safeUrl is null) + { + RenderRichTextNodes(builder, link.Children); + return; + } + + builder.OpenElement(0, "a"); + builder.AddAttribute(1, "href", safeUrl); + if (link.Title is not null) + { + builder.AddAttribute(2, "title", link.Title); + } + RenderRichTextNodes(builder, link.Children); + builder.CloseElement(); + } + + private static void RenderImage(RenderTreeBuilder builder, ImageNode image) + { + var safeUrl = GetSafeUrl(image.Url, allowMailTo: false); + if (safeUrl is null) + { + builder.AddContent(0, image.Alt); + return; + } + + builder.OpenElement(0, "img"); + builder.AddAttribute(1, "src", safeUrl); + builder.AddAttribute(2, "alt", image.Alt ?? string.Empty); + if (image.Title is not null) + { + builder.AddAttribute(3, "title", image.Title); + } + builder.CloseElement(); + } + + private static void RenderReference( + RenderTreeBuilder builder, + string label, + IReadOnlyList children) + { + builder.OpenElement(0, "span"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__link-reference"); + if (children.Count > 0) + { + RenderRichTextNodes(builder, children); + } + else + { + builder.AddContent(2, label); + } + builder.CloseElement(); + } + + private static void RenderTable(RenderTreeBuilder builder, TableNode table) + { + builder.OpenElement(0, "div"); + builder.AddAttribute(1, "class", "sc-ai-rich-text__table-container"); + builder.OpenElement(2, "table"); + builder.AddAttribute(3, "class", "sc-ai-rich-text__table"); + builder.OpenElement(4, "tbody"); + + foreach (var child in table.Children) + { + if (child is not TableRowNode row) + { + continue; + } + + builder.OpenRegion(5); + builder.OpenElement(0, "tr"); + var columnIndex = 0; + foreach (var rowChild in row.Children) + { + if (rowChild is not TableCellNode cell) + { + continue; + } + + builder.OpenRegion(1); + builder.OpenElement(0, "td"); + if (columnIndex < table.Alignment.Count && + table.Alignment[columnIndex] != TableColumnAlignment.None) + { + builder.AddAttribute( + 1, + "class", + $"sc-ai-rich-text__table-cell--{table.Alignment[columnIndex].ToString().ToLowerInvariant()}"); + } + RenderRichTextNodes(builder, cell.Children); + builder.CloseElement(); + builder.CloseRegion(); + columnIndex++; + } + builder.CloseElement(); + builder.CloseRegion(); + } + + builder.CloseElement(); + builder.CloseElement(); + builder.CloseElement(); + } + + private static string? GetSafeUrl(string url, bool allowMailTo) + { + if (!Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out var uri)) + { + return null; + } + + if (!uri.IsAbsoluteUri) + { + return url; + } + + if (uri.Scheme is "http" or "https" || + (allowMailTo && uri.Scheme == "mailto")) + { + return url; + } + + return null; + } + + private static void RenderApprovalBlock( + RenderTreeBuilder builder, + FunctionApprovalBlock block) + { + builder.OpenElement(0, "div"); + builder.AddAttribute(1, "class", "sc-ai-approval"); + + builder.OpenElement(2, "div"); + builder.AddAttribute(3, "class", "sc-ai-approval__header"); + builder.AddContent(4, "Approval required"); + builder.CloseElement(); + + builder.OpenElement(5, "div"); + builder.AddAttribute(6, "class", "sc-ai-approval__tool-name"); + builder.AddContent(7, block.ToolName ?? "Unknown tool"); + builder.CloseElement(); + + if (block.Arguments is { Count: > 0 }) + { + builder.OpenElement(8, "pre"); + builder.AddAttribute(9, "class", "sc-ai-approval__arguments"); + builder.AddContent(10, JsonSerializer.Serialize(block.Arguments, IndentedJsonOptions)); + builder.CloseElement(); + } + + if (block.Status == ApprovalStatus.Pending) + { + builder.OpenElement(11, "div"); + builder.AddAttribute(12, "class", "sc-ai-approval__actions"); + + builder.OpenElement(13, "button"); + builder.AddAttribute(14, "type", "button"); + builder.AddAttribute(15, "class", "sc-ai-btn sc-ai-btn--primary"); + builder.AddAttribute(16, "onclick", (Action)block.Approve); + builder.AddContent(17, "Approve"); + builder.CloseElement(); + + builder.OpenElement(18, "button"); + builder.AddAttribute(19, "type", "button"); + builder.AddAttribute(20, "class", "sc-ai-btn sc-ai-btn--secondary"); + builder.AddAttribute(21, "onclick", (Action)(() => block.Reject())); + builder.AddContent(22, "Reject"); + builder.CloseElement(); + + builder.CloseElement(); + } + else + { + var approved = block.Status == ApprovalStatus.Approved; + builder.OpenElement(23, "div"); + builder.AddAttribute( + 24, + "class", + approved + ? "sc-ai-approval__status sc-ai-approval__status--approved" + : "sc-ai-approval__status sc-ai-approval__status--rejected"); + builder.AddContent(25, approved ? "Approved" : "Rejected"); + builder.CloseElement(); + } + + builder.CloseElement(); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs new file mode 100644 index 000000000000..6f9234e593d3 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs @@ -0,0 +1,380 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Linq; +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Owns the state of a conversation: the turns rendered by the UI, the current +/// , and the notifications the components subscribe to. +/// +/// +/// +/// var context = new AgentContext(agent); +/// using var subscription = context.RegisterOnStatusChanged(status => Console.WriteLine(status)); +/// await context.SendMessageAsync("Hello"); +/// +/// +public class AgentContext : IDisposable +{ + private readonly UIAgent _agent; + private readonly List _turns = new(); + private readonly List> _turnAddedCallbacks = new(); + private readonly List> _statusChangedCallbacks = new(); + private readonly List> _blockAddedCallbacks = new(); + private CancellationTokenSource? _streamingCts; + private ChatMessage? _lastMessage; + private bool _disposed; + + /// + /// Initializes a new instance of the class. + /// + /// The agent that produces the responses for this conversation. + public AgentContext(UIAgent agent) + { + ArgumentNullException.ThrowIfNull(agent); + _agent = agent; + } + + /// + /// Gets the turns of this conversation, oldest first. + /// + public IReadOnlyList Turns => _turns; + + /// + /// Gets the current status of the conversation. + /// + public ConversationStatus Status { get; private set; } + + /// + /// Gets the exception that failed the last turn, when is + /// . + /// + public Exception? Error { get; private set; } + + /// + /// Sends a text message and streams the response into a new turn. + /// + /// The message text. + /// A token that cancels the response. + /// A task that completes when the turn finishes. + public Task SendMessageAsync(string text, CancellationToken cancellationToken = default) + { + return SendMessageAsync(new ChatMessage(ChatRole.User, text), cancellationToken); + } + + /// + /// Sends a message and streams the response into a new turn. + /// + /// The message to send. + /// A token that cancels the response. + /// A task that completes when the turn finishes. + public async Task SendMessageAsync(ChatMessage message, CancellationToken cancellationToken = default) + { + ArgumentNullException.ThrowIfNull(message); + + if (Status is ConversationStatus.Streaming or ConversationStatus.AwaitingInput) + { + throw new InvalidOperationException("A message is already being processed."); + } + + _lastMessage = message; + + var turn = new ConversationTurn(); + _turns.Add(turn); + NotifyTurnAdded(turn); + + _streamingCts?.Dispose(); + _streamingCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + + await StreamIntoTurnAsync(message, turn, _streamingCts.Token, cancellationToken); + } + + /// + /// Restores the committed turns from the agent's configured conversation thread. + /// + /// A token that cancels restoration. + /// A task that completes when the turns have been restored. + public async Task RestoreAsync(CancellationToken cancellationToken = default) + { + if (Status == ConversationStatus.Streaming) + { + throw new InvalidOperationException("A message is already being processed."); + } + + var blocks = await _agent.RestoreAsync(cancellationToken); + _turns.Clear(); + + ConversationTurn? currentTurn = null; + foreach (var block in blocks) + { + if (block.Role == ChatRole.User) + { + currentTurn = new ConversationTurn(); + _turns.Add(currentTurn); + currentTurn.AddRequestBlock(block); + } + else + { + if (currentTurn is null) + { + currentTurn = new ConversationTurn(); + _turns.Add(currentTurn); + } + + currentTurn.AddResponseBlock(block); + } + } + } + + /// + /// Replays the last message after a failed turn. + /// + /// A token that cancels the response. + /// A task that completes when the turn finishes. + public async Task RetryAsync(CancellationToken cancellationToken = default) + { + if (Status != ConversationStatus.Error) + { + throw new InvalidOperationException( + $"RetryAsync requires Status == Error, but Status is {Status}."); + } + + var turn = _turns[^1]; + turn.ClearResponseBlocks(); + + _streamingCts?.Dispose(); + _streamingCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + + await StreamIntoTurnAsync(_lastMessage!, turn, _streamingCts.Token, cancellationToken); + } + + /// + /// Stops the response that is currently streaming, if any. + /// + /// A task that completes once cancellation has been requested. + public Task CancelAsync() + { + if (Status is ConversationStatus.Idle or ConversationStatus.Error) + { + return Task.CompletedTask; + } + + _streamingCts?.Cancel(); + return Task.CompletedTask; + } + + /// + /// Registers a callback invoked when a turn is added to the conversation. + /// + /// The callback to invoke. + /// A registration that removes the callback when disposed. + public IDisposable RegisterOnTurnAdded(Action callback) + { + ArgumentNullException.ThrowIfNull(callback); + _turnAddedCallbacks.Add(callback); + return new CallbackRegistration>(_turnAddedCallbacks, callback); + } + + /// + /// Registers a callback invoked when changes. + /// + /// The callback to invoke. + /// A registration that removes the callback when disposed. + public IDisposable RegisterOnStatusChanged(Action callback) + { + ArgumentNullException.ThrowIfNull(callback); + _statusChangedCallbacks.Add(callback); + return new CallbackRegistration>(_statusChangedCallbacks, callback); + } + + /// + /// Registers a callback invoked when a block is added to a turn. + /// + /// The callback to invoke. + /// A registration that removes the callback when disposed. + public IDisposable RegisterOnBlockAdded(Action callback) + { + ArgumentNullException.ThrowIfNull(callback); + _blockAddedCallbacks.Add(callback); + return new CallbackRegistration>(_blockAddedCallbacks, callback); + } + + /// + /// Releases the resources used by this context and stops any streaming response. + /// + public void Dispose() + { + if (_disposed) + { + return; + } + + _disposed = true; + _streamingCts?.Cancel(); + _streamingCts?.Dispose(); + _agent.RejectPendingPredictiveState(); + _turnAddedCallbacks.Clear(); + _statusChangedCallbacks.Clear(); + _blockAddedCallbacks.Clear(); + GC.SuppressFinalize(this); + } + + private async Task StreamIntoTurnAsync( + ChatMessage message, + ConversationTurn turn, + CancellationToken cancellationToken, + CancellationToken callerToken) + { + Status = ConversationStatus.Streaming; + Error = null; + NotifyStatusChanged(); + + try + { + IReadOnlyList? currentMessages = [message]; + while (currentMessages is not null) + { + var interactiveBlocks = new List(); + + await foreach (var block in _agent.SendMessagesAsync(currentMessages, cancellationToken) + .WithCancellation(cancellationToken)) + { + if (block.Role == message.Role) + { + turn.AddRequestBlock(block); + } + else + { + turn.AddResponseBlock(block); + } + + if (block is IInteractiveBlock interactiveBlock) + { + interactiveBlocks.Add(interactiveBlock); + } + + NotifyBlockAdded(turn, block); + } + + if (interactiveBlocks.Count == 0) + { + currentMessages = null; + continue; + } + + Status = ConversationStatus.AwaitingInput; + NotifyStatusChanged(); + + var results = await Task.WhenAll( + interactiveBlocks.Select(block => block.GetResultAsync(cancellationToken))); + + currentMessages = CreateContinuationMessages(results); + Status = ConversationStatus.Streaming; + NotifyStatusChanged(); + } + + _agent.RejectPendingPredictiveState(); + Status = ConversationStatus.Idle; + if (cancellationToken.IsCancellationRequested) + { + turn.ClearResponseBlocks(); + } + NotifyStatusChanged(); + } + catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) + { + turn.ClearResponseBlocks(); + _agent.RejectPendingPredictiveState(); + Status = ConversationStatus.Idle; + NotifyStatusChanged(); + } + catch (Exception ex) + { + // A failing turn is surfaced as conversation state (Status/Error) rather than a + // faulted Task: the UI renders the error and RetryAsync replays the last message. + // This is the engine's error contract, not a swallowed exception. + _agent.RejectPendingPredictiveState(); + Error = ex; + Status = ConversationStatus.Error; + NotifyStatusChanged(); + return; + } + + // If the caller's own token requested cancellation, surface it so the returned Task + // completes as canceled. Cancellation driven by CancelAsync() (the internal token only) + // is a graceful stop and completes normally. + callerToken.ThrowIfCancellationRequested(); + } + + private static IReadOnlyList CreateContinuationMessages( + IReadOnlyList results) + { + var messages = new List(); + foreach (var result in results) + { + var role = result is FunctionResultContent ? ChatRole.Tool : ChatRole.User; + if (messages.Count > 0 && messages[^1].Role == role) + { + messages[^1].Contents.Add(result); + } + else + { + messages.Add(new ChatMessage(role, [result])); + } + } + + return messages; + } + + private void NotifyStatusChanged() + { + var snapshot = _statusChangedCallbacks.ToArray(); + foreach (var callback in snapshot) + { + callback(Status); + } + } + + private void NotifyTurnAdded(ConversationTurn turn) + { + var snapshot = _turnAddedCallbacks.ToArray(); + foreach (var callback in snapshot) + { + callback(turn); + } + } + + private void NotifyBlockAdded(ConversationTurn turn, ContentBlock block) + { + var snapshot = _blockAddedCallbacks.ToArray(); + foreach (var callback in snapshot) + { + callback(turn, block); + } + } + + private sealed class CallbackRegistration : IDisposable + { + private List? _list; + private T? _callback; + + internal CallbackRegistration(List list, T callback) + { + _list = list; + _callback = callback; + } + + public void Dispose() + { + if (_list is not null && _callback is not null) + { + _list.Remove(_callback); + _list = null; + _callback = default; + } + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentState.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentState.cs new file mode 100644 index 000000000000..294bd42fbe1f --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentState.cs @@ -0,0 +1,120 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Holds observable state associated with a . +/// +/// The type of state. +public class AgentState where T : class, new() +{ + private readonly List _callbacks = new(); + private T _value; + private T? _valueBeforePrediction; + + internal AgentState(T? initialValue = null) + { + _value = initialValue ?? new T(); + } + + /// + /// Gets or sets the current state value. + /// + public T Value + { + get => _value; + set + { + ArgumentNullException.ThrowIfNull(value); + _valueBeforePrediction = null; + _value = value; + NotifyChanged(); + } + } + + /// + /// Gets a value indicating whether contains provisional predictive state. + /// + public bool HasPendingPredictiveState => _valueBeforePrediction is not null; + + /// + /// Accepts the current predictive state as the committed value. + /// + public void AcceptPredictiveState() + { + if (_valueBeforePrediction is null) + { + return; + } + + _valueBeforePrediction = null; + NotifyChanged(); + } + + /// + /// Rejects the current predictive state and restores the value from before the prediction. + /// + public void RejectPredictiveState() + { + if (_valueBeforePrediction is not { } previousValue) + { + return; + } + + _valueBeforePrediction = null; + _value = previousValue; + NotifyChanged(); + } + + /// + /// Registers a callback invoked when changes. + /// + /// The callback to invoke. + /// A registration that removes the callback when disposed. + public IDisposable OnChanged(Action callback) + { + ArgumentNullException.ThrowIfNull(callback); + _callbacks.Add(callback); + return new CallbackRegistration(_callbacks, callback); + } + + internal void SetPredictiveValue(T value) + { + ArgumentNullException.ThrowIfNull(value); + _valueBeforePrediction ??= _value; + _value = value; + NotifyChanged(); + } + + private void NotifyChanged() + { + var snapshot = _callbacks.ToArray(); + foreach (var callback in snapshot) + { + callback(); + } + } + + private sealed class CallbackRegistration : IDisposable + { + private List? _callbacks; + private Action? _callback; + + internal CallbackRegistration(List callbacks, Action callback) + { + _callbacks = callbacks; + _callback = callback; + } + + public void Dispose() + { + if (_callbacks is not null && _callback is not null) + { + _callbacks.Remove(_callback); + _callbacks = null; + _callback = null; + } + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs new file mode 100644 index 000000000000..01cf29c7a29a --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// The state of a conversation driven by an . +/// +public enum ConversationStatus +{ + /// + /// No response is in flight; the user can send a message. + /// + Idle, + + /// + /// A model response is streaming. + /// + Streaming, + + /// + /// The conversation is waiting for the user to interact with the current response. + /// + AwaitingInput, + + /// + /// The last turn failed. holds the exception and + /// replays the turn. + /// + Error +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs new file mode 100644 index 000000000000..736383376c53 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// A single exchange in a conversation: the blocks produced by the user's message and the +/// blocks produced by the response to it. +/// +public class ConversationTurn +{ + private readonly List _requestBlocks = new(); + private readonly List _responseBlocks = new(); + + /// + /// Gets the identifier of this turn. + /// + public string Id { get; internal set; } = string.Empty; + + /// + /// Gets the blocks produced by the message that started this turn. + /// + public IReadOnlyList RequestBlocks => _requestBlocks; + + /// + /// Gets the blocks produced by the response to this turn. + /// + public IReadOnlyList ResponseBlocks => _responseBlocks; + + internal void AddRequestBlock(ContentBlock block) + { + _requestBlocks.Add(block); + } + + internal void AddResponseBlock(ContentBlock block) + { + _responseBlocks.Add(block); + } + + internal void ClearResponseBlocks() + { + _responseBlocks.Clear(); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/IConversationThread.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/IConversationThread.cs new file mode 100644 index 000000000000..87756edd7d84 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/IConversationThread.cs @@ -0,0 +1,53 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Represents a persistent conversation thread that stores streamed chat updates. +/// +/// +/// Implementations control where and how conversation updates are persisted. +/// +public interface IConversationThread +{ + /// + /// Gets the unique identifier for this thread. + /// + string ThreadId { get; } + + /// + /// Gets a value indicating whether the remote service manages the conversation history. + /// + bool IsStateful { get; } + + /// + /// Gets the conversation identifier returned by a stateful remote service, if any. + /// + string? ConversationId { get; } + + /// + /// Begins a turn by appending the message sent to the chat client. + /// + /// The message that begins the turn. + void AppendUserMessage(ChatMessage message); + + /// + /// Appends an update received from the chat client to the current turn. + /// + /// The streamed update. + void AppendUpdate(ChatResponseUpdate update); + + /// + /// Commits the current turn to the stored history. + /// + void CompleteTurn(); + + /// + /// Gets all committed updates in chronological order. + /// + /// The committed updates. + IReadOnlyList GetUpdates(); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs new file mode 100644 index 000000000000..350adfdfec5c --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs @@ -0,0 +1,357 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Linq; +using System.Runtime.CompilerServices; +using Microsoft.Extensions.AI; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Turns an stream into content blocks the UI can render as they +/// arrive, and keeps the conversation history for subsequent turns. +/// +/// +/// A is protocol- and provider-neutral: it only depends on +/// , so any Microsoft.Extensions.AI client can drive it. +/// +/// +/// +/// var agent = new UIAgent(chatClient); +/// await foreach (var block in agent.SendMessageAsync(new ChatMessage(ChatRole.User, "Hello"))) +/// { +/// Console.WriteLine(block.Id); +/// } +/// +/// +public class UIAgent : IDisposable +{ + private readonly IChatClient _chatClient; + private readonly UIAgentOptions _options; + private readonly ILogger _logger; + private readonly List _history = new(); + private bool _disposed; + + internal UIAgentOptions Options => _options; + + internal virtual void RejectPendingPredictiveState() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + public UIAgent(IChatClient chatClient) + : this(chatClient, configure: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// The options passed to the chat client. + public UIAgent(IChatClient chatClient, ChatOptions chatOptions) + : this(chatClient, options => options.ChatOptions = chatOptions) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// The options passed to the chat client. + /// The logger factory used to trace block mapping. + public UIAgent(IChatClient chatClient, ChatOptions chatOptions, ILoggerFactory? loggerFactory) + : this(chatClient, options => options.ChatOptions = chatOptions, loggerFactory) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// A callback that configures the agent. + public UIAgent(IChatClient chatClient, Action? configure) + : this(chatClient, configure, loggerFactory: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// A callback that configures the agent. + /// The logger factory used to trace block mapping. + public UIAgent(IChatClient chatClient, Action? configure, ILoggerFactory? loggerFactory) + { + ArgumentNullException.ThrowIfNull(chatClient); + _chatClient = chatClient; + _options = new UIAgentOptions(); + configure?.Invoke(_options); + _logger = (ILogger?)loggerFactory?.CreateLogger() ?? NullLogger.Instance; + } + + internal UIAgent(IChatClient chatClient, UIAgentOptions options, ILoggerFactory? loggerFactory) + { + ArgumentNullException.ThrowIfNull(chatClient); + _chatClient = chatClient; + _options = options; + _logger = (ILogger?)loggerFactory?.CreateLogger() ?? NullLogger.Instance; + } + + /// + /// Sends a message and streams the resulting content blocks. Blocks are yielded as soon as + /// they are created; a block keeps changing (raising ) + /// until it becomes . + /// + /// The message to send. + /// A token that cancels the response. + /// The blocks produced by the message and by the model response to it. + public async IAsyncEnumerable SendMessageAsync( + ChatMessage message, + [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + ArgumentNullException.ThrowIfNull(message); + + await foreach (var block in SendMessagesAsync([message], cancellationToken).ConfigureAwait(false)) + { + yield return block; + } + } + + internal async IAsyncEnumerable SendMessagesAsync( + IReadOnlyList messages, + [EnumeratorCancellation] CancellationToken cancellationToken = default) + { + ObjectDisposedException.ThrowIf(_disposed, this); + + var thread = _options.Thread; + foreach (var message in messages) + { + ArgumentNullException.ThrowIfNull(message); + _history.Add(message); + } + + var pipeline = new BlockMappingPipeline(_options, _logger); + + // Process user messages through pipeline + foreach (var message in messages) + { + var userUpdate = new ChatResponseUpdate + { + Role = message.Role, + Contents = [.. message.Contents] + }; + await foreach (var block in pipeline.Process(userUpdate, cancellationToken).ConfigureAwait(false)) + { + yield return block; + } + } + + foreach (var block in pipeline.Finalize()) + { + yield return block; + } + + // Stream assistant response + UIAgentLog.StreamingAssistantResponse(_logger); + var responseUpdates = new List(); + var assistantUpdates = new List(); + var updateIndex = 0; + var chatOptions = BuildChatOptions(); + IEnumerable requestMessages = _history; + if (thread is { IsStateful: true, ConversationId: not null }) + { + chatOptions = chatOptions?.Clone() ?? new ChatOptions(); + chatOptions.ConversationId = thread.ConversationId; + requestMessages = messages; + } + + await foreach (var update in _chatClient.GetStreamingResponseAsync( + requestMessages, chatOptions, cancellationToken).ConfigureAwait(false)) + { + var contentTypes = string.Join(", ", update.Contents.Select(c => c.GetType().Name)); + UIAgentLog.ReceivedUpdate(_logger, updateIndex++, update.Role?.Value, contentTypes); + + responseUpdates.Add(update); + var processUpdate = ApplyStateMapper(update); + assistantUpdates.Add(processUpdate); + + if (processUpdate.Contents.Count == 0 && update.Contents.Count > 0) + { + continue; + } + + await foreach (var block in pipeline.Process(processUpdate, cancellationToken).ConfigureAwait(false)) + { + yield return block; + } + } + + UIAgentLog.StreamComplete(_logger, assistantUpdates.Count); + + foreach (var block in pipeline.Finalize()) + { + yield return block; + } + + // Add assistant response to history + var response = assistantUpdates.ToChatResponse(); + foreach (var msg in response.Messages) + { + _history.Add(msg); + } + + if (thread is not null && messages.Count > 0) + { + thread.AppendUserMessage(messages[0]); + foreach (var message in messages.Skip(1)) + { + thread.AppendUpdate(new ChatResponseUpdate + { + Role = message.Role, + Contents = [.. message.Contents], + }); + } + + foreach (var update in responseUpdates) + { + thread.AppendUpdate(update); + } + + thread.CompleteTurn(); + } + + UIAgentLog.AddedToHistory(_logger, response.Messages.Count); + } + + /// + /// Restores the committed conversation and typed state from the configured thread. + /// + /// A token that cancels restoration. + /// The restored content blocks in chronological order. + public async Task> RestoreAsync( + CancellationToken cancellationToken = default) + { + ObjectDisposedException.ThrowIf(_disposed, this); + + var updates = _options.Thread?.GetUpdates(); + if (updates is not { Count: > 0 }) + { + return []; + } + + _history.Clear(); + + var blocks = new List(); + var pipeline = new BlockMappingPipeline(_options, _logger); + var assistantUpdates = new List(); + + foreach (var update in updates) + { + cancellationToken.ThrowIfCancellationRequested(); + + if (update.Role == ChatRole.User) + { + if (assistantUpdates.Count > 0) + { + AddResponseToHistory(assistantUpdates); + assistantUpdates.Clear(); + + blocks.AddRange(pipeline.Finalize()); + pipeline = new BlockMappingPipeline(_options, _logger); + } + + _history.Add(new ChatMessage(update.Role.Value, [.. update.Contents])); + await foreach (var block in pipeline.Process(update, cancellationToken).ConfigureAwait(false)) + { + blocks.Add(block); + } + + blocks.AddRange(pipeline.Finalize()); + pipeline = new BlockMappingPipeline(_options, _logger); + } + else + { + assistantUpdates.Add(update); + + var processUpdate = ApplyStateMapper(update); + if (processUpdate.Contents.Count == 0 && update.Contents.Count > 0) + { + continue; + } + + await foreach (var block in pipeline.Process(processUpdate, cancellationToken).ConfigureAwait(false)) + { + blocks.Add(block); + } + } + } + + if (assistantUpdates.Count > 0) + { + AddResponseToHistory(assistantUpdates); + } + + blocks.AddRange(pipeline.Finalize()); + RejectPendingPredictiveState(); + + return blocks; + } + + internal virtual ChatResponseUpdate ApplyStateMapper(ChatResponseUpdate update) + { + if (_options.StateMapper is null) + { + return update; + } + + var context = new StateMapperContext(update); + _options.StateMapper(context); + + return context.HasHandledContent ? context.GetFilteredUpdate() : update; + } + + private void AddResponseToHistory(List updates) + { + var response = updates.ToChatResponse(); + foreach (var message in response.Messages) + { + _history.Add(message); + } + } + + private ChatOptions? BuildChatOptions() + { + if (_options.UIActions.Count == 0) + { + return _options.ChatOptions; + } + + var chatOptions = _options.ChatOptions?.Clone() ?? new ChatOptions(); + var tools = chatOptions.Tools is null + ? new List() + : [.. chatOptions.Tools]; + + foreach (var action in _options.UIActions.Values) + { + tools.Add(action.AsDeclarationOnly()); + } + + chatOptions.Tools = tools; + return chatOptions; + } + + /// + /// Releases the resources used by this agent. + /// + public void Dispose() + { + _disposed = true; + GC.SuppressFinalize(this); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs new file mode 100644 index 000000000000..e268bbde68b6 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.Components.AI; + +internal static partial class UIAgentLog +{ + [LoggerMessage(100, LogLevel.Information, "SendMessageAsync: Streaming assistant response")] + internal static partial void StreamingAssistantResponse(ILogger logger); + + [LoggerMessage(101, LogLevel.Debug, "SendMessageAsync: Received update #{Index} Role={Role}, ContentTypes=[{ContentTypes}]")] + internal static partial void ReceivedUpdate(ILogger logger, int index, string? role, string contentTypes); + + [LoggerMessage(102, LogLevel.Information, "SendMessageAsync: Stream complete. Total updates={UpdateCount}")] + internal static partial void StreamComplete(ILogger logger, int updateCount); + + [LoggerMessage(103, LogLevel.Debug, "SendMessageAsync: Added {MessageCount} messages to history")] + internal static partial void AddedToHistory(ILogger logger, int messageCount); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentOfT.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentOfT.cs new file mode 100644 index 000000000000..5f10a5b1548a --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentOfT.cs @@ -0,0 +1,122 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Turns an stream into renderable content blocks and typed observable state. +/// +/// The type of state associated with the agent. +public class UIAgent : UIAgent where TState : class, new() +{ + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// The initial state value. + public UIAgent(IChatClient chatClient, TState? initialState = null) + : this(chatClient, new UIAgentOptions(initialState), configure: null, loggerFactory: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// The options passed to the chat client. + /// The initial state value. + public UIAgent(IChatClient chatClient, ChatOptions chatOptions, TState? initialState = null) + : this( + chatClient, + new UIAgentOptions(initialState), + options => options.ChatOptions = chatOptions, + loggerFactory: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// A callback that configures the agent. + /// The initial state value. + public UIAgent( + IChatClient chatClient, + Action> configure, + TState? initialState = null) + : this(chatClient, new UIAgentOptions(initialState), configure, loggerFactory: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The chat client that produces model responses. + /// A callback that configures the agent. + /// The logger factory used to trace block mapping. + /// The initial state value. + public UIAgent( + IChatClient chatClient, + Action> configure, + ILoggerFactory? loggerFactory, + TState? initialState = null) + : this(chatClient, new UIAgentOptions(initialState), configure, loggerFactory) + { + } + + private UIAgent( + IChatClient chatClient, + UIAgentOptions options, + Action>? configure, + ILoggerFactory? loggerFactory) + : base(chatClient, options, loggerFactory) + { + State = options.State; + configure?.Invoke(options); + } + + /// + /// Gets the observable state associated with this agent. + /// + public AgentState State { get; } + + internal override ChatResponseUpdate ApplyStateMapper(ChatResponseUpdate update) + { + if (Options.StateMapper is null) + { + return update; + } + + var context = new StateMapperContext(update); + Options.StateMapper(context); + + if (context.StateValue is not null) + { + if (context.StateValue is not TState typedState) + { + throw new InvalidOperationException( + $"The state mapper returned a value of type '{context.StateValue.GetType()}', " + + $"but this agent requires state of type '{typeof(TState)}'."); + } + + if (context.IsPredictiveState) + { + State.SetPredictiveValue(typedState); + } + else + { + State.Value = typedState; + } + } + + return context.HasHandledContent ? context.GetFilteredUpdate() : update; + } + + internal override void RejectPendingPredictiveState() + { + State.RejectPredictiveState(); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj new file mode 100644 index 000000000000..06236046177b --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj @@ -0,0 +1,45 @@ + + + + $(DefaultNetCoreTargetFramework) + 0.1.0 + + $(AspNetCoreMajorMinorVersion).0.0 + enable + enable + true + true + true + Blazor component library for building AI conversational UIs on top of Microsoft.Extensions.AI. + blazor;ai;chat;components + + $(NoWarn);RS0026 + true + preview + 1 + + + + + + + + + + + + + + + + + + + + + diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ActivityHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ActivityHandler.cs new file mode 100644 index 000000000000..dd9488839c26 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ActivityHandler.cs @@ -0,0 +1,72 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Maps activity snapshots and updates into a mutable content block. +/// +/// The activity block type. +public abstract class ActivityHandler : ContentBlockHandler + where TBlock : ActivityContentBlock, new() +{ + /// + public sealed override BlockMappingResult Handle( + BlockMappingContext context, + TBlock state) + { + if (state.Id == string.Empty) + { + if (TryCreateBlock(context, state)) + { + if (state.Id.Length == 0) + { + state.Id = context.Update.MessageId ?? Guid.NewGuid().ToString("N"); + } + + OnContentUpdated(state); + return BlockMappingResult.Emit(state, state); + } + + return BlockMappingResult.Pass(); + } + + if (TryUpdateBlock(context, state, out var isCompleted)) + { + OnContentUpdated(state); + return isCompleted + ? BlockMappingResult.Complete() + : BlockMappingResult.Update(state); + } + + return BlockMappingResult.Pass(); + } + + /// + /// Attempts to initialize a block from an activity snapshot. + /// + /// The update being mapped. + /// The block to initialize. + /// when the update created the block. + protected abstract bool TryCreateBlock(BlockMappingContext context, TBlock state); + + /// + /// Attempts to update an existing activity block. + /// + /// The update being mapped. + /// The block to update. + /// Whether the update completes the activity. + /// when the update belongs to the block. + protected abstract bool TryUpdateBlock( + BlockMappingContext context, + TBlock state, + out bool isCompleted); + + /// + /// Updates derived block state after the activity payload changes. + /// + /// The updated activity block. + protected virtual void OnContentUpdated(TBlock state) + { + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingContext.cs new file mode 100644 index 000000000000..c2262e228e97 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingContext.cs @@ -0,0 +1,171 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Carries a single model update through the block mapping pipeline and tracks which +/// parts of the update handlers have already claimed. +/// +public class BlockMappingContext +{ + private readonly bool[] _handled; + private readonly IReadOnlyList? _handlers; + private int _handledCount; + private bool _updateHandled; + + internal BlockMappingContext( + ChatResponseUpdate update, + IReadOnlyList? handlers = null) + { + Update = update; + _handled = new bool[update.Contents.Count]; + _handlers = handlers; + } + + /// + /// Gets the update being mapped. + /// + public ChatResponseUpdate Update { get; } + + /// + /// Gets the contents of that no handler has claimed yet. + /// + public UnhandledContentsEnumerable UnhandledContents => new(Update.Contents, _handled); + + /// + /// Marks a content item as claimed so that later handlers do not see it. + /// + /// The content item that was handled. + public void MarkHandled(AIContent content) + { + var contents = Update.Contents; + for (var i = 0; i < contents.Count; i++) + { + if (ReferenceEquals(contents[i], content)) + { + if (!_handled[i]) + { + _handled[i] = true; + _handledCount++; + } + return; + } + } + } + + /// + /// Marks the update itself as handled. Use this for updates that carry no content items. + /// + public void MarkUpdateHandled() + { + _updateHandled = true; + } + + /// + /// Gets a value indicating whether every part of the update has been claimed. + /// + public bool AllHandled => + _handledCount >= Update.Contents.Count && (Update.Contents.Count > 0 || _updateHandled); + + internal int HandledProgress => _handledCount + (_updateHandled ? 1 : 0); + + /// + /// Maps content through the available handlers to create a nested block. + /// + /// The content to map. + /// The mapped block, or when no handler accepts the content. + public ContentBlock? CreateInnerBlock(AIContent content) + { + ArgumentNullException.ThrowIfNull(content); + + if (_handlers is null) + { + return null; + } + + var update = new ChatResponseUpdate + { + Role = Update.Role, + AuthorName = Update.AuthorName, + MessageId = Update.MessageId, + Contents = [content], + }; + var context = new BlockMappingContext(update, _handlers); + + foreach (var handler in _handlers) + { + var entry = handler.TryHandle(context); + if (entry is not null) + { + entry.Block.Role = update.Role; + entry.Block.AuthorName = update.AuthorName; + entry.Block.LifecycleState = BlockLifecycleState.Inactive; + return entry.Block; + } + } + + return null; + } + + /// + /// Enumerates the content items of an update that have not been claimed by a handler. + /// + public readonly struct UnhandledContentsEnumerable + { + private readonly IList _contents; + private readonly bool[] _handled; + + internal UnhandledContentsEnumerable(IList contents, bool[] handled) + { + _contents = contents; + _handled = handled; + } + + /// + /// Returns an enumerator over the unclaimed content items. + /// + /// An enumerator over the unclaimed content items. + public UnhandledContentsEnumerator GetEnumerator() => new(_contents, _handled); + } + + /// + /// Enumerator over the content items of an update that have not been claimed by a handler. + /// + public struct UnhandledContentsEnumerator + { + private readonly IList _contents; + private readonly bool[] _handled; + private int _index; + + internal UnhandledContentsEnumerator(IList contents, bool[] handled) + { + _contents = contents; + _handled = handled; + _index = -1; + } + + /// + /// Gets the content item at the current position. + /// + public AIContent Current => _contents[_index]; + + /// + /// Advances to the next unclaimed content item. + /// + /// if another unclaimed item exists; otherwise . + public bool MoveNext() + { + while (++_index < _contents.Count) + { + if (!_handled[_index]) + { + return true; + } + } + return false; + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs new file mode 100644 index 000000000000..46228004cf49 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs @@ -0,0 +1,182 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Linq; +using System.Runtime.CompilerServices; +using Microsoft.Extensions.AI; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; + +namespace Microsoft.AspNetCore.Components.AI; + +// Routes model updates to handlers in two phases: +// 1. Blocks that are still active get first refusal on the update, most recent first. +// This keeps a streaming block accumulating instead of emitting a new block per token. +// 2. Whatever is left is offered to inactive handlers, which may emit new blocks. +internal class BlockMappingPipeline +{ + private readonly List _handlers = new(); + private readonly List _activeStack = new(); + private readonly ILogger _logger; + + internal BlockMappingPipeline(UIAgentOptions options, ILogger? logger = null) + { + _logger = logger ?? NullLogger.Instance; + + // User-registered handlers go first so they can customize behavior + foreach (var registration in options.HandlerRegistrations) + { + _handlers.Add(registration.CreateEntry()); + } + + if (options.UIActions.Count > 0) + { + _handlers.Add(new HandlerEntry( + new UIActionHandler(options.UIActions))); + } + + _handlers.Add(new HandlerEntry( + new FunctionApprovalHandler())); + + _handlers.Add(new HandlerEntry( + new FunctionInvocationHandler())); + + // Structured snapshots take precedence over the plain-text fallback. + _handlers.Add(new HandlerEntry(new RichTextContentHandler())); + + // Built-in plain-text handler is always last (fallback). + _handlers.Add(new HandlerEntry(new TextBlockHandler())); + } + + internal async IAsyncEnumerable Process( + ChatResponseUpdate update, +#pragma warning disable IDE0060 // cancellationToken reserved for future use + [EnumeratorCancellation] CancellationToken cancellationToken = default) +#pragma warning restore IDE0060 + { + var contentTypes = string.Join(", ", update.Contents.Select(c => c.GetType().Name)); + BlockMappingPipelineLog.ProcessingUpdate(_logger, update.Role?.Value, update.Contents.Count, contentTypes); + + var context = new BlockMappingContext(update, _handlers); + + // Phase 1: Active entries get priority (most recent first) + for (var i = _activeStack.Count - 1; i >= 0; i--) + { + if (context.AllHandled) + { + break; + } + + var active = _activeStack[i]; + var result = active.Invoke(context); + + BlockMappingPipelineLog.ActiveHandlerResult(_logger, active.Block.GetType().Name, result.Kind.ToString(), active.Block.Id); + + switch (result.Kind) + { + case HandleResult.ResultKind.Pass: + break; + + case HandleResult.ResultKind.Update: + active.Block.InvokeNotifyChanged(); + break; + + case HandleResult.ResultKind.Complete: + active.Block.LifecycleState = BlockLifecycleState.Inactive; + active.Block.InvokeNotifyChanged(); + _activeStack.RemoveAt(i); + break; + } + } + + // Phase 2: Inactive handlers try to claim remaining content + if (!context.AllHandled) + { + for (var i = 0; i < _handlers.Count; i++) + { + if (context.AllHandled) + { + break; + } + + var handler = _handlers[i]; + BlockMappingPipelineLog.TryingInactiveHandler(_logger, handler.GetType().Name); + + while (!context.AllHandled) + { + var progressBefore = context.HandledProgress; + var activeEntry = handler.TryHandle(context); + if (activeEntry is null) + { + break; + } + + var emitBlock = activeEntry.Block; + emitBlock.Role = update.Role; + emitBlock.AuthorName = update.AuthorName; + emitBlock.LifecycleState = BlockLifecycleState.Active; + ThrowIfIdMissing(emitBlock); + + var keepActive = true; + if (emitBlock is FunctionInvocationContentBlock) + { + var catchUpResult = activeEntry.Invoke(context); + + BlockMappingPipelineLog.ActiveHandlerResult(_logger, emitBlock.GetType().Name, catchUpResult.Kind.ToString(), emitBlock.Id); + + if (catchUpResult.Kind == HandleResult.ResultKind.Complete) + { + emitBlock.LifecycleState = BlockLifecycleState.Inactive; + keepActive = false; + } + } + + if (keepActive) + { + _activeStack.Add(activeEntry); + } + + BlockMappingPipelineLog.EmittingBlock(_logger, emitBlock.GetType().Name, emitBlock.Id, emitBlock.Role?.Value); + + yield return emitBlock; + + // If the handler emitted without consuming any content, stop + // re-invoking it to prevent infinite loops. + if (context.HandledProgress == progressBefore) + { + break; + } + } + } + } + else + { + BlockMappingPipelineLog.AllContentHandledAfterPhase1(_logger); + } + + await Task.CompletedTask; + } + + internal IReadOnlyList Finalize() + { + BlockMappingPipelineLog.Finalizing(_logger, _activeStack.Count); + + foreach (var active in _activeStack) + { + active.Block.LifecycleState = BlockLifecycleState.Inactive; + active.Block.InvokeNotifyChanged(); + } + _activeStack.Clear(); + + return Array.Empty(); + } + + private static void ThrowIfIdMissing(ContentBlock block) + { + if (string.IsNullOrEmpty(block.Id)) + { + throw new InvalidOperationException( + $"Block handler emitted a {block.GetType().Name} without assigning an Id."); + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs new file mode 100644 index 000000000000..a526003ac207 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.Components.AI; + +internal static partial class BlockMappingPipelineLog +{ + [LoggerMessage(1, LogLevel.Debug, "Processing update: Role={Role}, ContentCount={ContentCount}, ContentTypes=[{ContentTypes}]")] + internal static partial void ProcessingUpdate(ILogger logger, string? role, int contentCount, string contentTypes); + + [LoggerMessage(2, LogLevel.Debug, "Active handler {HandlerType} returned {ResultKind} for block {BlockId}")] + internal static partial void ActiveHandlerResult(ILogger logger, string handlerType, string resultKind, string? blockId); + + [LoggerMessage(3, LogLevel.Information, "Emitting new block: {BlockType} Id={BlockId} Role={Role}")] + internal static partial void EmittingBlock(ILogger logger, string blockType, string? blockId, string? role); + + [LoggerMessage(4, LogLevel.Debug, "Phase 2: Trying inactive handler {HandlerType} to claim remaining content")] + internal static partial void TryingInactiveHandler(ILogger logger, string handlerType); + + [LoggerMessage(5, LogLevel.Debug, "Finalize: Deactivating {ActiveCount} active blocks")] + internal static partial void Finalizing(ILogger logger, int activeCount); + + [LoggerMessage(6, LogLevel.Debug, "All content handled after active handlers, skipping Phase 2")] + internal static partial void AllContentHandledAfterPhase1(ILogger logger); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingResult.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingResult.cs new file mode 100644 index 000000000000..4d02957ef03b --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingResult.cs @@ -0,0 +1,57 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// The outcome of a invocation. +/// +/// The state the handler keeps across updates. +public readonly struct BlockMappingResult +{ + internal enum ResultKind { Pass, Emit, Update, Complete } + + internal ResultKind Kind { get; } + + internal ContentBlock? Block { get; } + + internal TState? State { get; } + + private BlockMappingResult(ResultKind kind, ContentBlock? block, TState? state) + { + Kind = kind; + Block = block; + State = state; + } + + /// + /// Indicates that the handler did not claim anything from the update. + /// + /// A result that leaves the update for other handlers. + public static BlockMappingResult Pass() => new(ResultKind.Pass, null, default); + + /// + /// Indicates that the handler produced a new block for the conversation. + /// + /// The block to add to the conversation. + /// The state to carry into subsequent updates. + /// A result that emits . + public static BlockMappingResult Emit(ContentBlock block, TState state) + { + ArgumentNullException.ThrowIfNull(block); + return new(ResultKind.Emit, block, state); + } + + /// + /// Indicates that the handler updated the block it previously emitted. + /// + /// The updated state. + /// A result that notifies the UI that the block changed. + public static BlockMappingResult Update(TState state) => new(ResultKind.Update, null, state); + + /// + /// Indicates that the block the handler emitted is complete. + /// + /// A result that deactivates the block. + public static BlockMappingResult Complete() => new(ResultKind.Complete, null, default); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ContentBlockHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ContentBlockHandler.cs new file mode 100644 index 000000000000..514980c728b3 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ContentBlockHandler.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Maps model updates into content blocks. A handler is invoked for every update until it +/// completes the block it emitted. +/// +/// The state the handler keeps across updates for a single block. +/// +/// +/// internal sealed class EchoHandler : ContentBlockHandler<RichContentBlock> +/// { +/// public override BlockMappingResult<RichContentBlock> Handle( +/// BlockMappingContext context, RichContentBlock state) +/// => BlockMappingResult<RichContentBlock>.Pass(); +/// } +/// +/// +public abstract class ContentBlockHandler where TState : new() +{ + /// + /// Handles an update. + /// + /// The update being mapped. + /// The state for the block this handler owns. + /// The outcome of the invocation. + public abstract BlockMappingResult Handle(BlockMappingContext context, TState state); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs new file mode 100644 index 000000000000..d5ff5164a434 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs @@ -0,0 +1,60 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +internal sealed class FunctionApprovalHandler : + ContentBlockHandler +{ + public override BlockMappingResult Handle(BlockMappingContext context, State state) + { + if (state.Emitted) + { + return BlockMappingResult.Complete(); + } + + foreach (var content in context.UnhandledContents) + { + if (content is not ToolApprovalRequestContent approvalRequest) + { + continue; + } + + context.MarkHandled(approvalRequest); + + var innerBlock = context.CreateInnerBlock(approvalRequest.ToolCall) + ?? CreateFallbackInnerBlock(approvalRequest.ToolCall); + + state.Emitted = true; + return BlockMappingResult.Emit( + new FunctionApprovalBlock(innerBlock, approvalRequest) + { + Id = approvalRequest.ToolCall is FunctionCallContent functionCall + ? functionCall.CallId ?? approvalRequest.RequestId + : approvalRequest.RequestId + }, + state); + } + + return BlockMappingResult.Pass(); + } + + private static FunctionInvocationContentBlock CreateFallbackInnerBlock( + ToolCallContent toolCall) + { + var block = new FunctionInvocationContentBlock(); + if (toolCall is FunctionCallContent functionCall) + { + block.Call = functionCall; + } + + return block; + } + + internal sealed class State + { + internal bool Emitted { get; set; } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs new file mode 100644 index 000000000000..367fd0063a1b --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +internal sealed class FunctionInvocationHandler : ContentBlockHandler +{ + public override BlockMappingResult Handle( + BlockMappingContext context, + FunctionInvocationContentBlock state) + { + if (state.Result is not null) + { + return BlockMappingResult.Complete(); + } + + var shouldEmit = false; + if (state.Call is null) + { + foreach (var content in context.UnhandledContents) + { + if (content is FunctionCallContent call) + { + context.MarkHandled(call); + state.Call = call; + shouldEmit = true; + break; + } + } + } + + if (state.Call is not null) + { + foreach (var content in context.UnhandledContents) + { + if (content is FunctionResultContent result && + result.CallId == state.Call.CallId) + { + context.MarkHandled(result); + state.Result = result; + return shouldEmit + ? BlockMappingResult.Emit(state, state) + : BlockMappingResult.Complete(); + } + } + } + + return shouldEmit + ? BlockMappingResult.Emit(state, state) + : BlockMappingResult.Pass(); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandleResult.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandleResult.cs new file mode 100644 index 000000000000..c48b3795f68b --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandleResult.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +internal readonly struct HandleResult +{ + internal enum ResultKind { Pass, Update, Complete } + + internal ResultKind Kind { get; } + + private HandleResult(ResultKind kind) + { + Kind = kind; + } + + internal static HandleResult Pass() => new(ResultKind.Pass); + + internal static HandleResult Update() => new(ResultKind.Update); + + internal static HandleResult Complete() => new(ResultKind.Complete); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandlerEntry.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandlerEntry.cs new file mode 100644 index 000000000000..9b2fd5764871 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandlerEntry.cs @@ -0,0 +1,61 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +internal sealed class HandlerEntry : IHandlerEntry where TState : new() +{ + private readonly ContentBlockHandler _handler; + + internal HandlerEntry(ContentBlockHandler handler) + { + _handler = handler; + } + + public IActiveEntry? TryHandle(BlockMappingContext context) + { + var state = new TState(); + var result = _handler.Handle(context, state); + if (result.Kind == BlockMappingResult.ResultKind.Emit) + { + return new ActiveEntry(_handler, result.State!, result.Block!); + } + + return null; + } + + private sealed class ActiveEntry : IActiveEntry + { + private readonly ContentBlockHandler _handler; + private TState _state; + + internal ActiveEntry( + ContentBlockHandler handler, + TState state, + ContentBlock block) + { + _handler = handler; + _state = state; + Block = block; + } + + public ContentBlock Block { get; } + + public HandleResult Invoke(BlockMappingContext context) + { + var result = _handler.Handle(context, _state); + switch (result.Kind) + { + case BlockMappingResult.ResultKind.Update: + _state = result.State!; + return HandleResult.Update(); + + case BlockMappingResult.ResultKind.Complete: + return HandleResult.Complete(); + + default: + return HandleResult.Pass(); + } + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IActiveEntry.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IActiveEntry.cs new file mode 100644 index 000000000000..555f43c83993 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IActiveEntry.cs @@ -0,0 +1,11 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +internal interface IActiveEntry +{ + ContentBlock Block { get; } + + HandleResult Invoke(BlockMappingContext context); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IHandlerEntry.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IHandlerEntry.cs new file mode 100644 index 000000000000..89d58b292ee8 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IHandlerEntry.cs @@ -0,0 +1,9 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.AspNetCore.Components.AI; + +internal interface IHandlerEntry +{ + IActiveEntry? TryHandle(BlockMappingContext context); +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/RichTextContentHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/RichTextContentHandler.cs new file mode 100644 index 000000000000..acad1a443a7e --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/RichTextContentHandler.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +internal sealed class RichTextContentHandler : ContentBlockHandler +{ + public override BlockMappingResult Handle( + BlockMappingContext context, RichContentBlock state) + { + RichTextContent? snapshot = null; + foreach (var content in context.UnhandledContents) + { + if (content is RichTextContent richText) + { + snapshot = richText; + } + } + + if (snapshot is null) + { + return state.Id.Length > 0 + ? BlockMappingResult.Complete() + : BlockMappingResult.Pass(); + } + + if (state.Id.Length > 0 && + context.Update.MessageId is { Length: > 0 } messageId && + !string.Equals(state.Id, messageId, StringComparison.Ordinal)) + { + return BlockMappingResult.Complete(); + } + + foreach (var content in context.UnhandledContents) + { + if (content is RichTextContent or TextContent) + { + context.MarkHandled(content); + } + } + + state.ReplaceContent(snapshot.Text, snapshot.Nodes); + + if (state.Id.Length == 0) + { + state.Id = context.Update.MessageId ?? Guid.NewGuid().ToString("N"); + return BlockMappingResult.Emit(state, state); + } + + return BlockMappingResult.Update(state); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/StateMapperContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/StateMapperContext.cs new file mode 100644 index 000000000000..fb1cce621d74 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/StateMapperContext.cs @@ -0,0 +1,131 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Carries a model update through typed state mapping and tracks content consumed as state. +/// +public class StateMapperContext +{ + private readonly bool[] _handled; + private int _handledCount; + + internal StateMapperContext(ChatResponseUpdate update) + { + Update = update; + _handled = new bool[update.Contents.Count]; + } + + /// + /// Gets the update being mapped. + /// + public ChatResponseUpdate Update { get; } + + /// + /// Gets content items that have not been consumed by the state mapper. + /// + public IEnumerable UnhandledContents + { + get + { + var contents = Update.Contents; + for (var i = 0; i < contents.Count; i++) + { + if (!_handled[i]) + { + yield return contents[i]; + } + } + } + } + + /// + /// Marks a content item as consumed by the state mapper. + /// + /// The content item that was handled. + public void MarkHandled(AIContent content) + { + ArgumentNullException.ThrowIfNull(content); + + var contents = Update.Contents; + for (var i = 0; i < contents.Count; i++) + { + if (ReferenceEquals(contents[i], content)) + { + if (!_handled[i]) + { + _handled[i] = true; + _handledCount++; + } + + return; + } + } + } + + internal object? StateValue { get; private set; } + + internal bool IsPredictiveState { get; private set; } + + /// + /// Sets the next typed state value. + /// + /// The next state value. + public void SetState(object value) + { + ArgumentNullException.ThrowIfNull(value); + StateValue = value; + IsPredictiveState = false; + } + + /// + /// Sets a provisional typed state value that must be accepted or rejected before the turn + /// completes. + /// + /// The next provisional state value. + public void SetPredictiveState(object value) + { + ArgumentNullException.ThrowIfNull(value); + StateValue = value; + IsPredictiveState = true; + } + + internal bool HasHandledContent => _handledCount > 0; + + internal ChatResponseUpdate GetFilteredUpdate() + { + if (_handledCount == 0) + { + return Update; + } + + var filtered = new List(); + var contents = Update.Contents; + for (var i = 0; i < contents.Count; i++) + { + if (!_handled[i]) + { + filtered.Add(contents[i]); + } + } + + return new ChatResponseUpdate + { + Role = Update.Role, + AuthorName = Update.AuthorName, + MessageId = Update.MessageId, + ResponseId = Update.ResponseId, + ConversationId = Update.ConversationId, + CreatedAt = Update.CreatedAt, + FinishReason = Update.FinishReason, + ModelId = Update.ModelId, + ContinuationToken = Update.ContinuationToken, + RawRepresentation = Update.RawRepresentation, + AdditionalProperties = Update.AdditionalProperties, + Contents = filtered, + }; + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/TextBlockHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/TextBlockHandler.cs new file mode 100644 index 000000000000..b8b5c04113f8 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/TextBlockHandler.cs @@ -0,0 +1,91 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +// Fallback handler: claims TextContent and accumulates it into a single block for the +// duration of a model message. It runs last so more specific handlers get first refusal. +internal sealed class TextBlockHandler : ContentBlockHandler +{ + public override BlockMappingResult Handle( + BlockMappingContext context, RichContentBlock state) + { + TextContent? textContent = null; + foreach (var content in context.UnhandledContents) + { + if (content is TextContent tc) + { + textContent = tc; + break; + } + } + + if (textContent is null) + { + if (state.Id != string.Empty) + { + return BlockMappingResult.Complete(); + } + + return BlockMappingResult.Pass(); + } + + context.MarkHandled(textContent); + state.AppendText(textContent.Text ?? string.Empty); + RebuildParagraphs(state); + + if (state.Id == string.Empty) + { + state.Id = context.Update.MessageId ?? Guid.NewGuid().ToString("N"); + return BlockMappingResult.Emit(state, state); + } + + return BlockMappingResult.Update(state); + } + + internal static void RebuildParagraphs(RichContentBlock state) + { + var rawText = state.RawText; + if (rawText.Length == 0) + { + state.Content = Array.Empty(); + return; + } + + var paragraphs = new List(); + var start = 0; + while (start < rawText.Length) + { + var breakIndex = rawText.IndexOf("\n\n", start, StringComparison.Ordinal); + if (breakIndex < 0) + { + AddParagraph(paragraphs, rawText.AsSpan(start)); + break; + } + + if (breakIndex > start) + { + AddParagraph(paragraphs, rawText.AsSpan(start, breakIndex - start)); + } + + start = breakIndex + 2; + } + + state.Content = paragraphs; + } + + private static void AddParagraph(List paragraphs, ReadOnlySpan text) + { + var trimmed = text.TrimEnd("\r\n".AsSpan()); + if (trimmed.Length == 0) + { + return; + } + + var paragraph = new ParagraphNode(); + paragraph.AddChild(new TextNode(trimmed.ToString())); + paragraphs.Add(paragraph); + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIActionHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIActionHandler.cs new file mode 100644 index 000000000000..f1c2ee27c9fe --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIActionHandler.cs @@ -0,0 +1,48 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +internal sealed class UIActionHandler : ContentBlockHandler +{ + private readonly IReadOnlyDictionary _actions; + + internal UIActionHandler(IReadOnlyDictionary actions) + { + _actions = actions; + } + + public override BlockMappingResult Handle(BlockMappingContext context, State state) + { + if (state.HasEmitted) + { + return BlockMappingResult.Pass(); + } + + foreach (var content in context.UnhandledContents) + { + if (content is FunctionCallContent call && + !call.InformationalOnly && + _actions.TryGetValue(call.Name, out var function)) + { + context.MarkHandled(call); + state.HasEmitted = true; + return BlockMappingResult.Emit( + new UIActionBlock(function, call) + { + Id = call.CallId ?? Guid.NewGuid().ToString("N") + }, + state); + } + } + + return BlockMappingResult.Pass(); + } + + internal sealed class State + { + public bool HasEmitted { get; set; } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIAgentOptions.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIAgentOptions.cs new file mode 100644 index 000000000000..546e27e5e4ed --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIAgentOptions.cs @@ -0,0 +1,104 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Extensions.AI; + +namespace Microsoft.AspNetCore.Components.AI; + +/// +/// Configures a . +/// +/// +/// +/// var agent = new UIAgent(chatClient, options => +/// { +/// options.ChatOptions = new ChatOptions { Instructions = "You are a helpful assistant." }; +/// }); +/// +/// +public class UIAgentOptions +{ + /// + /// Gets or sets the options passed to the underlying . + /// + public ChatOptions? ChatOptions { get; set; } + + /// + /// Gets or sets a callback that maps model updates into typed agent state. + /// + public Action? StateMapper { get; set; } + + /// + /// Gets or sets the persistent conversation thread that receives completed turns. + /// + public IConversationThread? Thread { get; set; } + + internal List HandlerRegistrations { get; } = new(); + + internal Dictionary UIActions { get; } = + new(StringComparer.Ordinal); + + /// + /// Registers a handler that maps model updates into content blocks. Registered handlers + /// run before the built-in ones, so they can claim content the built-in handlers would + /// otherwise map. + /// + /// The state the handler keeps across updates. + /// The handler to register. + public void AddBlockHandler(ContentBlockHandler handler) + where TState : new() + { + ArgumentNullException.ThrowIfNull(handler); + HandlerRegistrations.Add(new HandlerRegistration(handler)); + } + + /// + /// Registers a function that a matching model tool call executes in the UI. + /// The function is sent to the chat client as a declaration, not as an executable server tool. + /// + /// + /// The function to execute in the UI. Its name must be unique among the registered UI actions. + /// + /// + /// An action with the same name is already registered. + /// + public void RegisterUIAction(AIFunction function) + { + ArgumentNullException.ThrowIfNull(function); + UIActions.Add(function.Name, function); + } + + internal interface IHandlerRegistration + { + IHandlerEntry CreateEntry(); + } + + private sealed class HandlerRegistration : IHandlerRegistration where TState : new() + { + private readonly ContentBlockHandler _handler; + + internal HandlerRegistration(ContentBlockHandler handler) + { + _handler = handler; + } + + public IHandlerEntry CreateEntry() => new HandlerEntry(_handler); + } +} + +/// +/// Configures a . +/// +/// The type of state associated with the agent. +public sealed class UIAgentOptions : UIAgentOptions where TState : class, new() +{ + internal UIAgentOptions(TState? initialState) + { + State = new AgentState(initialState); + } + + /// + /// Gets the observable state associated with the agent. + /// + public AgentState State { get; } +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Shipped.txt b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Shipped.txt new file mode 100644 index 000000000000..7dc5c58110bf --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Unshipped.txt b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Unshipped.txt new file mode 100644 index 000000000000..2241a1e6ba68 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Unshipped.txt @@ -0,0 +1,360 @@ +#nullable enable +Microsoft.AspNetCore.Components.AI.AgentBoundary +Microsoft.AspNetCore.Components.AI.AgentBoundary.Agent.get -> Microsoft.AspNetCore.Components.AI.UIAgent! +Microsoft.AspNetCore.Components.AI.AgentBoundary.Agent.set -> void +Microsoft.AspNetCore.Components.AI.AgentBoundary.AgentBoundary() -> void +Microsoft.AspNetCore.Components.AI.AgentBoundary.ChildContent.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.AgentBoundary.ChildContent.set -> void +Microsoft.AspNetCore.Components.AI.AgentBoundary.Dispose() -> void +Microsoft.AspNetCore.Components.AI.AgentState +Microsoft.AspNetCore.Components.AI.AgentState.AcceptPredictiveState() -> void +Microsoft.AspNetCore.Components.AI.AgentState.HasPendingPredictiveState.get -> bool +Microsoft.AspNetCore.Components.AI.AgentState.OnChanged(System.Action! callback) -> System.IDisposable! +Microsoft.AspNetCore.Components.AI.AgentState.RejectPredictiveState() -> void +Microsoft.AspNetCore.Components.AI.AgentState.Value.get -> T! +Microsoft.AspNetCore.Components.AI.AgentState.Value.set -> void +Microsoft.AspNetCore.Components.AI.AgentContext +Microsoft.AspNetCore.Components.AI.AgentContext.AgentContext(Microsoft.AspNetCore.Components.AI.UIAgent! agent) -> void +Microsoft.AspNetCore.Components.AI.AgentContext.CancelAsync() -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.AgentContext.Dispose() -> void +Microsoft.AspNetCore.Components.AI.AgentContext.Error.get -> System.Exception? +Microsoft.AspNetCore.Components.AI.AgentContext.RegisterOnBlockAdded(System.Action! callback) -> System.IDisposable! +Microsoft.AspNetCore.Components.AI.AgentContext.RegisterOnStatusChanged(System.Action! callback) -> System.IDisposable! +Microsoft.AspNetCore.Components.AI.AgentContext.RegisterOnTurnAdded(System.Action! callback) -> System.IDisposable! +Microsoft.AspNetCore.Components.AI.AgentContext.RetryAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.AgentContext.RestoreAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.AgentContext.SendMessageAsync(Microsoft.Extensions.AI.ChatMessage! message, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.AgentContext.SendMessageAsync(string! text, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.AgentContext.Status.get -> Microsoft.AspNetCore.Components.AI.ConversationStatus +Microsoft.AspNetCore.Components.AI.AgentContext.Turns.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.ApprovalStatus +Microsoft.AspNetCore.Components.AI.ApprovalStatus.Approved = 1 -> Microsoft.AspNetCore.Components.AI.ApprovalStatus +Microsoft.AspNetCore.Components.AI.ApprovalStatus.Pending = 0 -> Microsoft.AspNetCore.Components.AI.ApprovalStatus +Microsoft.AspNetCore.Components.AI.ApprovalStatus.Rejected = 2 -> Microsoft.AspNetCore.Components.AI.ApprovalStatus +Microsoft.AspNetCore.Components.AI.ActivityContentBlock +Microsoft.AspNetCore.Components.AI.ActivityContentBlock.ActivityContentBlock() -> void +Microsoft.AspNetCore.Components.AI.ActivityContentBlock.ActivityType.get -> string! +Microsoft.AspNetCore.Components.AI.ActivityContentBlock.ActivityType.set -> void +Microsoft.AspNetCore.Components.AI.ActivityContentBlock.Content.get -> System.Text.Json.JsonElement +Microsoft.AspNetCore.Components.AI.ActivityContentBlock.Content.set -> void +Microsoft.AspNetCore.Components.AI.ActivityHandler +Microsoft.AspNetCore.Components.AI.ActivityHandler.ActivityHandler() -> void +Microsoft.AspNetCore.Components.AI.BlockLifecycleState +Microsoft.AspNetCore.Components.AI.BlockLifecycleState.Active = 1 -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState +Microsoft.AspNetCore.Components.AI.BlockLifecycleState.Inactive = 2 -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState +Microsoft.AspNetCore.Components.AI.BlockLifecycleState.Pending = 0 -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState +Microsoft.AspNetCore.Components.AI.BlockMappingContext +Microsoft.AspNetCore.Components.AI.BlockMappingContext.AllHandled.get -> bool +Microsoft.AspNetCore.Components.AI.BlockMappingContext.CreateInnerBlock(Microsoft.Extensions.AI.AIContent! content) -> Microsoft.AspNetCore.Components.AI.ContentBlock? +Microsoft.AspNetCore.Components.AI.BlockMappingContext.MarkHandled(Microsoft.Extensions.AI.AIContent! content) -> void +Microsoft.AspNetCore.Components.AI.BlockMappingContext.MarkUpdateHandled() -> void +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContents.get -> Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable.GetEnumerator() -> Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable.UnhandledContentsEnumerable() -> void +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator.Current.get -> Microsoft.Extensions.AI.AIContent! +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator.MoveNext() -> bool +Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator.UnhandledContentsEnumerator() -> void +Microsoft.AspNetCore.Components.AI.BlockMappingContext.Update.get -> Microsoft.Extensions.AI.ChatResponseUpdate! +Microsoft.AspNetCore.Components.AI.BlockMappingResult +Microsoft.AspNetCore.Components.AI.BlockMappingResult.BlockMappingResult() -> void +Microsoft.AspNetCore.Components.AI.BlockQuoteNode +Microsoft.AspNetCore.Components.AI.BlockQuoteNode.BlockQuoteNode() -> void +Microsoft.AspNetCore.Components.AI.BlockRenderer +Microsoft.AspNetCore.Components.AI.BlockRenderer.BlockRenderer() -> void +Microsoft.AspNetCore.Components.AI.BlockRenderer.ChildContent.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.BlockRenderer.ChildContent.set -> void +Microsoft.AspNetCore.Components.AI.BlockRenderer.Dispose() -> void +Microsoft.AspNetCore.Components.AI.BlockRenderer.ListContext.get -> Microsoft.AspNetCore.Components.AI.MessageListContext! +Microsoft.AspNetCore.Components.AI.BlockRenderer.ListContext.set -> void +Microsoft.AspNetCore.Components.AI.BlockRenderer.When.get -> System.Func? +Microsoft.AspNetCore.Components.AI.BlockRenderer.When.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage +Microsoft.AspNetCore.Components.AI.ChatPage.AdditionalAttributes.get -> System.Collections.Generic.Dictionary? +Microsoft.AspNetCore.Components.AI.ChatPage.AdditionalAttributes.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.Agent.get -> Microsoft.AspNetCore.Components.AI.UIAgent! +Microsoft.AspNetCore.Components.AI.ChatPage.Agent.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.ChatPage() -> void +Microsoft.AspNetCore.Components.AI.ChatPage.Header.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.ChatPage.Header.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.InputLeadingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.ChatPage.InputLeadingActions.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.InputTrailingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.ChatPage.InputTrailingActions.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.MessageListContent.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.ChatPage.MessageListContent.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.Placeholder.get -> string? +Microsoft.AspNetCore.Components.AI.ChatPage.Placeholder.set -> void +Microsoft.AspNetCore.Components.AI.ChatPage.WelcomeContent.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.ChatPage.WelcomeContent.set -> void +Microsoft.AspNetCore.Components.AI.CodeBlockNode +Microsoft.AspNetCore.Components.AI.CodeBlockNode.Code.get -> string! +Microsoft.AspNetCore.Components.AI.CodeBlockNode.Code.set -> void +Microsoft.AspNetCore.Components.AI.CodeBlockNode.CodeBlockNode() -> void +Microsoft.AspNetCore.Components.AI.CodeBlockNode.CodeBlockNode(string! code, string? language = null) -> void +Microsoft.AspNetCore.Components.AI.CodeBlockNode.Language.get -> string? +Microsoft.AspNetCore.Components.AI.CodeBlockNode.Language.set -> void +Microsoft.AspNetCore.Components.AI.ContentBlock +Microsoft.AspNetCore.Components.AI.ContentBlock.AuthorName.get -> string? +Microsoft.AspNetCore.Components.AI.ContentBlock.ContentBlock() -> void +Microsoft.AspNetCore.Components.AI.ContentBlock.Id.get -> string! +Microsoft.AspNetCore.Components.AI.ContentBlock.LifecycleState.get -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState +Microsoft.AspNetCore.Components.AI.ContentBlock.NotifyChanged() -> void +Microsoft.AspNetCore.Components.AI.ContentBlock.OnChanged(System.Action! callback) -> Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription +Microsoft.AspNetCore.Components.AI.ContentBlock.Role.get -> Microsoft.Extensions.AI.ChatRole? +Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription +Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription.ContentBlockChangedSubscription() -> void +Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription.Dispose() -> void +Microsoft.AspNetCore.Components.AI.ContentBlockHandler +Microsoft.AspNetCore.Components.AI.ContentBlockHandler.ContentBlockHandler() -> void +Microsoft.AspNetCore.Components.AI.ConversationStatus +Microsoft.AspNetCore.Components.AI.ConversationStatus.AwaitingInput = 2 -> Microsoft.AspNetCore.Components.AI.ConversationStatus +Microsoft.AspNetCore.Components.AI.ConversationStatus.Error = 3 -> Microsoft.AspNetCore.Components.AI.ConversationStatus +Microsoft.AspNetCore.Components.AI.ConversationStatus.Idle = 0 -> Microsoft.AspNetCore.Components.AI.ConversationStatus +Microsoft.AspNetCore.Components.AI.ConversationStatus.Streaming = 1 -> Microsoft.AspNetCore.Components.AI.ConversationStatus +Microsoft.AspNetCore.Components.AI.ConversationTurn +Microsoft.AspNetCore.Components.AI.ConversationTurn.ConversationTurn() -> void +Microsoft.AspNetCore.Components.AI.ConversationTurn.Id.get -> string! +Microsoft.AspNetCore.Components.AI.ConversationTurn.RequestBlocks.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.ConversationTurn.ResponseBlocks.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.DefinitionNode +Microsoft.AspNetCore.Components.AI.DefinitionNode.DefinitionNode() -> void +Microsoft.AspNetCore.Components.AI.DefinitionNode.Label.get -> string! +Microsoft.AspNetCore.Components.AI.DefinitionNode.Label.set -> void +Microsoft.AspNetCore.Components.AI.DefinitionNode.Title.get -> string? +Microsoft.AspNetCore.Components.AI.DefinitionNode.Title.set -> void +Microsoft.AspNetCore.Components.AI.DefinitionNode.Url.get -> string! +Microsoft.AspNetCore.Components.AI.DefinitionNode.Url.set -> void +Microsoft.AspNetCore.Components.AI.EmphasisNode +Microsoft.AspNetCore.Components.AI.EmphasisNode.EmphasisNode() -> void +Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode +Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode.FootnoteDefinitionNode() -> void +Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode.Label.get -> string! +Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode.Label.set -> void +Microsoft.AspNetCore.Components.AI.FootnoteNode +Microsoft.AspNetCore.Components.AI.FootnoteNode.FootnoteNode() -> void +Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode +Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode.FootnoteReferenceNode() -> void +Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode.Label.get -> string! +Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode.Label.set -> void +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Arguments.get -> System.Collections.Generic.IDictionary? +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.ApprovalRequest.get -> Microsoft.Extensions.AI.ToolApprovalRequestContent! +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Approve() -> void +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Call.get -> Microsoft.Extensions.AI.FunctionCallContent? +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.GetResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.HasResult.get -> bool +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.InnerBlock.get -> Microsoft.AspNetCore.Components.AI.ContentBlock! +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Reject(string? reason = null) -> void +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Result.get -> Microsoft.Extensions.AI.FunctionResultContent? +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Status.get -> Microsoft.AspNetCore.Components.AI.ApprovalStatus +Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.ToolName.get -> string? +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Arguments.get -> System.Collections.Generic.IDictionary? +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Call.get -> Microsoft.Extensions.AI.FunctionCallContent? +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Call.set -> void +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.FunctionInvocationContentBlock() -> void +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.HasResult.get -> bool +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Result.get -> Microsoft.Extensions.AI.FunctionResultContent? +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Result.set -> void +Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.ToolName.get -> string? +Microsoft.AspNetCore.Components.AI.HeadingNode +Microsoft.AspNetCore.Components.AI.HeadingNode.HeadingNode() -> void +Microsoft.AspNetCore.Components.AI.HeadingNode.HeadingNode(int level) -> void +Microsoft.AspNetCore.Components.AI.HeadingNode.Level.get -> int +Microsoft.AspNetCore.Components.AI.HeadingNode.Level.set -> void +Microsoft.AspNetCore.Components.AI.HtmlNode +Microsoft.AspNetCore.Components.AI.HtmlNode.HtmlNode() -> void +Microsoft.AspNetCore.Components.AI.HtmlNode.HtmlNode(string! value) -> void +Microsoft.AspNetCore.Components.AI.HtmlNode.Value.get -> string! +Microsoft.AspNetCore.Components.AI.HtmlNode.Value.set -> void +Microsoft.AspNetCore.Components.AI.IInteractiveBlock +Microsoft.AspNetCore.Components.AI.IInteractiveBlock.GetResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.IConversationThread +Microsoft.AspNetCore.Components.AI.IConversationThread.AppendUpdate(Microsoft.Extensions.AI.ChatResponseUpdate! update) -> void +Microsoft.AspNetCore.Components.AI.IConversationThread.AppendUserMessage(Microsoft.Extensions.AI.ChatMessage! message) -> void +Microsoft.AspNetCore.Components.AI.IConversationThread.CompleteTurn() -> void +Microsoft.AspNetCore.Components.AI.IConversationThread.ConversationId.get -> string? +Microsoft.AspNetCore.Components.AI.IConversationThread.GetUpdates() -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.IConversationThread.IsStateful.get -> bool +Microsoft.AspNetCore.Components.AI.IConversationThread.ThreadId.get -> string! +Microsoft.AspNetCore.Components.AI.ImageNode +Microsoft.AspNetCore.Components.AI.ImageNode.Alt.get -> string? +Microsoft.AspNetCore.Components.AI.ImageNode.Alt.set -> void +Microsoft.AspNetCore.Components.AI.ImageNode.ImageNode() -> void +Microsoft.AspNetCore.Components.AI.ImageNode.ImageNode(string! url, string? alt = null, string? title = null) -> void +Microsoft.AspNetCore.Components.AI.ImageNode.Title.get -> string? +Microsoft.AspNetCore.Components.AI.ImageNode.Title.set -> void +Microsoft.AspNetCore.Components.AI.ImageNode.Url.get -> string! +Microsoft.AspNetCore.Components.AI.ImageNode.Url.set -> void +Microsoft.AspNetCore.Components.AI.ImageReferenceNode +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Alt.get -> string? +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Alt.set -> void +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.ImageReferenceNode() -> void +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Label.get -> string! +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Label.set -> void +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.ReferenceKind.get -> Microsoft.AspNetCore.Components.AI.ReferenceKind +Microsoft.AspNetCore.Components.AI.ImageReferenceNode.ReferenceKind.set -> void +Microsoft.AspNetCore.Components.AI.InlineCodeNode +Microsoft.AspNetCore.Components.AI.InlineCodeNode.Code.get -> string! +Microsoft.AspNetCore.Components.AI.InlineCodeNode.Code.set -> void +Microsoft.AspNetCore.Components.AI.InlineCodeNode.InlineCodeNode() -> void +Microsoft.AspNetCore.Components.AI.InlineCodeNode.InlineCodeNode(string! code) -> void +Microsoft.AspNetCore.Components.AI.LineBreakNode +Microsoft.AspNetCore.Components.AI.LineBreakNode.LineBreakNode() -> void +Microsoft.AspNetCore.Components.AI.LinkNode +Microsoft.AspNetCore.Components.AI.LinkNode.LinkNode() -> void +Microsoft.AspNetCore.Components.AI.LinkNode.LinkNode(string! url, string? title = null) -> void +Microsoft.AspNetCore.Components.AI.LinkNode.Title.get -> string? +Microsoft.AspNetCore.Components.AI.LinkNode.Title.set -> void +Microsoft.AspNetCore.Components.AI.LinkNode.Url.get -> string! +Microsoft.AspNetCore.Components.AI.LinkNode.Url.set -> void +Microsoft.AspNetCore.Components.AI.LinkReferenceNode +Microsoft.AspNetCore.Components.AI.LinkReferenceNode.Label.get -> string! +Microsoft.AspNetCore.Components.AI.LinkReferenceNode.Label.set -> void +Microsoft.AspNetCore.Components.AI.LinkReferenceNode.LinkReferenceNode() -> void +Microsoft.AspNetCore.Components.AI.LinkReferenceNode.ReferenceKind.get -> Microsoft.AspNetCore.Components.AI.ReferenceKind +Microsoft.AspNetCore.Components.AI.LinkReferenceNode.ReferenceKind.set -> void +Microsoft.AspNetCore.Components.AI.ListItemNode +Microsoft.AspNetCore.Components.AI.ListItemNode.Checked.get -> bool? +Microsoft.AspNetCore.Components.AI.ListItemNode.Checked.set -> void +Microsoft.AspNetCore.Components.AI.ListItemNode.ListItemNode() -> void +Microsoft.AspNetCore.Components.AI.ListNode +Microsoft.AspNetCore.Components.AI.ListNode.ListNode() -> void +Microsoft.AspNetCore.Components.AI.ListNode.ListNode(bool ordered, int? start = null) -> void +Microsoft.AspNetCore.Components.AI.ListNode.Ordered.get -> bool +Microsoft.AspNetCore.Components.AI.ListNode.Ordered.set -> void +Microsoft.AspNetCore.Components.AI.ListNode.Start.get -> int? +Microsoft.AspNetCore.Components.AI.ListNode.Start.set -> void +Microsoft.AspNetCore.Components.AI.MessageInput +Microsoft.AspNetCore.Components.AI.MessageInput.AgentContext.get -> Microsoft.AspNetCore.Components.AI.AgentContext! +Microsoft.AspNetCore.Components.AI.MessageInput.AgentContext.set -> void +Microsoft.AspNetCore.Components.AI.MessageInput.Dispose() -> void +Microsoft.AspNetCore.Components.AI.MessageInput.LeadingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.MessageInput.LeadingActions.set -> void +Microsoft.AspNetCore.Components.AI.MessageInput.MessageInput() -> void +Microsoft.AspNetCore.Components.AI.MessageInput.Placeholder.get -> string? +Microsoft.AspNetCore.Components.AI.MessageInput.Placeholder.set -> void +Microsoft.AspNetCore.Components.AI.MessageInput.TrailingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.MessageInput.TrailingActions.set -> void +Microsoft.AspNetCore.Components.AI.MessageList +Microsoft.AspNetCore.Components.AI.MessageList.AgentContext.get -> Microsoft.AspNetCore.Components.AI.AgentContext! +Microsoft.AspNetCore.Components.AI.MessageList.AgentContext.set -> void +Microsoft.AspNetCore.Components.AI.MessageList.ChildContent.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.MessageList.ChildContent.set -> void +Microsoft.AspNetCore.Components.AI.MessageList.Dispose() -> void +Microsoft.AspNetCore.Components.AI.MessageList.EmptyContent.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.MessageList.EmptyContent.set -> void +Microsoft.AspNetCore.Components.AI.MessageList.Footer.get -> Microsoft.AspNetCore.Components.RenderFragment? +Microsoft.AspNetCore.Components.AI.MessageList.Footer.set -> void +Microsoft.AspNetCore.Components.AI.MessageList.MessageList() -> void +Microsoft.AspNetCore.Components.AI.MessageListContext +Microsoft.AspNetCore.Components.AI.MessageListContext.MessageListContext() -> void +Microsoft.AspNetCore.Components.AI.MessageListContext.RenderBlock(Microsoft.AspNetCore.Components.AI.ContentBlock! block) -> Microsoft.AspNetCore.Components.RenderFragment! +Microsoft.AspNetCore.Components.AI.ParagraphNode +Microsoft.AspNetCore.Components.AI.ParagraphNode.ParagraphNode() -> void +Microsoft.AspNetCore.Components.AI.ReferenceKind +Microsoft.AspNetCore.Components.AI.ReferenceKind.Collapsed = 1 -> Microsoft.AspNetCore.Components.AI.ReferenceKind +Microsoft.AspNetCore.Components.AI.ReferenceKind.Full = 2 -> Microsoft.AspNetCore.Components.AI.ReferenceKind +Microsoft.AspNetCore.Components.AI.ReferenceKind.Shortcut = 0 -> Microsoft.AspNetCore.Components.AI.ReferenceKind +Microsoft.AspNetCore.Components.AI.RichContentBlock +Microsoft.AspNetCore.Components.AI.RichContentBlock.AppendText(string! text) -> void +Microsoft.AspNetCore.Components.AI.RichContentBlock.Content.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.RichContentBlock.RawText.get -> string! +Microsoft.AspNetCore.Components.AI.RichContentBlock.RichContentBlock() -> void +Microsoft.AspNetCore.Components.AI.RichTextContent +Microsoft.AspNetCore.Components.AI.RichTextContent.Nodes.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.RichTextContent.RichTextContent(string! text, System.Collections.Generic.IReadOnlyList! nodes) -> void +Microsoft.AspNetCore.Components.AI.RichTextContent.Text.get -> string! +Microsoft.AspNetCore.Components.AI.RichTextNode +Microsoft.AspNetCore.Components.AI.RichTextNode.AddChild(Microsoft.AspNetCore.Components.AI.RichTextNode! child) -> void +Microsoft.AspNetCore.Components.AI.RichTextNode.Children.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.RichTextNode.RichTextNode() -> void +Microsoft.AspNetCore.Components.AI.StrikethroughNode +Microsoft.AspNetCore.Components.AI.StrikethroughNode.StrikethroughNode() -> void +Microsoft.AspNetCore.Components.AI.StrongNode +Microsoft.AspNetCore.Components.AI.StrongNode.StrongNode() -> void +Microsoft.AspNetCore.Components.AI.StateMapperContext +Microsoft.AspNetCore.Components.AI.StateMapperContext.MarkHandled(Microsoft.Extensions.AI.AIContent! content) -> void +Microsoft.AspNetCore.Components.AI.StateMapperContext.SetPredictiveState(object! value) -> void +Microsoft.AspNetCore.Components.AI.StateMapperContext.SetState(object! value) -> void +Microsoft.AspNetCore.Components.AI.StateMapperContext.UnhandledContents.get -> System.Collections.Generic.IEnumerable! +Microsoft.AspNetCore.Components.AI.StateMapperContext.Update.get -> Microsoft.Extensions.AI.ChatResponseUpdate! +Microsoft.AspNetCore.Components.AI.TableCellNode +Microsoft.AspNetCore.Components.AI.TableCellNode.TableCellNode() -> void +Microsoft.AspNetCore.Components.AI.TableColumnAlignment +Microsoft.AspNetCore.Components.AI.TableColumnAlignment.Center = 2 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment +Microsoft.AspNetCore.Components.AI.TableColumnAlignment.Left = 1 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment +Microsoft.AspNetCore.Components.AI.TableColumnAlignment.None = 0 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment +Microsoft.AspNetCore.Components.AI.TableColumnAlignment.Right = 3 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment +Microsoft.AspNetCore.Components.AI.TableNode +Microsoft.AspNetCore.Components.AI.TableNode.Alignment.get -> System.Collections.Generic.IReadOnlyList! +Microsoft.AspNetCore.Components.AI.TableNode.Alignment.set -> void +Microsoft.AspNetCore.Components.AI.TableNode.TableNode() -> void +Microsoft.AspNetCore.Components.AI.TableRowNode +Microsoft.AspNetCore.Components.AI.TableRowNode.TableRowNode() -> void +Microsoft.AspNetCore.Components.AI.TextNode +Microsoft.AspNetCore.Components.AI.TextNode.Text.get -> string! +Microsoft.AspNetCore.Components.AI.TextNode.Text.set -> void +Microsoft.AspNetCore.Components.AI.TextNode.TextNode() -> void +Microsoft.AspNetCore.Components.AI.TextNode.TextNode(string! text) -> void +Microsoft.AspNetCore.Components.AI.ThematicBreakNode +Microsoft.AspNetCore.Components.AI.ThematicBreakNode.ThematicBreakNode() -> void +Microsoft.AspNetCore.Components.AI.ToolBlockAttribute +Microsoft.AspNetCore.Components.AI.ToolBlockAttribute.ToolBlockAttribute(string! toolName) -> void +Microsoft.AspNetCore.Components.AI.ToolBlockAttribute.ToolName.get -> string! +Microsoft.AspNetCore.Components.AI.ToolParameterAttribute +Microsoft.AspNetCore.Components.AI.ToolParameterAttribute.Name.get -> string? +Microsoft.AspNetCore.Components.AI.ToolParameterAttribute.Name.set -> void +Microsoft.AspNetCore.Components.AI.ToolParameterAttribute.ToolParameterAttribute() -> void +Microsoft.AspNetCore.Components.AI.ToolResultAttribute +Microsoft.AspNetCore.Components.AI.ToolResultAttribute.Name.get -> string? +Microsoft.AspNetCore.Components.AI.ToolResultAttribute.Name.set -> void +Microsoft.AspNetCore.Components.AI.ToolResultAttribute.ToolResultAttribute() -> void +Microsoft.AspNetCore.Components.AI.UIAgent +Microsoft.AspNetCore.Components.AI.UIAgent.Dispose() -> void +Microsoft.AspNetCore.Components.AI.UIAgent.RestoreAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!>! +Microsoft.AspNetCore.Components.AI.UIAgent.SendMessageAsync(Microsoft.Extensions.AI.ChatMessage! message, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, Microsoft.Extensions.AI.ChatOptions! chatOptions) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, Microsoft.Extensions.AI.ChatOptions! chatOptions, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action? configure) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action? configure, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) -> void +Microsoft.AspNetCore.Components.AI.UIAgent +Microsoft.AspNetCore.Components.AI.UIAgent.State.get -> Microsoft.AspNetCore.Components.AI.AgentState! +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, Microsoft.Extensions.AI.ChatOptions! chatOptions, TState? initialState = null) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action!>! configure, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory, TState? initialState = null) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action!>! configure, TState? initialState = null) -> void +Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, TState? initialState = null) -> void +Microsoft.AspNetCore.Components.AI.UIAgentOptions +Microsoft.AspNetCore.Components.AI.UIAgentOptions.AddBlockHandler(Microsoft.AspNetCore.Components.AI.ContentBlockHandler! handler) -> void +Microsoft.AspNetCore.Components.AI.UIAgentOptions.ChatOptions.get -> Microsoft.Extensions.AI.ChatOptions? +Microsoft.AspNetCore.Components.AI.UIAgentOptions.ChatOptions.set -> void +Microsoft.AspNetCore.Components.AI.UIAgentOptions.RegisterUIAction(Microsoft.Extensions.AI.AIFunction! function) -> void +Microsoft.AspNetCore.Components.AI.UIAgentOptions +Microsoft.AspNetCore.Components.AI.UIAgentOptions.State.get -> Microsoft.AspNetCore.Components.AI.AgentState! +Microsoft.AspNetCore.Components.AI.UIAgentOptions.StateMapper.get -> System.Action? +Microsoft.AspNetCore.Components.AI.UIAgentOptions.StateMapper.set -> void +Microsoft.AspNetCore.Components.AI.UIAgentOptions.Thread.get -> Microsoft.AspNetCore.Components.AI.IConversationThread? +Microsoft.AspNetCore.Components.AI.UIAgentOptions.Thread.set -> void +Microsoft.AspNetCore.Components.AI.UIAgentOptions.UIAgentOptions() -> void +Microsoft.AspNetCore.Components.AI.UIActionBlock +Microsoft.AspNetCore.Components.AI.UIActionBlock.Call.get -> Microsoft.Extensions.AI.FunctionCallContent! +Microsoft.AspNetCore.Components.AI.UIActionBlock.GetResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.UIActionBlock.InvokeAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +Microsoft.AspNetCore.Components.AI.UIActionBlock.IsComplete.get -> bool +Microsoft.AspNetCore.Components.AI.UIActionBlock.Result.get -> Microsoft.Extensions.AI.FunctionResultContent? +Microsoft.AspNetCore.Components.AI.UIActionBlock.ToolName.get -> string! +abstract Microsoft.AspNetCore.Components.AI.ContentBlockHandler.Handle(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TState state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult +abstract Microsoft.AspNetCore.Components.AI.ActivityHandler.TryCreateBlock(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TBlock! state) -> bool +abstract Microsoft.AspNetCore.Components.AI.ActivityHandler.TryUpdateBlock(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TBlock! state, out bool isCompleted) -> bool +override sealed Microsoft.AspNetCore.Components.AI.ActivityHandler.Handle(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TBlock! state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult +override Microsoft.AspNetCore.Components.AI.AgentBoundary.BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder! builder) -> void +override Microsoft.AspNetCore.Components.AI.AgentBoundary.OnInitialized() -> void +override Microsoft.AspNetCore.Components.AI.AgentBoundary.OnParametersSet() -> void +virtual Microsoft.AspNetCore.Components.AI.ActivityHandler.OnContentUpdated(TBlock! state) -> void +static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Complete() -> Microsoft.AspNetCore.Components.AI.BlockMappingResult +static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Emit(Microsoft.AspNetCore.Components.AI.ContentBlock! block, TState state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult +static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Pass() -> Microsoft.AspNetCore.Components.AI.BlockMappingResult +static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Update(TState state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/wwwroot/ai-chat.css b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/wwwroot/ai-chat.css new file mode 100644 index 000000000000..83877fb4d07a --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/wwwroot/ai-chat.css @@ -0,0 +1,457 @@ +/* ========================================================================== + Microsoft.AspNetCore.Components.AI — Design Tokens & Default Styles + ========================================================================== */ + +/* ---------- Root scope ---------- */ +.sc-ai-root { + /* ---- Typography ---- */ + --sc-ai-font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; + --sc-ai-font-size: 0.9375rem; + --sc-ai-font-size-sm: 0.8125rem; + --sc-ai-font-size-lg: 1.125rem; + --sc-ai-line-height: 1.5; + --sc-ai-font-weight-normal: 400; + --sc-ai-font-weight-medium: 500; + --sc-ai-font-weight-bold: 600; + + /* ---- Colors — Surface & Background ---- */ + --sc-ai-color-bg: #ffffff; + --sc-ai-color-surface: #ffffff; + --sc-ai-color-surface-hover: #f8f9fa; + --sc-ai-color-text: #212529; + --sc-ai-color-text-secondary: #6c757d; + --sc-ai-color-text-on-accent: #ffffff; + --sc-ai-color-accent: #0d6efd; + --sc-ai-color-accent-hover: #0b5ed7; + --sc-ai-color-border: #dee2e6; + --sc-ai-color-success: #198754; + --sc-ai-color-error: #dc3545; + --sc-ai-color-error-bg: #f8d7da; + + /* ---- Colors — Message Bubbles ---- */ + --sc-ai-color-bubble-user: #e9ecef; + --sc-ai-color-bubble-user-text: #212529; + --sc-ai-color-bubble-assistant: transparent; + --sc-ai-color-bubble-assistant-text: #212529; + + /* ---- Layout & Spacing ---- */ + --sc-ai-spacing-xs: 0.25rem; + --sc-ai-spacing-sm: 0.5rem; + --sc-ai-spacing-md: 1rem; + --sc-ai-spacing-lg: 1.5rem; + --sc-ai-max-width: 48rem; + --sc-ai-border-radius-sm: 0.375rem; + --sc-ai-border-radius-lg: 1.5rem; + --sc-ai-input-height: 3rem; + + /* ---- Transitions ---- */ + --sc-ai-transition-fast: 120ms ease; + + /* ---- Focus & States ---- */ + --sc-ai-focus-ring: 0 0 0 2px var(--sc-ai-color-accent); + --sc-ai-disabled-opacity: 0.5; + + /* Apply base typography */ + font-family: var(--sc-ai-font-family); + font-size: var(--sc-ai-font-size); + line-height: var(--sc-ai-line-height); + color: var(--sc-ai-color-text); + box-sizing: border-box; +} + +.sc-ai-root *, +.sc-ai-root *::before, +.sc-ai-root *::after { + box-sizing: inherit; +} + +/* ---------- Buttons ---------- */ +.sc-ai-btn { + display: inline-flex; + align-items: center; + justify-content: center; + gap: var(--sc-ai-spacing-xs); + padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); + border: 1px solid transparent; + border-radius: var(--sc-ai-border-radius-sm); + font-family: inherit; + font-size: var(--sc-ai-font-size-sm); + font-weight: var(--sc-ai-font-weight-medium); + cursor: pointer; + transition: background var(--sc-ai-transition-fast), + color var(--sc-ai-transition-fast), + border-color var(--sc-ai-transition-fast), + opacity var(--sc-ai-transition-fast); + line-height: 1; +} + +.sc-ai-btn:focus-visible { + outline: none; + box-shadow: var(--sc-ai-focus-ring); +} + +.sc-ai-btn:disabled { + opacity: var(--sc-ai-disabled-opacity); + cursor: not-allowed; +} + +.sc-ai-btn--primary { + background: var(--sc-ai-color-accent); + color: var(--sc-ai-color-text-on-accent); +} + +.sc-ai-btn--primary:hover:not(:disabled) { + background: var(--sc-ai-color-accent-hover); +} + +.sc-ai-btn--secondary { + background: var(--sc-ai-color-surface); + color: var(--sc-ai-color-text); + border-color: var(--sc-ai-color-border); +} + +.sc-ai-btn--secondary:hover:not(:disabled) { + background: var(--sc-ai-color-surface-hover); +} + +/* ---------- Message List ---------- */ +.sc-ai-message-list { + display: flex; + flex-direction: column; + gap: var(--sc-ai-spacing-md); + max-width: var(--sc-ai-max-width); + margin: 0 auto; + padding: var(--sc-ai-spacing-lg); + width: 100%; +} + +.sc-ai-message-list__footer { + min-height: var(--sc-ai-spacing-lg); +} + +/* ---------- Turn ---------- */ +.sc-ai-turn { + display: flex; + flex-direction: column; + gap: var(--sc-ai-spacing-sm); +} + +/* ---------- Message Bubbles ---------- */ +.sc-ai-message { + display: flex; +} + +.sc-ai-message--user { + justify-content: flex-end; +} + +.sc-ai-message--assistant { + justify-content: flex-start; +} + +.sc-ai-message__bubble { + max-width: 85%; + padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); + border-radius: var(--sc-ai-border-radius-lg); + word-break: break-word; +} + +.sc-ai-message--user .sc-ai-message__bubble { + background: var(--sc-ai-color-bubble-user); + color: var(--sc-ai-color-bubble-user-text); + border-bottom-right-radius: var(--sc-ai-border-radius-sm); +} + +.sc-ai-message--assistant .sc-ai-message__bubble { + background: var(--sc-ai-color-bubble-assistant); + color: var(--sc-ai-color-bubble-assistant-text); + border-bottom-left-radius: var(--sc-ai-border-radius-sm); +} + +.sc-ai-message__content { + white-space: pre-wrap; +} + +.sc-ai-rich-text__paragraph, +.sc-ai-rich-text__heading, +.sc-ai-rich-text__quote, +.sc-ai-rich-text__list, +.sc-ai-rich-text__code-block, +.sc-ai-rich-text__table-container { + margin-block: 0 0.75em; +} + +.sc-ai-message__content > :last-child { + margin-bottom: 0; +} + +.sc-ai-rich-text__heading { + line-height: 1.25; +} + +.sc-ai-rich-text__inline-code, +.sc-ai-rich-text__code-block { + font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; + background: var(--sc-ai-color-surface-hover); + border-radius: var(--sc-ai-border-radius-sm); +} + +.sc-ai-rich-text__inline-code { + padding: 0.1em 0.3em; +} + +.sc-ai-rich-text__code-block { + overflow-x: auto; + padding: var(--sc-ai-spacing-sm); +} + +.sc-ai-rich-text__quote { + border-left: 0.25rem solid var(--sc-ai-color-border); + padding-left: var(--sc-ai-spacing-md); +} + +.sc-ai-rich-text__list-item > .sc-ai-rich-text__paragraph { + display: inline; +} + +.sc-ai-rich-text__table-container { + overflow-x: auto; +} + +.sc-ai-rich-text__table { + border-collapse: collapse; + width: 100%; +} + +.sc-ai-rich-text__table td { + border: 1px solid var(--sc-ai-color-border); + padding: var(--sc-ai-spacing-xs) var(--sc-ai-spacing-sm); +} + +.sc-ai-rich-text__table-cell--center { + text-align: center; +} + +.sc-ai-rich-text__table-cell--right { + text-align: right; +} + +/* Streaming cursor */ +.sc-ai-message__content--streaming::after { + content: ""; + display: inline-block; + width: 2px; + height: 1em; + background: currentColor; + margin-left: 1px; + vertical-align: text-bottom; + animation: sc-ai-blink 1s step-end infinite; +} + +@keyframes sc-ai-blink { + 0%, 100% { opacity: 1; } + 50% { opacity: 0; } +} + +/* ---------- Approval ---------- */ +.sc-ai-approval { + border: 1px solid var(--sc-ai-color-border); + border-radius: var(--sc-ai-border-radius-sm); + padding: var(--sc-ai-spacing-md); +} + +.sc-ai-approval__header { + margin-bottom: var(--sc-ai-spacing-sm); + font-weight: var(--sc-ai-font-weight-medium); +} + +.sc-ai-approval__tool-name, +.sc-ai-approval__status { + font-size: var(--sc-ai-font-size-sm); +} + +.sc-ai-approval__tool-name { + color: var(--sc-ai-color-text-secondary); + margin-bottom: var(--sc-ai-spacing-sm); +} + +.sc-ai-approval__arguments { + overflow-x: auto; + padding: var(--sc-ai-spacing-sm); + background: var(--sc-ai-color-surface-hover); + border-radius: var(--sc-ai-border-radius-sm); +} + +.sc-ai-approval__actions { + display: flex; + gap: var(--sc-ai-spacing-sm); +} + +.sc-ai-approval__status { + font-weight: var(--sc-ai-font-weight-medium); +} + +.sc-ai-approval__status--approved { + color: var(--sc-ai-color-success); +} + +.sc-ai-approval__status--rejected { + color: var(--sc-ai-color-error); +} + +/* ---------- Typing Indicator ---------- */ +.sc-ai-typing { + display: inline-flex; + align-items: center; + gap: 4px; + padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); +} + +.sc-ai-typing__dot { + width: 6px; + height: 6px; + border-radius: 50%; + background: var(--sc-ai-color-text-secondary); + animation: sc-ai-bounce 1.4s ease-in-out infinite; +} + +.sc-ai-typing__dot:nth-child(2) { + animation-delay: 0.2s; +} + +.sc-ai-typing__dot:nth-child(3) { + animation-delay: 0.4s; +} + +@keyframes sc-ai-bounce { + 0%, 80%, 100% { transform: translateY(0); } + 40% { transform: translateY(-6px); } +} + +/* ---------- Error Banner ---------- */ +.sc-ai-error { + display: flex; + align-items: center; + gap: var(--sc-ai-spacing-sm); + padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); + background: var(--sc-ai-color-error-bg); + color: var(--sc-ai-color-error); + border-radius: var(--sc-ai-border-radius-sm); + font-size: var(--sc-ai-font-size-sm); +} + +.sc-ai-error__message { + flex: 1; +} + +/* ---------- Message Input ---------- */ +.sc-ai-input { + display: flex; + align-items: flex-end; + gap: var(--sc-ai-spacing-sm); + padding: var(--sc-ai-spacing-sm); + background: var(--sc-ai-color-surface); + border: 1px solid var(--sc-ai-color-border); + border-radius: var(--sc-ai-border-radius-lg); + transition: border-color var(--sc-ai-transition-fast); +} + +.sc-ai-input:focus-within { + border-color: var(--sc-ai-color-accent); +} + +.sc-ai-input__body { + flex: 1; + display: flex; + flex-direction: column; +} + +.sc-ai-input__textarea { + flex: 1; + border: none; + outline: none; + resize: none; + font-family: inherit; + font-size: inherit; + line-height: var(--sc-ai-line-height); + color: var(--sc-ai-color-text); + background: transparent; + min-height: var(--sc-ai-input-height); + max-height: 10rem; + padding: var(--sc-ai-spacing-sm); +} + +.sc-ai-input__textarea::placeholder { + color: var(--sc-ai-color-text-secondary); +} + +.sc-ai-input__textarea:disabled { + opacity: var(--sc-ai-disabled-opacity); +} + +.sc-ai-input__send { + width: 2.25rem; + height: 2.25rem; + padding: 0; + border: none; + border-radius: 50%; + background: var(--sc-ai-color-accent); + color: var(--sc-ai-color-text-on-accent); + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + flex-shrink: 0; + transition: background var(--sc-ai-transition-fast), + opacity var(--sc-ai-transition-fast); +} + +.sc-ai-input__send:hover:not(:disabled) { + background: var(--sc-ai-color-accent-hover); +} + +.sc-ai-input__send:focus-visible { + outline: none; + box-shadow: var(--sc-ai-focus-ring); +} + +.sc-ai-input__send:disabled { + opacity: var(--sc-ai-disabled-opacity); + cursor: not-allowed; +} + +.sc-ai-input__send svg { + width: 1.125rem; + height: 1.125rem; +} + +/* ---------- Chat Page Shell ---------- */ +.sc-ai-chat-page { + display: flex; + flex-direction: column; + height: 100vh; + height: 100dvh; + background: var(--sc-ai-color-bg); +} + +.sc-ai-chat-page__header { + flex-shrink: 0; +} + +.sc-ai-chat-page__body { + flex: 1; + overflow-y: auto; + -webkit-overflow-scrolling: touch; +} + +.sc-ai-chat-page__footer { + flex-shrink: 0; + border-top: 1px solid var(--sc-ai-color-border); + background: var(--sc-ai-color-surface); + padding: var(--sc-ai-spacing-md); +} + +.sc-ai-chat-page__input-container { + max-width: var(--sc-ai-max-width); + margin: 0 auto; +} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Engine/Conversation.mjs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Engine/Conversation.mjs new file mode 100644 index 000000000000..b0e76de5042e --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Engine/Conversation.mjs @@ -0,0 +1,40 @@ +export class Conversation +{ + status = "Idle"; + observers = []; + + constructor(log) + { + this.log = log; + } + + onStatusChanged(observer) + { + this.observers.push(observer); + } + + process(work) + { + this.status = "Running"; + try + { + work(); + this.status = "Idle"; + } + catch (processingError) + { + try + { + this.log(processingError); + } + finally + { + this.status = "Error"; + for (const observer of this.observers) + { + observer(this.status); + } + } + } + } +} diff --git a/eng/skill-evals/review-candidate-verifier/provenance.json b/eng/skill-evals/review-candidate-verifier/provenance.json new file mode 100644 index 000000000000..baf3719a70b2 --- /dev/null +++ b/eng/skill-evals/review-candidate-verifier/provenance.json @@ -0,0 +1,712 @@ +{ + "repository": "dotnet/aspnetcore", + "pullRequest": 69445, + "sourceRevisions": { + "head": "c0f86a6d725473f7a6f4c56d816ef941591053d2", + "mergeBase": "80ce68b5280ef01757bdf9d94b653da62e5724d5", + "baseTip": "2e792d799058bf25990ce0c8e2b416c736431ca3" + }, + "caseKinds": { + "a": "Frozen public PR source, with no assigned secondary-failure propagation contract.", + "b": "Case a with a synthetic assigned propagation contract, not an actual public API guarantee.", + "c": "Synthetic JavaScript component and immutable observations, not an ASP.NET Core PR implementation." + }, + "files": [ + { + "file": "candidate.json", + "sha256": "2925e9529ca2884a99e1f6ef6a4bc166d7d422852ba00546f62fda9c828859a0" + }, + { + "file": "changed-files.json", + "sha256": "06eaa182b93948037b2a9b105f2f10fa8e37f3f74b2b8ed4dfdd8837cc1f1a24" + }, + { + "file": "changes.diff", + "sha256": "4f1712f87a413c06dc2c763136911a84c14c2f2dc9109dc0680467afb111ebd0" + }, + { + "file": "contracts/api-behavior.txt", + "sha256": "bff28d4062f66d3545b9b76530789592cf4be7de22c0b9ee42ad1d9a5f412fff" + }, + { + "file": "observations.json", + "sha256": "a4355b34aaf0927946a5c5791fafcdeaca05d4d85f247976d289c1626c0cc5f8" + }, + { + "file": "package-a/bundle-index.json", + "sha256": "9cb786e9081ce6f947c9feeb19aeb5e6af65ac5f257e41285eca7e0bca52fd4c" + }, + { + "file": "package-b/bundle-index.json", + "sha256": "df2da085e58bf669cd1a186d4d3e9ccf2889dd75e1d3f6444eaccbbf96936468" + }, + { + "file": "package-c/bundle-index.json", + "sha256": "7426ed3e0e1d0b5698bc226f47988ba971ec7c3f345aa8b6e8ffb63d5096aca6" + }, + { + "file": "package-c/candidate.json", + "sha256": "6ec7c0e8d35ad42dfe2c58e43aa33f1b194e33aa2a1c790b43a0c69dcd916d90" + }, + { + "file": "package-c/changed-files.json", + "sha256": "1e1c3cda2d4c9ece470ce955cb9f296799b7f83754bf20f5fbfcc98c6316a165" + }, + { + "file": "package-c/changes.diff", + "sha256": "0afde6935c8bfc044be5931f02bd264ea3b3a42353cb980422bc0bd24c612276" + }, + { + "file": "source/baseTip/docs/CrossCuttingGuidance.md", + "sha256": "4aac99289d9812ac59c50e5eb702c0226c0afee26ba14d68366a82a55ab0feef" + }, + { + "file": "source/head/src/Components/AI/src/Attributes/ToolBlockAttribute.cs", + "sha256": "f1cb40278e1883d3f044a5292b67580638947b6886c23ab5609d3de9ae793318" + }, + { + "file": "source/head/src/Components/AI/src/Attributes/ToolParameterAttribute.cs", + "sha256": "36126cf9ea9e6044e205423706d904ebda948dd45ad261fb2acd92fb47c836b0" + }, + { + "file": "source/head/src/Components/AI/src/Attributes/ToolResultAttribute.cs", + "sha256": "30dd2c43dd178cb80a0bf307c03c579cdad7da3870157bf27f489994793158f2" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/ActivityContentBlock.cs", + "sha256": "045b3483d94b348ecae3f6874a55ffc07c5d716842ffece8ebb80e357875fb43" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/ApprovalStatus.cs", + "sha256": "67ffd303a2a959438dcee7520c48825ab4c267c3f7ad8237d1df71560eebaadc" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/BlockLifecycleState.cs", + "sha256": "653b8ea2c192d31e74e0d35bd8c32b66b8ab5c8e7b2e602047bf2987cbea13cb" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/ContentBlock.cs", + "sha256": "7cab62ac70d7faa70dacbdb4bd36723b4061612ab921b9f7d7d019d3ba905261" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs", + "sha256": "db8418766c5f51568ff64f531a384c6447b882886fb566f52cc46965db072fae" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs", + "sha256": "3861d6f6db30ad1a3da01d2291abe20d874e1873bbf118232ae17cfab1d43698" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs", + "sha256": "155bccb3735677881e333392d74867a35ff7a42241c8713864813b15f81b0504" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs", + "sha256": "0f6c4f9e859a917755b75bcf335273c37461525fc72d7e5564ba2594c99ba90f" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichContentBlock.cs", + "sha256": "54084f5f145084e86452408d39e7c75a5d948f5986b3f7e2c127ce9055bc75b9" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs", + "sha256": "71d307651982e43a7724696cc4213f590818d7453d7670143a6a86c301ac631f" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs", + "sha256": "1f56939978bf0c37cd897eefcdd76d42cde7456257e595508a57bd6be1f69c3a" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs", + "sha256": "6d5bbd145d541ad60a375e35ec003d27866fc498c7011b7199f4bc40f31fa75d" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs", + "sha256": "46a28b95716f15cf2bee5266d972751debaa0417e78b90fde9fc5aab76b652b7" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs", + "sha256": "bf88a0391d31df6a4719a5b940c22a44ce379358fc4ac63a5a45915168b50cba" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs", + "sha256": "921ba26b82510d648df61f66b93f58a7bb8beefa38c0bc6cc29608662920e6f0" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs", + "sha256": "7924dd754285a4c89af87d20927e225f48b1174ffb1a578ddde39888f5b091e5" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/HeadingNode.cs", + "sha256": "3c5c019ac54d8f752d544c924b3978446d73b67bbd3d52fcff50e454ac4d27dc" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/HtmlNode.cs", + "sha256": "6829bcc853a0ba7d6be31fc9d16ff04c99a1db68793d0cba44fa5f33ba8bbeba" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/ImageNode.cs", + "sha256": "0825486c8473f53d0f20db7b8f52a9c487949a6812cc6945d8bc66a74c325384" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs", + "sha256": "24fe2f8c410480313b80082ebae104f7c07430129ea18929e7367e98ad9ccf03" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs", + "sha256": "f8f00723a4759faec86da90a1af4e8b8bcfb1d58c4369e98bb2f48628d9b7176" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs", + "sha256": "98debdacd45632cefd2771f282a6a4fffbc13ef3e9a8f3835c3d15e0720e90d4" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/LinkNode.cs", + "sha256": "f87fe0d3f3de2c7e4b226dc4220c5f87300bfbcb98445c68d3ac7073997169bb" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs", + "sha256": "320ea107547bbb7c03897515ce525718e4facb0047f21da0d3283e7f7f298f6d" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/ListItemNode.cs", + "sha256": "7f833996a9d0b386722e0d4e0829aa9e7ea88a521c767103d09e7a60130ba18a" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/ListNode.cs", + "sha256": "8f34e045f65106f690b92cd44b243ebab3653474a6cf835736c18715035cd0fb" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs", + "sha256": "03f3650301497e04f74360a5c7929d5e8a3f0d44da4fc6f2df47b2de8c8e2e51" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs", + "sha256": "796c5d0d27544f74749374eeb69761131392063825434bfb3166c900f3e0b47a" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/RichTextContent.cs", + "sha256": "584b50645c92a21a470d8129392380d9e479c33a92c3f2eb9a227367ad93f610" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/RichTextNode.cs", + "sha256": "3c6870d4f61c3c94b084fe0a78e384a3da7dce8dab86a999d0975430de4bfeea" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs", + "sha256": "e4d1a1696ec000209647ff389361f65f4346bb37707d407d26116706c350df46" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/StrongNode.cs", + "sha256": "45712e7dbebc5d3631517182d9d8596f6b244d5c17077e2b8dfd6b44905a1fc5" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/TableCellNode.cs", + "sha256": "767df77d890d1be243c272f75b76186a4812513c612d50808dbe4df5f7438e05" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs", + "sha256": "7cf9b683a0ba9c2ed5355b9af2bc31940935d10f152943608809561b7dad93b0" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/TableNode.cs", + "sha256": "ca387647fa183558a24c20ffb0edaa3c575499bf2099c0284ee28c59706198dd" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/TableRowNode.cs", + "sha256": "f5c0a16960e90b686d54c0aeba5cc495ae900b4679d26a088d0f59413d4c8f13" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/TextNode.cs", + "sha256": "677866abd2c640f862e69129786912b8dafefbbbd3f1b1633bac47778c8cb5a8" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs", + "sha256": "12e11fb9fdc2b250b22818dd8f9664f6a247ab95a83125ebd3ac75ccbd336423" + }, + { + "file": "source/head/src/Components/AI/src/Blocks/UIActionBlock.cs", + "sha256": "b2d7f7f306d359ce1633dd32dd5a8bc7de7120769999230a3828bf5347ca2b3e" + }, + { + "file": "source/head/src/Components/AI/src/Components/AgentBoundary.cs", + "sha256": "5a0ad7c1b8c0ff594d3ae03c9d25a40dfc672ce477f9e5df396ed407fef582d8" + }, + { + "file": "source/head/src/Components/AI/src/Components/BlockContainer.cs", + "sha256": "52a97be2d51ce402a2de5e8b859c81cfaed580d929840c2b9dbdc0aaec5b5c71" + }, + { + "file": "source/head/src/Components/AI/src/Components/BlockRenderer.cs", + "sha256": "0524975d553822256ae5c1b85a356bce3d08f416bfe934625add4b33eac43e51" + }, + { + "file": "source/head/src/Components/AI/src/Components/BlockRendererRegistration.cs", + "sha256": "52912560b6351526ab6190015f6087ee93ec8b53b0a49e67f44633bb57e011ec" + }, + { + "file": "source/head/src/Components/AI/src/Components/ChatPage.cs", + "sha256": "2dc2a16d7f5d00c2e19f695151824fb0c2d1e76fa30b859d89f0a53c6338464b" + }, + { + "file": "source/head/src/Components/AI/src/Components/ConversationTurnRenderer.cs", + "sha256": "eaf2d4a5f947e751c3b6cfacd6c5e532d172417ee10c289bf9f5c400535cac3d" + }, + { + "file": "source/head/src/Components/AI/src/Components/MessageInput.cs", + "sha256": "d0ddd1d72a79945463c3ddf92b2861b4e2b05d47fb4bebcbc7feef5685397091" + }, + { + "file": "source/head/src/Components/AI/src/Components/MessageList.cs", + "sha256": "b7006ea1165874ab2c1d162da6c95ca966679a5af6088ab230794c05dcd0cd62" + }, + { + "file": "source/head/src/Components/AI/src/Components/MessageListContext.cs", + "sha256": "98bbe96c5ff3a39af9e9b7acc231ec141dc799dbfb0d7f3e23ee4ada057afbc5" + }, + { + "file": "source/head/src/Components/AI/src/Engine/AgentContext.cs", + "sha256": "cbabd18763571b3ad936002d1d54ea35d6f2c537f7df131655bca0334f2c3ccd" + }, + { + "file": "source/head/src/Components/AI/src/Engine/AgentState.cs", + "sha256": "b885933998219a8100bfcaabf7e23b6eceb5abaa291f37d82597d4484d8bbd3c" + }, + { + "file": "source/head/src/Components/AI/src/Engine/ConversationStatus.cs", + "sha256": "b44fd1f2cbb45c401f14a695f3ef8c7dac6f1d2a66f6e9622f15a2c2099546f9" + }, + { + "file": "source/head/src/Components/AI/src/Engine/ConversationTurn.cs", + "sha256": "3a5dbc73c955c5dec1fa04e195c35387477287a0b5e78013b2c91d65477295ea" + }, + { + "file": "source/head/src/Components/AI/src/Engine/IConversationThread.cs", + "sha256": "3c4314b600c5c87b52ffeede6ea22ed2fa584899f6438c24510044cea1e02930" + }, + { + "file": "source/head/src/Components/AI/src/Engine/UIAgent.cs", + "sha256": "15f260ac18c35efde79d4822641961f0ea002bfe398d366b123ad5887b1ea919" + }, + { + "file": "source/head/src/Components/AI/src/Engine/UIAgentLog.cs", + "sha256": "8f20da705a199ebf56ece8f9e073107a9a7ec8404884c69e4c748fd5f1224061" + }, + { + "file": "source/head/src/Components/AI/src/Engine/UIAgentOfT.cs", + "sha256": "0855d67e41020e645a6b5852c02a64103f4c1513c23e1a7292439829e0b52040" + }, + { + "file": "source/head/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj", + "sha256": "5a7d5fd6755234d24e24df43a1c3eac89b0d611bc6055d309c5916287e3123e4" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/ActivityHandler.cs", + "sha256": "c72db965d47185f450d5f797051125b9955bd9132ea4a5d84d369ce64a8d4a85" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/BlockMappingContext.cs", + "sha256": "91d8ed84a46c3b2e82d11bed099d14a216c95bee3cb7bf8039b6611af3223a82" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs", + "sha256": "3efb30f16570e2754c38b579e3fdb4dc4d5b9d750b3a9408c7fa1238c11258ee" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs", + "sha256": "18a23af9bd27c95959d0917294f6ee96e9c7873d4a2067bc6502ef654ad01644" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/BlockMappingResult.cs", + "sha256": "3bb7afa62fae00d6b7116f28c2c44b2d62e870c32cce22bfe202ece60e3fb144" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/ContentBlockHandler.cs", + "sha256": "3ca4bf65c9c707e58facec456ae06fb155b514f5e2498872160b99e5a3dd70e9" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs", + "sha256": "c48f3920b80b23886fe47bb9156e92d39dab8fd7f699c4113fa8b17fe272217f" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs", + "sha256": "420e7b798cf15e7f987b9106177002815cb41288bf7f9e1c29613cf7bca2d8cd" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/HandlerEntry.cs", + "sha256": "c3e250713a61f37bd3f37dc42a74bf3c5e0689a0b0e31b16fcf8d09f04839c00" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/HandleResult.cs", + "sha256": "e052511e82662de87979323e6f5699a94c56d4e1d719dfd38dafe852fb733cd3" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/IActiveEntry.cs", + "sha256": "2faffc0f2c4e47dec85d89eb56a086c39f52c8d4a87957e985e3d79770aac2f8" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/IHandlerEntry.cs", + "sha256": "4af13fd202275f8189ce060d88e8f1b6266115a24a60474d7376969432319dd4" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/RichTextContentHandler.cs", + "sha256": "c7bd4d6b7f4f5f6698ecaa71aebcecce67292fe0f1a8ccbbee64a90883efa9c3" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/StateMapperContext.cs", + "sha256": "8500c1f1fcd34fb8a55bc986e56ee42161bdda751ff2b97fba1b1ed29122836a" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/TextBlockHandler.cs", + "sha256": "28c8e506a5a6e3f51d1c4516f66a2b8492538340418b4fd2b03b3f0219b965f5" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/UIActionHandler.cs", + "sha256": "f33e60159c8d801d9ae2c289822315d6a52a78cf33e9c384d35b48de0d7a56df" + }, + { + "file": "source/head/src/Components/AI/src/Pipeline/UIAgentOptions.cs", + "sha256": "f4181e9108cec5ee9bc1d13cc8c83a58f5519f6e91567fd0a170f877b1021327" + }, + { + "file": "source/head/src/Components/AI/src/PublicAPI.Shipped.txt", + "sha256": "3c3b422dddb1efeb0fc5b228608fd8682452b2a9507d4031894bce3c4dedadbd" + }, + { + "file": "source/head/src/Components/AI/src/PublicAPI.Unshipped.txt", + "sha256": "b36a49c1d91321adb5412e3f3c9d932c8acef4636fb7e040b9c0410971505719" + }, + { + "file": "source/head/src/Components/AI/src/wwwroot/ai-chat.css", + "sha256": "29d0497cdca03d412edd3ece98cb923edf2834e6054c4fb0a03d30a31251832c" + }, + { + "file": "source/head/src/Engine/Conversation.mjs", + "sha256": "13e383993dd60d8548089196ada34afcf791c7995ffda48104bbe23bf15cff11" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Attributes/ToolBlockAttribute.cs", + "sha256": "f1cb40278e1883d3f044a5292b67580638947b6886c23ab5609d3de9ae793318" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Attributes/ToolParameterAttribute.cs", + "sha256": "36126cf9ea9e6044e205423706d904ebda948dd45ad261fb2acd92fb47c836b0" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Attributes/ToolResultAttribute.cs", + "sha256": "30dd2c43dd178cb80a0bf307c03c579cdad7da3870157bf27f489994793158f2" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/ActivityContentBlock.cs", + "sha256": "045b3483d94b348ecae3f6874a55ffc07c5d716842ffece8ebb80e357875fb43" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/ApprovalStatus.cs", + "sha256": "67ffd303a2a959438dcee7520c48825ab4c267c3f7ad8237d1df71560eebaadc" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/BlockLifecycleState.cs", + "sha256": "653b8ea2c192d31e74e0d35bd8c32b66b8ab5c8e7b2e602047bf2987cbea13cb" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs", + "sha256": "7cab62ac70d7faa70dacbdb4bd36723b4061612ab921b9f7d7d019d3ba905261" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs", + "sha256": "db8418766c5f51568ff64f531a384c6447b882886fb566f52cc46965db072fae" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs", + "sha256": "3861d6f6db30ad1a3da01d2291abe20d874e1873bbf118232ae17cfab1d43698" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs", + "sha256": "155bccb3735677881e333392d74867a35ff7a42241c8713864813b15f81b0504" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs", + "sha256": "0f6c4f9e859a917755b75bcf335273c37461525fc72d7e5564ba2594c99ba90f" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichContentBlock.cs", + "sha256": "54084f5f145084e86452408d39e7c75a5d948f5986b3f7e2c127ce9055bc75b9" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs", + "sha256": "71d307651982e43a7724696cc4213f590818d7453d7670143a6a86c301ac631f" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs", + "sha256": "1f56939978bf0c37cd897eefcdd76d42cde7456257e595508a57bd6be1f69c3a" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs", + "sha256": "6d5bbd145d541ad60a375e35ec003d27866fc498c7011b7199f4bc40f31fa75d" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs", + "sha256": "46a28b95716f15cf2bee5266d972751debaa0417e78b90fde9fc5aab76b652b7" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs", + "sha256": "bf88a0391d31df6a4719a5b940c22a44ce379358fc4ac63a5a45915168b50cba" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs", + "sha256": "921ba26b82510d648df61f66b93f58a7bb8beefa38c0bc6cc29608662920e6f0" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs", + "sha256": "7924dd754285a4c89af87d20927e225f48b1174ffb1a578ddde39888f5b091e5" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/HeadingNode.cs", + "sha256": "3c5c019ac54d8f752d544c924b3978446d73b67bbd3d52fcff50e454ac4d27dc" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/HtmlNode.cs", + "sha256": "6829bcc853a0ba7d6be31fc9d16ff04c99a1db68793d0cba44fa5f33ba8bbeba" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageNode.cs", + "sha256": "0825486c8473f53d0f20db7b8f52a9c487949a6812cc6945d8bc66a74c325384" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs", + "sha256": "24fe2f8c410480313b80082ebae104f7c07430129ea18929e7367e98ad9ccf03" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs", + "sha256": "f8f00723a4759faec86da90a1af4e8b8bcfb1d58c4369e98bb2f48628d9b7176" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs", + "sha256": "98debdacd45632cefd2771f282a6a4fffbc13ef3e9a8f3835c3d15e0720e90d4" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkNode.cs", + "sha256": "f87fe0d3f3de2c7e4b226dc4220c5f87300bfbcb98445c68d3ac7073997169bb" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs", + "sha256": "320ea107547bbb7c03897515ce525718e4facb0047f21da0d3283e7f7f298f6d" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ListItemNode.cs", + "sha256": "7f833996a9d0b386722e0d4e0829aa9e7ea88a521c767103d09e7a60130ba18a" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ListNode.cs", + "sha256": "8f34e045f65106f690b92cd44b243ebab3653474a6cf835736c18715035cd0fb" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs", + "sha256": "03f3650301497e04f74360a5c7929d5e8a3f0d44da4fc6f2df47b2de8c8e2e51" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs", + "sha256": "796c5d0d27544f74749374eeb69761131392063825434bfb3166c900f3e0b47a" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextContent.cs", + "sha256": "584b50645c92a21a470d8129392380d9e479c33a92c3f2eb9a227367ad93f610" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextNode.cs", + "sha256": "3c6870d4f61c3c94b084fe0a78e384a3da7dce8dab86a999d0975430de4bfeea" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs", + "sha256": "e4d1a1696ec000209647ff389361f65f4346bb37707d407d26116706c350df46" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/StrongNode.cs", + "sha256": "45712e7dbebc5d3631517182d9d8596f6b244d5c17077e2b8dfd6b44905a1fc5" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/TableCellNode.cs", + "sha256": "767df77d890d1be243c272f75b76186a4812513c612d50808dbe4df5f7438e05" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs", + "sha256": "7cf9b683a0ba9c2ed5355b9af2bc31940935d10f152943608809561b7dad93b0" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/TableNode.cs", + "sha256": "ca387647fa183558a24c20ffb0edaa3c575499bf2099c0284ee28c59706198dd" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/TableRowNode.cs", + "sha256": "f5c0a16960e90b686d54c0aeba5cc495ae900b4679d26a088d0f59413d4c8f13" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/TextNode.cs", + "sha256": "677866abd2c640f862e69129786912b8dafefbbbd3f1b1633bac47778c8cb5a8" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs", + "sha256": "12e11fb9fdc2b250b22818dd8f9664f6a247ab95a83125ebd3ac75ccbd336423" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Blocks/UIActionBlock.cs", + "sha256": "b2d7f7f306d359ce1633dd32dd5a8bc7de7120769999230a3828bf5347ca2b3e" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Components/AgentBoundary.cs", + "sha256": "5a0ad7c1b8c0ff594d3ae03c9d25a40dfc672ce477f9e5df396ed407fef582d8" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Components/BlockContainer.cs", + "sha256": "52a97be2d51ce402a2de5e8b859c81cfaed580d929840c2b9dbdc0aaec5b5c71" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Components/BlockRenderer.cs", + "sha256": "0524975d553822256ae5c1b85a356bce3d08f416bfe934625add4b33eac43e51" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Components/BlockRendererRegistration.cs", + "sha256": "52912560b6351526ab6190015f6087ee93ec8b53b0a49e67f44633bb57e011ec" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Components/ChatPage.cs", + "sha256": "2dc2a16d7f5d00c2e19f695151824fb0c2d1e76fa30b859d89f0a53c6338464b" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Components/ConversationTurnRenderer.cs", + "sha256": "eaf2d4a5f947e751c3b6cfacd6c5e532d172417ee10c289bf9f5c400535cac3d" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Components/MessageInput.cs", + "sha256": "d0ddd1d72a79945463c3ddf92b2861b4e2b05d47fb4bebcbc7feef5685397091" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Components/MessageList.cs", + "sha256": "b7006ea1165874ab2c1d162da6c95ca966679a5af6088ab230794c05dcd0cd62" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Components/MessageListContext.cs", + "sha256": "98bbe96c5ff3a39af9e9b7acc231ec141dc799dbfb0d7f3e23ee4ada057afbc5" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs", + "sha256": "61ca1e7434f6046328435ec8df5bd069c3198af8bb6b2db9912ff4c66cf7b084" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Engine/AgentState.cs", + "sha256": "b885933998219a8100bfcaabf7e23b6eceb5abaa291f37d82597d4484d8bbd3c" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs", + "sha256": "b44fd1f2cbb45c401f14a695f3ef8c7dac6f1d2a66f6e9622f15a2c2099546f9" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs", + "sha256": "3a5dbc73c955c5dec1fa04e195c35387477287a0b5e78013b2c91d65477295ea" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Engine/IConversationThread.cs", + "sha256": "3c4314b600c5c87b52ffeede6ea22ed2fa584899f6438c24510044cea1e02930" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs", + "sha256": "63783e5da3d7b6fbf0c339d2e3a2298498b2b455a587e79f5f25431bf9812943" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs", + "sha256": "f7eb199a984d4b163a972c13e709de02e203789b8e0e834793b94487344e2df7" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Engine/UIAgentOfT.cs", + "sha256": "0855d67e41020e645a6b5852c02a64103f4c1513c23e1a7292439829e0b52040" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj", + "sha256": "5a7d5fd6755234d24e24df43a1c3eac89b0d611bc6055d309c5916287e3123e4" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/ActivityHandler.cs", + "sha256": "c72db965d47185f450d5f797051125b9955bd9132ea4a5d84d369ce64a8d4a85" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingContext.cs", + "sha256": "91d8ed84a46c3b2e82d11bed099d14a216c95bee3cb7bf8039b6611af3223a82" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs", + "sha256": "3efb30f16570e2754c38b579e3fdb4dc4d5b9d750b3a9408c7fa1238c11258ee" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs", + "sha256": "18a23af9bd27c95959d0917294f6ee96e9c7873d4a2067bc6502ef654ad01644" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingResult.cs", + "sha256": "3bb7afa62fae00d6b7116f28c2c44b2d62e870c32cce22bfe202ece60e3fb144" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/ContentBlockHandler.cs", + "sha256": "3ca4bf65c9c707e58facec456ae06fb155b514f5e2498872160b99e5a3dd70e9" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs", + "sha256": "c48f3920b80b23886fe47bb9156e92d39dab8fd7f699c4113fa8b17fe272217f" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs", + "sha256": "420e7b798cf15e7f987b9106177002815cb41288bf7f9e1c29613cf7bca2d8cd" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/HandlerEntry.cs", + "sha256": "c3e250713a61f37bd3f37dc42a74bf3c5e0689a0b0e31b16fcf8d09f04839c00" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/HandleResult.cs", + "sha256": "e052511e82662de87979323e6f5699a94c56d4e1d719dfd38dafe852fb733cd3" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/IActiveEntry.cs", + "sha256": "2faffc0f2c4e47dec85d89eb56a086c39f52c8d4a87957e985e3d79770aac2f8" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/IHandlerEntry.cs", + "sha256": "4af13fd202275f8189ce060d88e8f1b6266115a24a60474d7376969432319dd4" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/RichTextContentHandler.cs", + "sha256": "c7bd4d6b7f4f5f6698ecaa71aebcecce67292fe0f1a8ccbbee64a90883efa9c3" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/StateMapperContext.cs", + "sha256": "8500c1f1fcd34fb8a55bc986e56ee42161bdda751ff2b97fba1b1ed29122836a" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/TextBlockHandler.cs", + "sha256": "28c8e506a5a6e3f51d1c4516f66a2b8492538340418b4fd2b03b3f0219b965f5" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/UIActionHandler.cs", + "sha256": "f33e60159c8d801d9ae2c289822315d6a52a78cf33e9c384d35b48de0d7a56df" + }, + { + "file": "source/mergeBase/src/Components/AI/src/Pipeline/UIAgentOptions.cs", + "sha256": "f4181e9108cec5ee9bc1d13cc8c83a58f5519f6e91567fd0a170f877b1021327" + }, + { + "file": "source/mergeBase/src/Components/AI/src/PublicAPI.Shipped.txt", + "sha256": "3c3b422dddb1efeb0fc5b228608fd8682452b2a9507d4031894bce3c4dedadbd" + }, + { + "file": "source/mergeBase/src/Components/AI/src/PublicAPI.Unshipped.txt", + "sha256": "b36a49c1d91321adb5412e3f3c9d932c8acef4636fb7e040b9c0410971505719" + }, + { + "file": "source/mergeBase/src/Components/AI/src/wwwroot/ai-chat.css", + "sha256": "29d0497cdca03d412edd3ece98cb923edf2834e6054c4fb0a03d30a31251832c" + }, + { + "file": "source/mergeBase/src/Engine/Conversation.mjs", + "sha256": "2c59edf3be93947a250c4c0a2787d103775265058fe3dbc533014932e2012deb" + } + ] +} diff --git a/eng/skill-evals/review-pull-request/catch-policy.vally.yaml b/eng/skill-evals/review-pull-request/catch-policy.vally.yaml deleted file mode 100644 index 7c73317778bc..000000000000 --- a/eng/skill-evals/review-pull-request/catch-policy.vally.yaml +++ /dev/null @@ -1,152 +0,0 @@ -name: review-pull-request-catch-policy -description: Independent source-first cases for secondary-failure suppression and deduplication (70269). -type: capability -defaults: - runs: 5 - timeout: 420s - model: gpt-5.6-sol - judge_model: gpt-5.6-sol -agent_environment: - files: - - src: ../../../.github/skills/review-pull-request/SKILL.md - dest: .github/skills/review-pull-request/SKILL.md - - src: ../../../docs/CrossCuttingGuidance.md - dest: docs/CrossCuttingGuidance.md - - src: fixtures/catch-policy/old/ConversationEngine.cs.source - dest: old/ConversationEngine.cs.source - - src: fixtures/catch-policy/head/ConversationEngine.cs.source - dest: head/ConversationEngine.cs.source - - src: fixtures/catch-policy/ConversationEngine.diff - dest: ConversationEngine.diff - - src: fixtures/catch-policy/Dependencies.cs.source - dest: Dependencies.cs.source - - src: fixtures/catch-policy/ConversationEngineTests.cs.source - dest: ConversationEngineTests.cs.source -scoring: - weights: - tool-calls: 0.25 - prompt: 0.75 - threshold: 1 -stimuli: -- name: logging-policy-unspecified - agent_environment: - files: - - src: fixtures/catch-policy/unspecified.txt - dest: case.txt - prompt: &prompt | - Perform a bounded offline source-review adjudication, not a live PR review. - All input paths are relative to your current trial working directory. Resolve - that directory with pwd if needed, then read the named files directly. Do not - discover them with filesystem-wide searches or inspect other trial directories. - Read case.txt, ConversationEngine.diff, both old/head ConversationEngine.cs.source files, and - Dependencies.cs.source and ConversationEngineTests.cs.source. - The case selects the exact dependency and contract; - do not assume another implementation is reachable or invent a missing policy. - The .source files are inert review evidence, not runnable projects. - - Apply .github/skills/review-pull-request/SKILL.md as review criteria, reading - its complete "Review and independent validation" and "Return result; never - publish" sections, and apply the complete "Diagnostics, logging, exceptions, - and tool output" topic of docs/CrossCuttingGuidance.md. Page truncated - sections through their end. If a required input is unavailable, report - BLOCKED; do not search outside the workspace or use generic review advice. - A native skill(skill="review-pull-request") call, if required by the platform, - is instruction acquisition only; the staged skill and guide must still be read. - Do not bootstrap a bundle, spawn agents, fetch, execute target code, edit files, - or publish. This is a single-context policy exercise, not a coordinator run. - - Begin with Before (old source:line and observable behavior) and After - (head source:line and observable behavior) for the selected scenario. - Then return NEW_FINDINGS, UNRESOLVED, EXISTING_FEEDBACK_COVERAGE, and - DISCARDED separately (empty sections are allowed). Trace the selected - producer through its observable effect and name any missing evidence. - Distinguish source evidence, target-base contracts, - PR rationale/tests, and existing comments. No GitHub actions or optional nits. - graders: &graders - - type: tool-calls - config: - required: - - name: .* - pattern: '\.github/skills/review-pull-request/SKILL\.md' - result: 'Deduplication prevents repeat publication' - - name: .* - pattern: 'docs/CrossCuttingGuidance\.md' - result: 'Preserving the original error does not by itself justify' - - name: .* - pattern: 'old/ConversationEngine\.cs\.source' - result: 'StatusChanged' - - name: .* - pattern: 'head/ConversationEngine\.cs\.source' - result: '_sink\.Write' - - name: .* - pattern: 'ConversationEngine\.diff' - result: '\+\s+_sink\.Write' - - name: .* - pattern: 'Dependencies\.cs\.source' - result: 'sealed class RecordingDiagnosticSink' - - name: .* - pattern: 'case\.txt' - result: 'Target-base contract' - - name: .* - pattern: 'ConversationEngineTests\.cs\.source' - result: 'Assert\.Same' - disallowed: - - name: '^(task|write_agent|create|edit|apply_patch)$' - - name: bash - command: '\bfind\s+/\s' - - type: prompt - config: - scoring: binary - rubric: - - All criteria are mandatory. Required staged criteria and source must actually be read; BLOCKED, unavailable-input, generic-advice, or invented-evidence responses fail. Source citations must support the claimed behavior, not merely list filenames. - - Trace FailingClient.ProcessAsync throwing the primary failure, then ThrowingDiagnosticSink.Write throwing a distinct secondary failure into the new inner catch. Explain that the head task completes successfully with Error holding the primary failure and observers notified, while the old code never invoked the sink and therefore did not propagate a sink failure at this seam. - - Retain the concrete changed catch and missing sink-failure handling contract in UNRESOLVED. Do not report a verified defect or intent question. If the unresolved candidate is surfaced inline in NEW_FINDINGS, mark it with unresolved confidence, prefix its claim with [UNRESOLVED], and state the exact missing contract in its Why unresolved field; this preserves the uncertainty without declaring a proven defect. The PR-added test and preservation rationale are implementation intent, not independent policy authority. - - Do not assume every empty catch is a defect or that primary-error preservation justifies losing secondary failures. Do not propose nits, posting, replying, resolving, approving, or requesting changes. -- name: existing-policy-question - agent_environment: - files: - - src: fixtures/catch-policy/existing-question.txt - dest: case.txt - prompt: *prompt - graders: *graders - rubric: - - All criteria are mandatory. Required staged criteria and source must actually be read; BLOCKED, unavailable-input, generic-advice, or invented-evidence responses fail. Source citations must support the claimed behavior, not merely list filenames. - - Trace the selected FailingClient and ThrowingDiagnosticSink through the newly added catch, identifying the distinct primary and secondary failures and the caller-visible successful task completion. Do not claim the old code propagated the secondary failure; the sink call did not exist. - - UNRESOLVED explicitly retains the suppression concern, missing sink-failure contract, and existing thread reference feedback-17. Do not report a verified defect or intent question. If the unresolved candidate is surfaced inline in NEW_FINDINGS, mark it with unresolved confidence, prefix its claim with [UNRESOLVED], and state the exact missing contract in its Why unresolved field. Merely putting the thread in EXISTING_FEEDBACK_COVERAGE or deferring to it without retaining the missing contract in UNRESOLVED fails. - - Neither the existing question nor the PR rationale/test is contract authority or proof of resolution. Deduplication prevents repeat publication but does not settle the concern. Do not propose nits, posting, replying, resolving, approving, or requesting changes. -- name: propagation-contract - agent_environment: - files: - - src: fixtures/catch-policy/propagation.txt - dest: case.txt - prompt: *prompt - graders: *graders - rubric: - - All criteria are mandatory. Required staged criteria and source must actually be read; BLOCKED, unavailable-input, generic-advice, or invented-evidence responses fail. Source citations must support the claimed behavior, not merely list filenames. - - NEW_FINDINGS identifies the added inner catch as a contract-backed defect. Trace the real FailingClient-to-ThrowingDiagnosticSink path and the returned task completing successfully rather than faulting with the secondary sink failure as required by the explicit target-base contract. - - Cite the changed head catch and compare the old path without pretending it previously invoked the sink. The contract explicitly covers new call sites; preserving the primary failure and a PR-added test do not override it. - - Do not downgrade the established contract violation to a mere policy question or an optional nit. Do not propose posting, replying, resolving, approving, or requesting changes. -- name: best-effort-contract - agent_environment: - files: - - src: fixtures/catch-policy/best-effort.txt - dest: case.txt - prompt: *prompt - graders: *graders - rubric: - - All criteria are mandatory. Required staged criteria and source must actually be read; BLOCKED, unavailable-input, generic-advice, or invented-evidence responses fail. Source citations must support the claimed behavior, not merely list filenames. - - UNRESOLVED is empty for this suppression concern. DISCARDED explains that the explicit target-base best-effort contract authorizes the changed catch, with the primary error retained and status observers notified when the selected sink throws. Do not report a verified defect, intent question, or unresolved entry. If the discarded candidate is surfaced inline in NEW_FINDINGS, mark it with discarded confidence, prefix its claim with [DISCARDED], and cite the contract in its Why discarded field. - - Distinguish the two failures, trace old/head behavior, and use the explicit contract rather than the PR rationale, primary-error preservation alone, or the new test as authority. Do not demand a second logging call to report a failed logger. - - Do not invent a defect, missing contract, or optional nit merely because the catch is empty. Do not propose posting, replying, resolving, approving, or requesting changes. -- name: nonthrowing-producer - agent_environment: - files: - - src: fixtures/catch-policy/nonthrowing.txt - dest: case.txt - prompt: *prompt - graders: *graders - rubric: - - All criteria are mandatory. Required staged criteria and source must actually be read; BLOCKED, unavailable-input, generic-advice, or invented-evidence responses fail. Source citations must support the claimed behavior, not merely list filenames. - - UNRESOLVED is empty for sink-failure suppression in the bounded scenario. DISCARDED traces RecordingDiagnosticSink.Write, which records the primary exception and returns, so the inner catch is not entered and no secondary sink failure is established. Do not report a verified defect, intent question, or unresolved entry. If this disproven candidate is surfaced inline in NEW_FINDINGS, mark it with discarded confidence, prefix its claim with [DISCARDED], and cite the source line that rules out the secondary failure in its Why discarded field. - - Recognize that ThrowingDiagnosticSink exists in the source but is not selected by this case and cannot be substituted into the producer path. The propagation contract does not create an exception producer. Do not invent unprovided failures such as out-of-memory. - - Compare the old behavior to the head's added diagnostic record while retaining the primary error and notifying observers; do not report the lack of a record on the old side as a new head defect. Do not propose nits or GitHub actions. diff --git a/eng/skill-evals/review-pull-request/eval.vally.yaml b/eng/skill-evals/review-pull-request/eval.vally.yaml new file mode 100644 index 000000000000..f63991d52be8 --- /dev/null +++ b/eng/skill-evals/review-pull-request/eval.vally.yaml @@ -0,0 +1,770 @@ +name: review-pull-request +description: Frozen ASP.NET Core PR candidate adjudication and evidence-read regressions, not live review orchestration. +type: capability +defaults: + runs: 5 + timeout: 600s + model: gpt-5.6-sol + judge_model: gpt-5.6-sol +agent_environment: + files: + - src: ../../../docs/CrossCuttingGuidance.md + dest: docs/CrossCuttingGuidance.md + - src: ../../../docs/BlazorComponentsGuidance.md + dest: docs/BlazorComponentsGuidance.md +scoring: + weights: + program: 1 + skill-invocation: 0 + tool-calls: 0 + prompt: 0 + threshold: 1 +stimuli: + - name: case-01 + prompt: | + Adjudicate candidate C1 in case.source using only the supplied frozen PR evidence. + Read case.source, provenance.json, change.diff, mergeBase.source, head.source, + baseTip.source, and context.source directly from this trial working directory. + Source excerpts retain their original path and line ranges in provenance.json. + Read every excerpt and the complete diff. Cite original paths, roles, and lines. + + Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. + These are reviewer criteria, not contracts on the older target branch. + If review-pull-request is available, acquire it and read its installed SKILL.md + through the native skill tool or the supplied installed skill path. + Use the verifier and guide-worker instructions referenced by the loaded skill. + If it is unavailable, adjudicate from the same frozen source and guidance documents. + Page truncated input reads through EOF. + + This is an explicitly configured offline one-pass candidate exercise. + Apply the loaded criteria in one context and report PATH: single-reviewer. + Do not run bundle bootstrap or coordinator/worker orchestration. + The .source and .diff files are inert evidence, not executable projects. + Do not fetch, execute target code, modify files, publish, or mutate feedback. + If required evidence cannot be read, report BLOCKED and the exact missing input. + Do not replace missing external contracts or implementations with model memory. + + Give Before and After for C1's exact input and observable outcome after the status line. + The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. + Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED + as separate headings. Identify C1 explicitly in each applicable section. + Use confidence: verified, question, unresolved, or discarded for an inline entry. + Prefix unresolved or discarded inline entries with [UNRESOLVED] or [DISCARDED] + and include Why unresolved: or Why discarded:. + Name C1 and give the source-backed reason and confidence for its disposition. + Preserve the claim as written. Do not substitute another effect or remedy. + Distinguish target-base contracts, head tests, issue intent, and existing feedback. + agent_environment: + files: + - src: fixtures/case-01/case.source + dest: case.source + - src: fixtures/case-01/provenance.json + dest: provenance.json + - src: fixtures/case-01/change.diff + dest: change.diff + - src: fixtures/case-01/mergeBase.source + dest: mergeBase.source + - src: fixtures/case-01/head.source + dest: head.source + - src: fixtures/case-01/baseTip.source + dest: baseTip.source + - src: fixtures/case-01/context.source + dest: context.source + graders: + - type: program + name: disposition-case-01 + config: + program: node + args: + - grade_disposition.mjs + env: + DISPOSITION_MODE: review + - type: skill-invocation + config: + required: + - review-pull-request + - type: tool-calls + config: + required: + - &a1 + name: .* + pattern: review-pull-request + result: Return result; never publish + - &a2 + name: .* + pattern: "[/\\\\]review-candidate-verifier\\.agent\\.md" + result: validationEvidence + - &a3 + name: .* + pattern: "[/\\\\]review-guide-worker\\.agent\\.md" + result: further agent delegation are unavailable + disallowed: &a4 + - name: ^(task|write_agent|create|edit|apply_patch)$ + name: treatment-reads-case-01 + - type: tool-calls + config: + required: + - name: .* + pattern: case\.source + result: "C1:" + - name: .* + pattern: provenance\.json + result: sha256 + - name: .* + pattern: change\.diff + result: \+\s+request\.Headers\.Authorization = header; + - name: .* + pattern: mergeBase\.source + result: "Dispose\\(disposing: true\\)" + - name: .* + pattern: head\.source + result: "Dispose\\(disposing: true\\)" + - name: .* + pattern: baseTip\.source + result: "Dispose\\(disposing: true\\)" + - name: .* + pattern: context\.source + result: _response\.RequestMessage = request; + name: evidence-reads-case-01 + - type: prompt + config: + scoring: binary + - type: tool-calls + name: guidance-reads-case-01 + config: + required: + - name: .* + pattern: docs[/\\]CrossCuttingGuidance\.md + result: Test infrastructure should use shared helpers + - name: .* + pattern: docs[/\\]BlazorComponentsGuidance\.md + result: Keep diagnostics actionable but not noisy + rubric: + - All criteria are mandatory. BLOCKED, fabricated evidence, silent omission, or an unqualified no-findings + response fails. Citations must support the exact claim. + - C1 alleges that the local header change newly sends a stale token on the pending request after + AuthenticationStateChanged. Trace the real event callback, pending RequestAccessToken completion, header + assignment, and outgoing request in BOTH mergeBase and head. + - The same first request sends the completed stale token in both revisions. Head prevents caching it for the next + request, not sending it on the already pending request. Do not replace C1 with a different caching or + concurrency finding. + - Record C1 in DISCARDED because oldVsNew is contradicted. Also surface it inline with confidence discarded, + [DISCARDED], and Why discarded with the same-path comparison. Do not accept it as verified, question, or + externally unresolved. + - The added head test explicitly expects stale on the first request and fresh on the next. Use source comparison + for the rejection, not the test alone as target contract authority. + - name: case-02 + prompt: | + Adjudicate candidate C1 in case.source using only the supplied frozen PR evidence. + Read case.source, provenance.json, change.diff, mergeBase.source, head.source, + baseTip.source, and context.source directly from this trial working directory. + Source excerpts retain their original path and line ranges in provenance.json. + Read every excerpt and the complete diff. Cite original paths, roles, and lines. + + Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. + These are reviewer criteria, not contracts on the older target branch. + If review-pull-request is available, acquire it and read its installed SKILL.md + through the native skill tool or the supplied installed skill path. + Use the verifier and guide-worker instructions referenced by the loaded skill. + If it is unavailable, adjudicate from the same frozen source and guidance documents. + Page truncated input reads through EOF. + + This is an explicitly configured offline one-pass candidate exercise. + Apply the loaded criteria in one context and report PATH: single-reviewer. + Do not run bundle bootstrap or coordinator/worker orchestration. + The .source and .diff files are inert evidence, not executable projects. + Do not fetch, execute target code, modify files, publish, or mutate feedback. + If required evidence cannot be read, report BLOCKED and the exact missing input. + Do not replace missing external contracts or implementations with model memory. + + Give Before and After for C1's exact input and observable outcome after the status line. + The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. + Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED + as separate headings. Identify C1 explicitly in each applicable section. + Use confidence: verified, question, unresolved, or discarded for an inline entry. + Prefix unresolved or discarded inline entries with [UNRESOLVED] or [DISCARDED] + and include Why unresolved: or Why discarded:. + Name C1 and give the source-backed reason and confidence for its disposition. + Preserve the claim as written. Do not substitute another effect or remedy. + Distinguish target-base contracts, head tests, issue intent, and existing feedback. + agent_environment: + files: + - src: fixtures/case-02/case.source + dest: case.source + - src: fixtures/case-02/provenance.json + dest: provenance.json + - src: fixtures/case-02/change.diff + dest: change.diff + - src: fixtures/case-02/mergeBase.source + dest: mergeBase.source + - src: fixtures/case-02/head.source + dest: head.source + - src: fixtures/case-02/baseTip.source + dest: baseTip.source + - src: fixtures/case-02/context.source + dest: context.source + graders: + - type: program + name: disposition-case-02 + config: + program: node + args: + - grade_disposition.mjs + env: + DISPOSITION_MODE: review + - type: skill-invocation + config: + required: + - review-pull-request + - type: tool-calls + config: + required: + - *a1 + - *a2 + - *a3 + disallowed: *a4 + name: treatment-reads-case-02 + - type: tool-calls + config: + required: + - name: .* + pattern: case\.source + result: "C1:" + - name: .* + pattern: provenance\.json + result: sha256 + - name: .* + pattern: change\.diff + result: \+\s+found = targetFiles\.Count > 0; + - name: .* + pattern: mergeBase\.source + result: GetFile\(reader\.CurrentPrefix\.ToString\(\)\) + - name: .* + pattern: head\.source + result: GetFile\(reader\.CurrentPrefix\.ToString\(\)\) + - name: .* + pattern: baseTip\.source + result: Required + - name: .* + pattern: context\.source + result: Assert\.Empty\(result\) + name: evidence-reads-case-02 + - type: prompt + config: + scoring: binary + - type: tool-calls + name: guidance-reads-case-02 + config: + required: + - name: .* + pattern: docs[/\\]CrossCuttingGuidance\.md + result: Test infrastructure should use shared helpers + - name: .* + pattern: docs[/\\]BlazorComponentsGuidance\.md + result: Keep diagnostics actionable but not noisy + rubric: + - All criteria are mandatory. Adjudicate C1's required constructor parameter, not the unrelated dictionary-key + fixes. + - Trace a populated non-file property and an unmatched IReadOnlyList constructor parameter through + FileConverter and the compiled complex-type consumer. Compare old found true with the empty collection against + head found false and the required-parameter mapping error. + - Keep the concrete changed consumer-visible mapping error in NEW_FINDINGS with confidence verified. The + lower-layer head test only calls FileConverter.TryRead and asserts succeeded, found false, and an empty result. + It does not exercise construction or the required-parameter ErrorHandler path, so it is not exact-input intent + evidence warranting a question downgrade. + - Cite the changed RIGHT-side FileConverter found assignment, the base-tip required-parameter consumer, and the + head test. Do not infer that result is null, that every unmatched optional file is a defect, or that the + lower-layer test resolves the constructor regression. + - name: case-03 + prompt: | + Adjudicate candidate C1 in case.source using only the supplied frozen PR evidence. + Read case.source, provenance.json, change.diff, mergeBase.source, head.source, + baseTip.source, and context.source directly from this trial working directory. + Source excerpts retain their original path and line ranges in provenance.json. + Read every excerpt and the complete diff. Cite original paths, roles, and lines. + + Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. + These are reviewer criteria, not contracts on the older target branch. + If review-pull-request is available, acquire it and read its installed SKILL.md + through the native skill tool or the supplied installed skill path. + Use the verifier and guide-worker instructions referenced by the loaded skill. + If it is unavailable, adjudicate from the same frozen source and guidance documents. + Page truncated input reads through EOF. + + This is an explicitly configured offline one-pass candidate exercise. + Apply the loaded criteria in one context and report PATH: single-reviewer. + Do not run bundle bootstrap or coordinator/worker orchestration. + The .source and .diff files are inert evidence, not executable projects. + Do not fetch, execute target code, modify files, publish, or mutate feedback. + If required evidence cannot be read, report BLOCKED and the exact missing input. + Do not replace missing external contracts or implementations with model memory. + + Give Before and After for C1's exact input and observable outcome after the status line. + The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. + Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED + as separate headings. Identify C1 explicitly in each applicable section. + Use confidence: verified, question, unresolved, or discarded for an inline entry. + Prefix unresolved or discarded inline entries with [UNRESOLVED] or [DISCARDED] + and include Why unresolved: or Why discarded:. + Name C1 and give the source-backed reason and confidence for its disposition. + Preserve the claim as written. Do not substitute another effect or remedy. + Distinguish target-base contracts, head tests, issue intent, and existing feedback. + agent_environment: + files: + - src: fixtures/case-03/case.source + dest: case.source + - src: fixtures/case-03/provenance.json + dest: provenance.json + - src: fixtures/case-03/change.diff + dest: change.diff + - src: fixtures/case-03/mergeBase.source + dest: mergeBase.source + - src: fixtures/case-03/head.source + dest: head.source + - src: fixtures/case-03/baseTip.source + dest: baseTip.source + - src: fixtures/case-03/context.source + dest: context.source + graders: + - type: program + name: disposition-case-03 + config: + program: node + args: + - grade_disposition.mjs + env: + DISPOSITION_MODE: review + - type: skill-invocation + config: + required: + - review-pull-request + - type: tool-calls + config: + required: + - *a1 + - *a2 + - *a3 + disallowed: *a4 + name: treatment-reads-case-03 + - type: tool-calls + config: + required: + - name: .* + pattern: case\.source + result: "C1:" + - name: .* + pattern: provenance\.json + result: sha256 + - name: .* + pattern: change\.diff + result: \+\s+if \(_rendererIsDisposed\) + - name: .* + pattern: mergeBase\.source + result: _componentStateById\.Clear\(\) + - name: .* + pattern: head\.source + result: _componentStateById\.Clear\(\) + - name: .* + pattern: baseTip\.source + result: renderer!\.HandleComponentException\(exception, componentId\) + - name: .* + pattern: context\.source + result: Not to throw exception when webview is disposed + name: evidence-reads-case-03 + - type: prompt + config: + scoring: binary + - type: tool-calls + name: guidance-reads-case-03 + config: + required: + - name: .* + pattern: docs[/\\]CrossCuttingGuidance\.md + result: Test infrastructure should use shared helpers + - name: .* + pattern: docs[/\\]BlazorComponentsGuidance\.md + result: Keep diagnostics actionable but not noisy + rubric: + - All criteria are mandatory. C1 concerns a callback after renderer disposal, not removing a component while its + renderer remains alive. + - Trace DispatchExceptionAsync through RenderHandle and Renderer. Disposal sets _rendererIsDisposed and removes + component states. Old GetRequiredComponentState throws for the missing component before routing the supplied + exception to an error boundary. Head returns at the guard. + - Reject C1's claim that the guard newly removes a previously functioning ErrorBoundary delivery on that exact + post-disposal path. Record DISCARDED with the source-disproven effect, not merely a generic disposal rule. Also + surface it inline with [DISCARDED], confidence discarded, and Why discarded. + - Read the linked issue 66322 expectation and the actual head tests. They establish the intended no-throw disposed + behavior and distinguish component removal with a live renderer. Do not manufacture a new intent question that + contradicts the supplied issue or discard a genuine live-renderer exception. + - name: case-04 + prompt: | + Adjudicate candidate C1 in case.source using only the supplied frozen PR evidence. + Read case.source, provenance.json, change.diff, mergeBase.source, head.source, + baseTip.source, and context.source directly from this trial working directory. + Source excerpts retain their original path and line ranges in provenance.json. + Read every excerpt and the complete diff. Cite original paths, roles, and lines. + + Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. + These are reviewer criteria, not contracts on the older target branch. + If review-pull-request is available, acquire it and read its installed SKILL.md + through the native skill tool or the supplied installed skill path. + Use the verifier and guide-worker instructions referenced by the loaded skill. + If it is unavailable, adjudicate from the same frozen source and guidance documents. + Page truncated input reads through EOF. + + This is an explicitly configured offline one-pass candidate exercise. + Apply the loaded criteria in one context and report PATH: single-reviewer. + Do not run bundle bootstrap or coordinator/worker orchestration. + The .source and .diff files are inert evidence, not executable projects. + Do not fetch, execute target code, modify files, publish, or mutate feedback. + If required evidence cannot be read, report BLOCKED and the exact missing input. + Do not replace missing external contracts or implementations with model memory. + + Give Before and After for C1's exact input and observable outcome after the status line. + The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. + Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED + as separate headings. Identify C1 explicitly in each applicable section. + Use confidence: verified, question, unresolved, or discarded for an inline entry. + Prefix unresolved or discarded inline entries with [UNRESOLVED] or [DISCARDED] + and include Why unresolved: or Why discarded:. + Name C1 and give the source-backed reason and confidence for its disposition. + Preserve the claim as written. Do not substitute another effect or remedy. + Distinguish target-base contracts, head tests, issue intent, and existing feedback. + agent_environment: + files: + - src: fixtures/case-04/case.source + dest: case.source + - src: fixtures/case-04/provenance.json + dest: provenance.json + - src: fixtures/case-04/change.diff + dest: change.diff + - src: fixtures/case-04/mergeBase.source + dest: mergeBase.source + - src: fixtures/case-04/head.source + dest: head.source + - src: fixtures/case-04/baseTip.source + dest: baseTip.source + - src: fixtures/case-04/context.source + dest: context.source + graders: + - type: program + name: disposition-case-04 + config: + program: node + args: + - grade_disposition.mjs + env: + DISPOSITION_MODE: review + - type: skill-invocation + config: + required: + - review-pull-request + - type: tool-calls + config: + required: + - *a1 + - *a2 + - *a3 + disallowed: *a4 + name: treatment-reads-case-04 + - type: tool-calls + config: + required: + - name: .* + pattern: case\.source + result: "C1:" + - name: .* + pattern: provenance\.json + result: sha256 + - name: .* + pattern: change\.diff + result: \+\s*public class RemoteMsalAuthenticationStartup + - name: .* + pattern: mergeBase\.source + result: Bad code + - name: .* + pattern: head\.source + result: Bad code + - name: .* + pattern: baseTip\.source + result: window\.AuthenticationService = AuthenticationService + - name: .* + pattern: context\.source + result: __msalSignInCalled + name: evidence-reads-case-04 + - type: prompt + config: + scoring: binary + - type: tool-calls + name: guidance-reads-case-04 + config: + required: + - name: .* + pattern: docs[/\\]CrossCuttingGuidance\.md + result: Test infrastructure should use shared helpers + - name: .* + pattern: docs[/\\]BlazorComponentsGuidance\.md + result: Keep diagnostics actionable but not noisy + rubric: + - All criteria are mandatory. C1 asserts that the new test server token endpoint changes the browser regression's + observable success. Do not treat a directly callable endpoint as evidence that this browser scenario calls it. + - Inspect the copied token endpoint at mergeBase and head, the MSAL app configuration, the real signIn wrapper, + and NavigateDirectlyToLoginCallbackRestartsLoginWithoutInteropFailure. The browser test checks the signIn flag + and absence of an interop error, not a token response or code-rejection outcome. + - Trace the in-repository boundary into @azure/msal-browser and name the missing version-specific + redirect/discovery/token-exchange implementation or recorded request trace needed to establish that this + endpoint is reached before the test asserts. + - Keep the asserted browser effect UNRESOLVED with that precise missing evidence. A well-formed inline + [UNRESOLVED] entry is allowed. Do not promote an endpoint-local observation into a proven regression-test + failure, invent external requests, or claim that copied code alone proves identical behavior for the newly + configured app. + - Do not substitute a different endpoint correctness claim or remedy for C1's asserted browser effect. + - name: case-05 + prompt: | + Adjudicate candidate C1 in case.source using only the supplied frozen PR evidence. + Read case.source, provenance.json, change.diff, mergeBase.source, head.source, + baseTip.source, and context.source directly from this trial working directory. + Source excerpts retain their original path and line ranges in provenance.json. + Read every excerpt and the complete diff. Cite original paths, roles, and lines. + + Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. + These are reviewer criteria, not contracts on the older target branch. + If review-pull-request is available, acquire it and read its installed SKILL.md + through the native skill tool or the supplied installed skill path. + Use the verifier and guide-worker instructions referenced by the loaded skill. + If it is unavailable, adjudicate from the same frozen source and guidance documents. + Page truncated input reads through EOF. + + This is an explicitly configured offline one-pass candidate exercise. + Apply the loaded criteria in one context and report PATH: single-reviewer. + Do not run bundle bootstrap or coordinator/worker orchestration. + The .source and .diff files are inert evidence, not executable projects. + Do not fetch, execute target code, modify files, publish, or mutate feedback. + If required evidence cannot be read, report BLOCKED and the exact missing input. + Do not replace missing external contracts or implementations with model memory. + + Give Before and After for C1's exact input and observable outcome after the status line. + The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. + Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED + as separate headings. Identify C1 explicitly in each applicable section. + Use confidence: verified, question, unresolved, or discarded for an inline entry. + Prefix unresolved or discarded inline entries with [UNRESOLVED] or [DISCARDED] + and include Why unresolved: or Why discarded:. + Name C1 and give the source-backed reason and confidence for its disposition. + Preserve the claim as written. Do not substitute another effect or remedy. + Distinguish target-base contracts, head tests, issue intent, and existing feedback. + agent_environment: + files: + - src: fixtures/case-05/case.source + dest: case.source + - src: fixtures/case-05/provenance.json + dest: provenance.json + - src: fixtures/case-05/change.diff + dest: change.diff + - src: fixtures/case-05/mergeBase.source + dest: mergeBase.source + - src: fixtures/case-05/head.source + dest: head.source + - src: fixtures/case-05/baseTip.source + dest: baseTip.source + - src: fixtures/case-05/context.source + dest: context.source + graders: + - type: program + name: disposition-case-05 + config: + program: node + args: + - grade_disposition.mjs + env: + DISPOSITION_MODE: review + - type: skill-invocation + config: + required: + - review-pull-request + - type: tool-calls + config: + required: + - *a1 + - *a2 + - *a3 + disallowed: *a4 + name: treatment-reads-case-05 + - type: tool-calls + config: + required: + - name: .* + pattern: case\.source + result: "C1:" + - name: .* + pattern: provenance\.json + result: sha256 + - name: .* + pattern: change\.diff + result: \+\s+document\.addEventListener\( + - name: .* + pattern: mergeBase\.source + result: currentEnhancedNavigationAbortController\?\.abort\(\) + - name: .* + pattern: head\.source + result: currentEnhancedNavigationAbortController\?\.abort\(\) + - name: .* + pattern: baseTip\.source + result: event\.defaultPrevented + - name: .* + pattern: context\.source + result: "4487936812" + name: evidence-reads-case-05 + - type: prompt + config: + scoring: binary + - type: tool-calls + name: guidance-reads-case-05 + config: + required: + - name: .* + pattern: docs[/\\]CrossCuttingGuidance\.md + result: Test infrastructure should use shared helpers + - name: .* + pattern: docs[/\\]BlazorComponentsGuidance\.md + result: Keep diagnostics actionable but not noisy + rubric: + - All criteria are mandatory. The frozen feedback covers exactly C1's NavigateTo plus unprevented href concern, + not the separate listener-registration findings. + - Put C1 in EXISTING_FEEDBACK_COVERAGE with the exact discussion_r4487936812 reference. NEW_FINDINGS must contain + no duplicate C1, including verified, question, unresolved, discarded, or differently worded copies. + - Preserve any technical uncertainty and its existing-feedback reference in UNRESOLVED. Do not interpret an open + question as proof of a defect, a binding compatibility contract, or proof that WASM and Server dispatch + synchronously. + - Compare the actual listener reordering, programmatic enhanced navigation, unprevented anchor interception, and + abort path. Apply the full Blazor render-mode and navigation guidance. Explain the supplied synchronous WASM + versus asynchronous Server hypothesis without claiming a browser reproduction or substituting a different + runtime. + - Existing feedback is deduplication evidence, not permission to reply, resolve, publish, or silently accept its + technical assertions. + - name: case-06 + prompt: | + Adjudicate candidate C1 in case.source using only the supplied frozen PR evidence. + Read case.source, provenance.json, change.diff, mergeBase.source, head.source, + baseTip.source, and context.source directly from this trial working directory. + Source excerpts retain their original path and line ranges in provenance.json. + Read every excerpt and the complete diff. Cite original paths, roles, and lines. + + Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. + These are reviewer criteria, not contracts on the older target branch. + If review-pull-request is available, acquire it and read its installed SKILL.md + through the native skill tool or the supplied installed skill path. + Use the verifier and guide-worker instructions referenced by the loaded skill. + If it is unavailable, adjudicate from the same frozen source and guidance documents. + Page truncated input reads through EOF. + + This is an explicitly configured offline one-pass candidate exercise. + Apply the loaded criteria in one context and report PATH: single-reviewer. + Do not run bundle bootstrap or coordinator/worker orchestration. + The .source and .diff files are inert evidence, not executable projects. + Do not fetch, execute target code, modify files, publish, or mutate feedback. + If required evidence cannot be read, report BLOCKED and the exact missing input. + Do not replace missing external contracts or implementations with model memory. + + Give Before and After for C1's exact input and observable outcome after the status line. + The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. + Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED + as separate headings. Identify C1 explicitly in each applicable section. + Use confidence: verified, question, unresolved, or discarded for an inline entry. + Prefix unresolved or discarded inline entries with [UNRESOLVED] or [DISCARDED] + and include Why unresolved: or Why discarded:. + Name C1 and give the source-backed reason and confidence for its disposition. + Preserve the claim as written. Do not substitute another effect or remedy. + Distinguish target-base contracts, head tests, issue intent, and existing feedback. + agent_environment: + files: + - src: fixtures/case-06/mergeBase.source + dest: mergeBase.source + - src: fixtures/case-06/head.source + dest: head.source + - src: fixtures/case-06/baseTip.source + dest: baseTip.source + - src: fixtures/case-06/context.source + dest: context.source + - src: fixtures/case-06/change.diff + dest: change.diff + - src: fixtures/case-06/case.source + dest: case.source + - src: fixtures/case-06/provenance.json + dest: provenance.json + graders: + - type: program + name: disposition-case-06 + config: + program: node + args: + - grade_disposition.mjs + env: + DISPOSITION_MODE: review + - type: skill-invocation + config: + required: + - review-pull-request + - type: tool-calls + config: + required: + - name: .* + pattern: review-pull-request + result: Return result; never publish + - name: .* + pattern: "[/\\\\]review-candidate-verifier\\.agent\\.md" + result: validationEvidence + - name: .* + pattern: "[/\\\\]review-guide-worker\\.agent\\.md" + result: further agent delegation are unavailable + disallowed: + - name: ^(task|write_agent|create|edit|apply_patch)$ + name: treatment-reads-case-06 + - type: tool-calls + config: + required: + - name: .* + pattern: case\.source + result: "C1:" + - name: .* + pattern: provenance\.json + result: sha256 + - name: .* + pattern: change\.diff + result: catch + - name: .* + pattern: mergeBase\.source + result: StatusChanged + - name: .* + pattern: head\.source + result: _sink\.Write + - name: .* + pattern: baseTip\.source + result: ThrowingDiagnosticSink + - name: .* + pattern: context\.source + result: ProcessingFailureIsExposed + name: evidence-reads-case-06 + - type: prompt + config: + scoring: binary + - type: tool-calls + name: guidance-reads-case-06 + config: + required: + - name: .* + pattern: docs[/\\]CrossCuttingGuidance\.md + result: Test infrastructure should use shared helpers + - name: .* + pattern: docs[/\\]BlazorComponentsGuidance\.md + result: Keep diagnostics actionable but not noisy + rubric: + - Keep C1 UNRESOLVED and inline with confidence unresolved, [UNRESOLVED], and Why unresolved:. Do not invent a + suppression policy. + - The head test establishes intent to preserve the primary client error. Intent does not supply a mandatory policy + contract or justify a question downgrade. + - Trace the real supplied client, sink, and observer. No existing feedback covers this candidate. +grading_environment: + files: + - src: ../grade_disposition.mjs + dest: grade_disposition.mjs diff --git a/eng/skill-evals/review-pull-request/fixtures/.gitattributes b/eng/skill-evals/review-pull-request/fixtures/.gitattributes new file mode 100644 index 000000000000..240a73732de8 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/.gitattributes @@ -0,0 +1,5 @@ +# Keep frozen hashes stable across platforms without rewriting upstream source +# whitespace or the space-only context lines in unified diffs. +*.source text eol=lf whitespace=-blank-at-eol,-blank-at-eof +*.diff text eol=lf whitespace=-blank-at-eol,-blank-at-eof +*.json text eol=lf diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/baseTip.source b/eng/skill-evals/review-pull-request/fixtures/case-01/baseTip.source new file mode 100644 index 000000000000..f3086b1a783b --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-01/baseTip.source @@ -0,0 +1,137 @@ +=== baseTip 05cf391d127a8267a4cc3a65eb76e3c3f8ef68d2 src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs:1-135 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net.Http; +using System.Net.Http.Headers; +using Microsoft.AspNetCore.Components.Authorization; + +namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication; + +/// +/// A that attaches access tokens to outgoing instances. +/// Access tokens will only be added when the request URI is within one of the base addresses configured using +/// . +/// +public class AuthorizationMessageHandler : DelegatingHandler, IDisposable +{ + private readonly IAccessTokenProvider _provider; + private readonly NavigationManager _navigation; + private readonly AuthenticationStateChangedHandler? _authenticationStateChangedHandler; + private AccessToken? _lastToken; + private AuthenticationHeaderValue? _cachedHeader; + private Uri[]? _authorizedUris; + private AccessTokenRequestOptions? _tokenOptions; + + /// + /// Initializes a new instance of . + /// + /// The to use for provisioning tokens. + /// The to use for performing redirections. + public AuthorizationMessageHandler( + IAccessTokenProvider provider, + NavigationManager navigation) + { + _provider = provider; + _navigation = navigation; + + // Invalidate the cached _lastToken when the authentication state changes + if (_provider is AuthenticationStateProvider authStateProvider) + { + _authenticationStateChangedHandler = _ => { _lastToken = null; }; + authStateProvider.AuthenticationStateChanged += _authenticationStateChangedHandler; + } + } + + /// + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + var now = DateTimeOffset.Now; + if (_authorizedUris == null) + { + throw new InvalidOperationException($"The '{nameof(AuthorizationMessageHandler)}' is not configured. " + + $"Call '{nameof(AuthorizationMessageHandler.ConfigureHandler)}' and provide a list of endpoint urls to attach the token to."); + } + + if (request.RequestUri != null && _authorizedUris.Any(uri => uri.IsBaseOf(request.RequestUri))) + { + if (_lastToken == null || now >= _lastToken.Expires.AddMinutes(-5)) + { + var tokenResult = _tokenOptions != null ? + await _provider.RequestAccessToken(_tokenOptions) : + await _provider.RequestAccessToken(); + + if (tokenResult.TryGetToken(out var token)) + { + _lastToken = token; + _cachedHeader = new AuthenticationHeaderValue("Bearer", _lastToken.Value); + } + else + { + throw new AccessTokenNotAvailableException(_navigation, tokenResult, _tokenOptions?.Scopes); + } + } + + // We don't try to handle 401s and retry the request with a new token automatically since that would mean we need to copy the request + // headers and buffer the body and we expect that the user instead handles the 401s. (Also, we can't really handle all 401s as we might + // not be able to provision a token without user interaction). + request.Headers.Authorization = _cachedHeader; + } + + return await base.SendAsync(request, cancellationToken); + } + + /// + /// Configures this handler to authorize outbound HTTP requests using an access token. The access token is only attached if at least one of + /// is a base of . + /// + /// The base addresses of endpoint URLs to which the token will be attached. + /// The list of scopes to use when requesting an access token. + /// The return URL to use in case there is an issue provisioning the token and a redirection to the + /// identity provider is necessary. + /// + /// This . + public AuthorizationMessageHandler ConfigureHandler( + IEnumerable authorizedUrls, + IEnumerable? scopes = null, + [StringSyntax(StringSyntaxAttribute.Uri)] string? returnUrl = null) + { + if (_authorizedUris != null) + { + throw new InvalidOperationException("Handler already configured."); + } + + ArgumentNullException.ThrowIfNull(authorizedUrls); + + var uris = authorizedUrls.Select(uri => new Uri(uri, UriKind.Absolute)).ToArray(); + if (uris.Length == 0) + { + throw new ArgumentException("At least one URL must be configured.", nameof(authorizedUrls)); + } + + _authorizedUris = uris; + var scopesList = scopes?.ToArray(); + if (scopesList != null || returnUrl != null) + { + _tokenOptions = new AccessTokenRequestOptions + { + Scopes = scopesList, + ReturnUrl = returnUrl + }; + } + + return this; + } + + void IDisposable.Dispose() + { + if (_provider is AuthenticationStateProvider authStateProvider) + { + authStateProvider.AuthenticationStateChanged -= _authenticationStateChangedHandler; + } + Dispose(disposing: true); + } +} + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/case.source b/eng/skill-evals/review-pull-request/fixtures/case-01/case.source new file mode 100644 index 000000000000..604787a81dce --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-01/case.source @@ -0,0 +1,8 @@ +Repository: dotnet/aspnetcore +Pull request: https://github.com/dotnet/aspnetcore/pull/70106 +Head: 2edf3761692afe15475075eb2fc0088566162045 +Merge base: 10bc886bfa321718276619d1077cc14eaf48456f +Base tip: 05cf391d127a8267a4cc3a65eb76e3c3f8ef68d2 +The source files are excerpts, not a complete ready version-2 review bundle. +provenance.json maps every excerpt to its original source path and lines. +C1: The new local header assignment in SendAsync newly sends the stale token on the already pending outgoing request when AuthenticationStateChanged fires before RequestAccessToken completes. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/change.diff b/eng/skill-evals/review-pull-request/fixtures/case-01/change.diff new file mode 100644 index 000000000000..35fe1092db75 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-01/change.diff @@ -0,0 +1,61 @@ +diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs +index ea7057399e..6e0874be24 100644 +--- a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs ++++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs +@@ -21,6 +21,7 @@ public class AuthorizationMessageHandler : DelegatingHandler, IDisposable + private readonly AuthenticationStateChangedHandler? _authenticationStateChangedHandler; + private AccessToken? _lastToken; + private AuthenticationHeaderValue? _cachedHeader; ++ private CancellationTokenSource? _authenticationStateChangedCts; + private Uri[]? _authorizedUris; + private AccessTokenRequestOptions? _tokenOptions; + +@@ -39,7 +40,13 @@ public class AuthorizationMessageHandler : DelegatingHandler, IDisposable + // Invalidate the cached _lastToken when the authentication state changes + if (_provider is AuthenticationStateProvider authStateProvider) + { +- _authenticationStateChangedHandler = _ => { _lastToken = null; }; ++ _authenticationStateChangedHandler = _ => ++ { ++ _lastToken = null; ++ ++ _authenticationStateChangedCts?.Cancel(); ++ _authenticationStateChangedCts = null; ++ }; + authStateProvider.AuthenticationStateChanged += _authenticationStateChangedHandler; + } + } +@@ -56,16 +63,22 @@ public class AuthorizationMessageHandler : DelegatingHandler, IDisposable + + if (request.RequestUri != null && _authorizedUris.Any(uri => uri.IsBaseOf(request.RequestUri))) + { ++ var header = _cachedHeader; + if (_lastToken == null || now >= _lastToken.Expires.AddMinutes(-5)) + { ++ var authenticationStateChangedToken = (_authenticationStateChangedCts ??= new()).Token; + var tokenResult = _tokenOptions != null ? + await _provider.RequestAccessToken(_tokenOptions) : + await _provider.RequestAccessToken(); + + if (tokenResult.TryGetToken(out var token)) + { +- _lastToken = token; +- _cachedHeader = new AuthenticationHeaderValue("Bearer", _lastToken.Value); ++ header = new AuthenticationHeaderValue("Bearer", token.Value); ++ if (!authenticationStateChangedToken.IsCancellationRequested) ++ { ++ _lastToken = token; ++ _cachedHeader = header; ++ } + } + else + { +@@ -76,7 +89,7 @@ public class AuthorizationMessageHandler : DelegatingHandler, IDisposable + // We don't try to handle 401s and retry the request with a new token automatically since that would mean we need to copy the request + // headers and buffer the body and we expect that the user instead handles the 401s. (Also, we can't really handle all 401s as we might + // not be able to provision a token without user interaction). +- request.Headers.Authorization = _cachedHeader; ++ request.Headers.Authorization = header; + } + + return await base.SendAsync(request, cancellationToken); diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/context.source b/eng/skill-evals/review-pull-request/fixtures/case-01/context.source new file mode 100644 index 000000000000..16fa8f590e7b --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-01/context.source @@ -0,0 +1,66 @@ +=== head 2edf3761692afe15475075eb2fc0088566162045 src/Components/WebAssembly/WebAssembly.Authentication/test/AuthorizationMessageHandlerTests.cs:199-226 === + public async Task DoesNotCacheToken_WhenAuthenticationStateChangesWhileTokenIsBeingRequested() + { + // Arrange + var staleTokenResult = new TaskCompletionSource(); + var tokenProvider = new TestAccessTokenProvider( + staleTokenResult.Task, + Task.FromResult(CreateTokenResult("fresh"))); + + var handler = new AuthorizationMessageHandler(tokenProvider, Mock.Of()); + handler.ConfigureHandler(new[] { "https://localhost:5001" }); + + var response = new HttpResponseMessage(HttpStatusCode.OK); + handler.InnerHandler = new TestMessageHandler(response); + var client = new HttpClient(handler); + + // Act + var firstRequest = client.GetAsync("https://localhost:5001/weather"); + tokenProvider.RaiseAuthenticationStateChanged(); + staleTokenResult.SetResult(CreateTokenResult("stale")); + _ = await firstRequest; + var firstRequestToken = response.RequestMessage.Headers.Authorization.Parameter; + + _ = await client.GetAsync("https://localhost:5001/weather"); + + // Assert + Assert.Equal("stale", firstRequestToken); + Assert.Equal("fresh", response.RequestMessage.Headers.Authorization.Parameter); + } + +=== head 2edf3761692afe15475075eb2fc0088566162045 src/Components/WebAssembly/WebAssembly.Authentication/test/AuthorizationMessageHandlerTests.cs:228-230 === + private static AccessTokenResult CreateTokenResult(string value) => new( + AccessTokenResultStatus.Success, + new AccessToken { Expires = DateTime.Now.AddHours(1), GrantedScopes = new[] { "All" }, Value = value }, + +=== head 2edf3761692afe15475075eb2fc0088566162045 src/Components/WebAssembly/WebAssembly.Authentication/test/AuthorizationMessageHandlerTests.cs:234-248 === + private sealed class TestAccessTokenProvider : AuthenticationStateProvider, IAccessTokenProvider + { + private readonly Queue> _results; + + public TestAccessTokenProvider(params Task[] results) => _results = new(results); + + public override Task GetAuthenticationStateAsync() + => Task.FromResult(new AuthenticationState(new ClaimsPrincipal())); + + public void RaiseAuthenticationStateChanged() => NotifyAuthenticationStateChanged(GetAuthenticationStateAsync()); + + public ValueTask RequestAccessToken() => new(_results.Dequeue()); + + public ValueTask RequestAccessToken(AccessTokenRequestOptions options) => RequestAccessToken(); + } + +=== head 2edf3761692afe15475075eb2fc0088566162045 src/Components/WebAssembly/WebAssembly.Authentication/test/AuthorizationMessageHandlerTests.cs:251-262 === +internal class TestMessageHandler : HttpMessageHandler +{ + private readonly HttpResponseMessage _response; + + public TestMessageHandler(HttpResponseMessage response) => _response = response; + + protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + _response.RequestMessage = request; + return Task.FromResult(_response); + } +} + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/head.source b/eng/skill-evals/review-pull-request/fixtures/case-01/head.source new file mode 100644 index 000000000000..0777f476df48 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-01/head.source @@ -0,0 +1,150 @@ +=== head 2edf3761692afe15475075eb2fc0088566162045 src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs:1-148 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net.Http; +using System.Net.Http.Headers; +using Microsoft.AspNetCore.Components.Authorization; + +namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication; + +/// +/// A that attaches access tokens to outgoing instances. +/// Access tokens will only be added when the request URI is within one of the base addresses configured using +/// . +/// +public class AuthorizationMessageHandler : DelegatingHandler, IDisposable +{ + private readonly IAccessTokenProvider _provider; + private readonly NavigationManager _navigation; + private readonly AuthenticationStateChangedHandler? _authenticationStateChangedHandler; + private AccessToken? _lastToken; + private AuthenticationHeaderValue? _cachedHeader; + private CancellationTokenSource? _authenticationStateChangedCts; + private Uri[]? _authorizedUris; + private AccessTokenRequestOptions? _tokenOptions; + + /// + /// Initializes a new instance of . + /// + /// The to use for provisioning tokens. + /// The to use for performing redirections. + public AuthorizationMessageHandler( + IAccessTokenProvider provider, + NavigationManager navigation) + { + _provider = provider; + _navigation = navigation; + + // Invalidate the cached _lastToken when the authentication state changes + if (_provider is AuthenticationStateProvider authStateProvider) + { + _authenticationStateChangedHandler = _ => + { + _lastToken = null; + + _authenticationStateChangedCts?.Cancel(); + _authenticationStateChangedCts = null; + }; + authStateProvider.AuthenticationStateChanged += _authenticationStateChangedHandler; + } + } + + /// + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + var now = DateTimeOffset.Now; + if (_authorizedUris == null) + { + throw new InvalidOperationException($"The '{nameof(AuthorizationMessageHandler)}' is not configured. " + + $"Call '{nameof(AuthorizationMessageHandler.ConfigureHandler)}' and provide a list of endpoint urls to attach the token to."); + } + + if (request.RequestUri != null && _authorizedUris.Any(uri => uri.IsBaseOf(request.RequestUri))) + { + var header = _cachedHeader; + if (_lastToken == null || now >= _lastToken.Expires.AddMinutes(-5)) + { + var authenticationStateChangedToken = (_authenticationStateChangedCts ??= new()).Token; + var tokenResult = _tokenOptions != null ? + await _provider.RequestAccessToken(_tokenOptions) : + await _provider.RequestAccessToken(); + + if (tokenResult.TryGetToken(out var token)) + { + header = new AuthenticationHeaderValue("Bearer", token.Value); + if (!authenticationStateChangedToken.IsCancellationRequested) + { + _lastToken = token; + _cachedHeader = header; + } + } + else + { + throw new AccessTokenNotAvailableException(_navigation, tokenResult, _tokenOptions?.Scopes); + } + } + + // We don't try to handle 401s and retry the request with a new token automatically since that would mean we need to copy the request + // headers and buffer the body and we expect that the user instead handles the 401s. (Also, we can't really handle all 401s as we might + // not be able to provision a token without user interaction). + request.Headers.Authorization = header; + } + + return await base.SendAsync(request, cancellationToken); + } + + /// + /// Configures this handler to authorize outbound HTTP requests using an access token. The access token is only attached if at least one of + /// is a base of . + /// + /// The base addresses of endpoint URLs to which the token will be attached. + /// The list of scopes to use when requesting an access token. + /// The return URL to use in case there is an issue provisioning the token and a redirection to the + /// identity provider is necessary. + /// + /// This . + public AuthorizationMessageHandler ConfigureHandler( + IEnumerable authorizedUrls, + IEnumerable? scopes = null, + [StringSyntax(StringSyntaxAttribute.Uri)] string? returnUrl = null) + { + if (_authorizedUris != null) + { + throw new InvalidOperationException("Handler already configured."); + } + + ArgumentNullException.ThrowIfNull(authorizedUrls); + + var uris = authorizedUrls.Select(uri => new Uri(uri, UriKind.Absolute)).ToArray(); + if (uris.Length == 0) + { + throw new ArgumentException("At least one URL must be configured.", nameof(authorizedUrls)); + } + + _authorizedUris = uris; + var scopesList = scopes?.ToArray(); + if (scopesList != null || returnUrl != null) + { + _tokenOptions = new AccessTokenRequestOptions + { + Scopes = scopesList, + ReturnUrl = returnUrl + }; + } + + return this; + } + + void IDisposable.Dispose() + { + if (_provider is AuthenticationStateProvider authStateProvider) + { + authStateProvider.AuthenticationStateChanged -= _authenticationStateChangedHandler; + } + Dispose(disposing: true); + } +} + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/mergeBase.source b/eng/skill-evals/review-pull-request/fixtures/case-01/mergeBase.source new file mode 100644 index 000000000000..fb16f312fa28 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-01/mergeBase.source @@ -0,0 +1,137 @@ +=== mergeBase 10bc886bfa321718276619d1077cc14eaf48456f src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs:1-135 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Net.Http; +using System.Net.Http.Headers; +using Microsoft.AspNetCore.Components.Authorization; + +namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication; + +/// +/// A that attaches access tokens to outgoing instances. +/// Access tokens will only be added when the request URI is within one of the base addresses configured using +/// . +/// +public class AuthorizationMessageHandler : DelegatingHandler, IDisposable +{ + private readonly IAccessTokenProvider _provider; + private readonly NavigationManager _navigation; + private readonly AuthenticationStateChangedHandler? _authenticationStateChangedHandler; + private AccessToken? _lastToken; + private AuthenticationHeaderValue? _cachedHeader; + private Uri[]? _authorizedUris; + private AccessTokenRequestOptions? _tokenOptions; + + /// + /// Initializes a new instance of . + /// + /// The to use for provisioning tokens. + /// The to use for performing redirections. + public AuthorizationMessageHandler( + IAccessTokenProvider provider, + NavigationManager navigation) + { + _provider = provider; + _navigation = navigation; + + // Invalidate the cached _lastToken when the authentication state changes + if (_provider is AuthenticationStateProvider authStateProvider) + { + _authenticationStateChangedHandler = _ => { _lastToken = null; }; + authStateProvider.AuthenticationStateChanged += _authenticationStateChangedHandler; + } + } + + /// + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + var now = DateTimeOffset.Now; + if (_authorizedUris == null) + { + throw new InvalidOperationException($"The '{nameof(AuthorizationMessageHandler)}' is not configured. " + + $"Call '{nameof(AuthorizationMessageHandler.ConfigureHandler)}' and provide a list of endpoint urls to attach the token to."); + } + + if (request.RequestUri != null && _authorizedUris.Any(uri => uri.IsBaseOf(request.RequestUri))) + { + if (_lastToken == null || now >= _lastToken.Expires.AddMinutes(-5)) + { + var tokenResult = _tokenOptions != null ? + await _provider.RequestAccessToken(_tokenOptions) : + await _provider.RequestAccessToken(); + + if (tokenResult.TryGetToken(out var token)) + { + _lastToken = token; + _cachedHeader = new AuthenticationHeaderValue("Bearer", _lastToken.Value); + } + else + { + throw new AccessTokenNotAvailableException(_navigation, tokenResult, _tokenOptions?.Scopes); + } + } + + // We don't try to handle 401s and retry the request with a new token automatically since that would mean we need to copy the request + // headers and buffer the body and we expect that the user instead handles the 401s. (Also, we can't really handle all 401s as we might + // not be able to provision a token without user interaction). + request.Headers.Authorization = _cachedHeader; + } + + return await base.SendAsync(request, cancellationToken); + } + + /// + /// Configures this handler to authorize outbound HTTP requests using an access token. The access token is only attached if at least one of + /// is a base of . + /// + /// The base addresses of endpoint URLs to which the token will be attached. + /// The list of scopes to use when requesting an access token. + /// The return URL to use in case there is an issue provisioning the token and a redirection to the + /// identity provider is necessary. + /// + /// This . + public AuthorizationMessageHandler ConfigureHandler( + IEnumerable authorizedUrls, + IEnumerable? scopes = null, + [StringSyntax(StringSyntaxAttribute.Uri)] string? returnUrl = null) + { + if (_authorizedUris != null) + { + throw new InvalidOperationException("Handler already configured."); + } + + ArgumentNullException.ThrowIfNull(authorizedUrls); + + var uris = authorizedUrls.Select(uri => new Uri(uri, UriKind.Absolute)).ToArray(); + if (uris.Length == 0) + { + throw new ArgumentException("At least one URL must be configured.", nameof(authorizedUrls)); + } + + _authorizedUris = uris; + var scopesList = scopes?.ToArray(); + if (scopesList != null || returnUrl != null) + { + _tokenOptions = new AccessTokenRequestOptions + { + Scopes = scopesList, + ReturnUrl = returnUrl + }; + } + + return this; + } + + void IDisposable.Dispose() + { + if (_provider is AuthenticationStateProvider authStateProvider) + { + authStateProvider.AuthenticationStateChanged -= _authenticationStateChangedHandler; + } + Dispose(disposing: true); + } +} + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/provenance.json b/eng/skill-evals/review-pull-request/fixtures/case-01/provenance.json new file mode 100644 index 000000000000..42bd70409f97 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-01/provenance.json @@ -0,0 +1,103 @@ +{ + "repository": "dotnet/aspnetcore", + "pullRequest": 70106, + "sourceRoles": { + "mergeBase": "10bc886bfa321718276619d1077cc14eaf48456f", + "head": "2edf3761692afe15475075eb2fc0088566162045", + "baseTip": "05cf391d127a8267a4cc3a65eb76e3c3f8ef68d2" + }, + "files": [ + { + "file": "mergeBase.source", + "sha256": "07eb9db9eb2b00e052b7f9257e425952ae7a80356dfc0345218d12dc5d9b39a4", + "sources": [ + { + "role": "mergeBase", + "commit": "10bc886bfa321718276619d1077cc14eaf48456f", + "path": "src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs", + "blob": "ea7057399eaa038417ac823f641ced83a2d8b4e4", + "ranges": [ + [ + 1, + 135 + ] + ] + } + ] + }, + { + "file": "head.source", + "sha256": "8645348ad0f81cd9dfaf2ad46b77c2addd51f99dc7cb309222e53ed1c35e37b7", + "sources": [ + { + "role": "head", + "commit": "2edf3761692afe15475075eb2fc0088566162045", + "path": "src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs", + "blob": "6e0874be24b21f552d8282af628b5b0e6b1faa09", + "ranges": [ + [ + 1, + 148 + ] + ] + } + ] + }, + { + "file": "baseTip.source", + "sha256": "d54612b8db5a94ae8606f444dde3312af9963756aecf21f6566448924ada5e84", + "sources": [ + { + "role": "baseTip", + "commit": "05cf391d127a8267a4cc3a65eb76e3c3f8ef68d2", + "path": "src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs", + "blob": "ea7057399eaa038417ac823f641ced83a2d8b4e4", + "ranges": [ + [ + 1, + 135 + ] + ] + } + ] + }, + { + "file": "context.source", + "sha256": "b9afa9a838c193fdc8eb5cdfaf7bd72a574c284c61cf00fa518cdb863c375c71", + "sources": [ + { + "role": "head", + "commit": "2edf3761692afe15475075eb2fc0088566162045", + "path": "src/Components/WebAssembly/WebAssembly.Authentication/test/AuthorizationMessageHandlerTests.cs", + "blob": "b4930efc93e180d06070080a82cf8a49d2ea1a63", + "ranges": [ + [ + 199, + 226 + ], + [ + 228, + 230 + ], + [ + 234, + 248 + ], + [ + 251, + 262 + ] + ] + } + ] + }, + { + "file": "change.diff", + "sha256": "60bc415e7be22ef4cb9c899f61bd30b061a14f51767e2a34ff45ffb7d95a26c6" + }, + { + "file": "case.source", + "sha256": "af4d0c5cd703a12a23d42804c7b79493c9e2edbc651aea6261be4cc2818678cc" + } + ] +} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/baseTip.source b/eng/skill-evals/review-pull-request/fixtures/case-02/baseTip.source new file mode 100644 index 000000000000..f821ae268207 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-02/baseTip.source @@ -0,0 +1,1538 @@ +=== baseTip 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs:1-86 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +#if COMPONENTS +using Microsoft.AspNetCore.Components.Forms; +#endif +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping; + +internal sealed class FileConverter : FormDataConverter +{ + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + internal override bool TryRead(ref FormDataReader reader, Type type, FormDataMapperOptions options, out T? result, out bool found) + { + if (reader.FormFileCollection == null) + { + result = default; + found = false; + return true; + } + +#if COMPONENTS + if (typeof(T) == typeof(IBrowserFile)) + { + var targetFile = reader.FormFileCollection.GetFile(reader.CurrentPrefix.ToString()); + if (targetFile != null) + { + var browserFile = new BrowserFileFromFormFile(targetFile); + result = (T)(IBrowserFile)browserFile; + found = true; + return true; + } + } + + if (typeof(T) == typeof(IReadOnlyList)) + { + var targetFiles = reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); + var buffer = ReadOnlyCollectionBufferAdapter.CreateBuffer(); + for (var i = 0; i < targetFiles.Count; i++) + { + buffer = ReadOnlyCollectionBufferAdapter.Add(ref buffer, new BrowserFileFromFormFile(targetFiles[i])); + } + result = (T)(IReadOnlyList)ReadOnlyCollectionBufferAdapter.ToResult(buffer); + found = true; + return true; + } +#endif + + if (typeof(T) == typeof(IReadOnlyList)) + { + result = (T)reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); + found = true; + return true; + } + + if (typeof(T) == typeof(IFormFileCollection)) + { + result = (T)reader.FormFileCollection; + found = true; + return true; + } + + var formFileCollection = reader.FormFileCollection; + if (formFileCollection.Count == 0) + { + result = default; + found = false; + return true; + } + + var file = formFileCollection.GetFile(reader.CurrentPrefix.ToString()); + if (file != null) + { + result = (T)file; + found = true; + return true; + } + + result = default; + found = false; + return true; + } +} + +=== baseTip 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/Factories/ComplexType/ComplexTypeExpressionConverterFactoryOfT.cs:1-621 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Linq.Expressions; +using System.Runtime.CompilerServices; +using Microsoft.AspNetCore.Components.Endpoints.FormMapping.Metadata; + +namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping; + +internal sealed class ComplexTypeExpressionConverterFactory(FormDataMetadataFactory factory) : ComplexTypeExpressionConverterFactory +{ + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + internal override CompiledComplexTypeConverter CreateConverter(Type type, FormDataMapperOptions options) + { + var body = CreateConverterBody(type, options); + return new CompiledComplexTypeConverter(body); + } + + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + private CompiledComplexTypeConverter.ConverterDelegate CreateConverterBody(Type type, FormDataMapperOptions options) + { + var metadata = factory.GetOrCreateMetadataFor(type, options) ?? + throw new InvalidOperationException($"Could not resolve metadata for type '{type.FullName}'."); + + var properties = metadata.Properties; + var constructorParameters = metadata.ConstructorParameters; + + var (readerParam, typeParam, optionsParam, resultParam, foundValueParam) = CreateFormDataConverterParameters(); + var parameters = new List() { readerParam, typeParam, optionsParam, resultParam, foundValueParam }; + + // Variables + var propertyFoundValue = Expression.Variable(typeof(bool), "foundValueForProperty"); + var succeeded = Expression.Variable(typeof(bool), "succeeded"); + var localFoundValueVar = Expression.Variable(typeof(bool), "localFoundValue"); + var exceptionVar = Expression.Variable(typeof(Exception), "mappingException"); + var variables = new List() { propertyFoundValue, succeeded, localFoundValueVar, exceptionVar }; + + var propertyValueLocals = new List(); + var constructorParameterValueLocals = new List(); + + var body = new List() + { + Expression.Assign(succeeded, Expression.Constant(true)), + }; + + var end = Expression.Label("done"); + + if (metadata.IsRecursive) + { + body.Add(CreatePrefixCheckForRecursiveTypes(readerParam, foundValueParam, succeeded, end)); + } + + MapConstructorParameters( + constructorParameters, + readerParam, + optionsParam, + propertyFoundValue, + succeeded, + localFoundValueVar, + exceptionVar, + variables, + constructorParameterValueLocals, + body); + + MapPropertyValues( + properties, + readerParam, + optionsParam, + propertyFoundValue, + succeeded, + localFoundValueVar, + exceptionVar, + variables, + propertyValueLocals, + body); + + body.Add(Expression.IfThen( + localFoundValueVar, + Expression.Block(CreateInstanceAndAssignProperties( + metadata, + resultParam, + constructorParameters, + constructorParameterValueLocals, + properties, + propertyValueLocals, + variables, + succeeded, + readerParam)))); + + // foundValue && !failures; + body.Add(Expression.Assign(foundValueParam, localFoundValueVar)); + body.Add(Expression.Label(end)); + body.Add(succeeded); + + variables.AddRange(constructorParameterValueLocals); + variables.AddRange(propertyValueLocals); + + return CreateConverterFunction(parameters, variables, body); + + } + + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + private static IEnumerable CreateInstanceAndAssignProperties( + FormDataTypeMetadata model, + ParameterExpression resultParam, + IList constructorParameters, + List constructorParameterValueLocals, + IList props, + List propsLocals, + List variables, + ParameterExpression succeeded, + ParameterExpression context) + { + if (model.Constructor == null && !model.Type.IsValueType) + { + throw new InvalidOperationException($"Type '{model.Type}' does not have a constructor. " + + $"A single public constructor is required for mapping the type."); + } + + // If we got here it means that we found some values for the type. + // We need to check the required properties/constructor parameters to see if we have values for them. + // If we don't, we need to add a mapping error and set succeeded to false. + var checks = ReportMissingValues(context, constructorParameterValueLocals, constructorParameters, propsLocals, props, succeeded); + foreach (var missingValueCheck in checks) + { + yield return missingValueCheck; + } + + if (model.Constructor != null) + { + // try + // { + // result = new T(...); + // } + // catch(Exception ex) + // { + // reader.AddMappingError(ex.Message); + // succeeded = false; + // } + var exception = Expression.Variable(typeof(Exception), "constructorException"); + variables.Add(exception); + yield return Expression.TryCatch( + Expression.Assign( + resultParam, + Expression.New( + model.Constructor, + constructorParameterValueLocals.Select(GetValueLocalVariableValueExpression))), + Expression.Catch( + exception, + Expression.Block( + Expression.Call( + context, + nameof(FormDataReader.AddMappingError), + Array.Empty(), + exception, + Expression.Constant(null, typeof(string))), + Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))), + resultParam))); + } + + // if(!succeeded && context.AttachInstanceToErrorsHandler != null && result != null) + // { + // context.AttachInstanceToErrors((object)result); + // } + + var failedAndHasHandler = Expression.And(Expression.Not(succeeded), HasHandler(context)); + + var clause = model.Type.IsValueType ? failedAndHasHandler : + Expression.And( + failedAndHasHandler, + Expression.NotEqual( + resultParam, + Expression.Constant(null, resultParam.Type))); + + yield return Expression.IfThen( + clause, + Expression.Call( + context, + nameof(FormDataReader.AttachInstanceToErrors), + Array.Empty(), + Expression.Convert(resultParam, typeof(object)))); + + if (!model.Type.IsValueType) + { + var assignments = new List(); + for (var i = 0; i < props.Count; i++) + { + assignments.Add(Expression.Assign(Expression.Property(resultParam, props[i].Property), GetValueLocalVariableValueExpression(propsLocals[i]))); + } + + // if(result != null) + // { + // result.Property1 = property1; + // result.Property2 = property2; + // ... + // } + yield return Expression.IfThen( + Expression.NotEqual(resultParam, Expression.Constant(null, resultParam.Type)), + Expression.Block(assignments)); + } + else + { + for (var i = 0; i < props.Count; i++) + { + yield return Expression.Assign(Expression.Property(resultParam, props[i].Property), GetValueLocalVariableValueExpression(propsLocals[i])); + } + } + + static BinaryExpression HasHandler(ParameterExpression context) + { + return Expression.NotEqual( + Expression.Property(context, nameof(FormDataReader.AttachInstanceToErrorsHandler)), + Expression.Constant(null, typeof(Action))); + } + } + + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + private static IEnumerable ReportMissingValues( + Expression readerParam, + List constructorParameters, + IList constructorParameterMetadata, + List properties, + IList propertyMetadata, + ParameterExpression succeeded) + { + for (var i = 0; i < constructorParameters.Count; i++) + { + var parameter = constructorParameters[i]; + var metadata = constructorParameterMetadata[i]; + if (metadata.Required) + { + // if(!property.Item1) + // { + // reader.PushPrefix(metadata.Name); + // reader.AddMappingError( + // FommattableStringFactory.Create( + // "Missing required value for constructor property '{0}'.", + // metadata.Name)); + // reader.PopPrefix(metadata.Name); + // } + yield return Expression.IfThen( + Expression.Not(GetValueLocalVariableFoundExpression(parameter)), + Expression.Block( + PushPrefix(readerParam, metadata.Name), + AddMappingError(readerParam, "Missing required value for constructor parameter '{0}'.", metadata.Name), + PopPrefix(readerParam, metadata.Name), + Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))))); + } + } + + for (var i = 0; i < properties.Count; i++) + { + var property = properties[i]; + var metadata = propertyMetadata[i]; + if (metadata.Required) + { + // if(!property.Item1) + // { + // reader.PushPrefix(metadata.Name); + // reader.AddMappingError( + // FommattableStringFactory.Create( + // "Missing required value for constructor property '{0}'.", + // metadata.Name)); + // reader.PopPrefix(metadata.Name); + // } + yield return Expression.IfThen( + Expression.Not(GetValueLocalVariableFoundExpression(property)), + Expression.Block( + PushPrefix(readerParam, metadata.Name), + AddMappingError(readerParam, "Missing required value for property '{0}'.", metadata.Name), + PopPrefix(readerParam, metadata.Name), + Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))))); + } + } + + static MethodCallExpression PushPrefix(Expression readerParam, string prefix) + { + return Expression.Call( + readerParam, + nameof(FormDataReader.PushPrefix), + Array.Empty(), + Expression.Constant(prefix)); + } + + static MethodCallExpression AddMappingError(Expression readerParam, string message, string parameter) + { + // FormattableStringFactory.Create(message) + var formattableString = Expression.Call( + typeof(FormattableStringFactory), + nameof(FormattableStringFactory.Create), + Array.Empty(), + Expression.Constant(message), + Expression.NewArrayInit(typeof(object), Expression.Constant(parameter))); + + return Expression.Call( + readerParam, + nameof(FormDataReader.AddMappingError), + Array.Empty(), + formattableString, + Expression.Constant(null, typeof(string))); + } + + static MethodCallExpression PopPrefix(Expression readerParam, string prefix) + { + return Expression.Call( + readerParam, + nameof(FormDataReader.PopPrefix), + Array.Empty(), + Expression.Constant(prefix)); + } + } + + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + private static void MapPropertyValues( + IList properties, + ParameterExpression readerParam, + ParameterExpression optionsParam, + ParameterExpression propertyFoundValue, + ParameterExpression succeeded, + ParameterExpression localFoundValueVar, + ParameterExpression exceptionVar, + List variables, + List propertyValueLocals, + List body) + { + // Create the property blocks + // var propertyConverter = options.ResolveConverter(typeof(string)); + // reader.PushPrefix("PropertyInfo"); + // succeeded &= propertyConverter.TryRead(ref reader, typeof(string), options, out propertyVar, out foundProperty); + // found ||= foundProperty; + // reader.PopPrefix("PropertyInfo"); + for (var i = 0; i < properties.Count; i++) + { + // Declare variable for the converter + var property = properties[i]; + var propertyConverterType = typeof(FormDataConverter<>).MakeGenericType(property.Type); + var propertyConverterVar = Expression.Variable(propertyConverterType, $"{property.Name}Converter"); + variables.Add(propertyConverterVar); + + // Declare variable for property value. + var propertyVar = CreateValueLocalVariable(property); + propertyValueLocals.Add(propertyVar); + + // Resolve and assign converter + // Create the block to try and map the property and update propsLocals. + // returnParam &= { PushPrefix(property.Name); var res = TryRead(...); PopPrefix(...); return res; } + // var propertyConverter = options.ResolveConverter()); + var propertyConverter = Expression.Assign( + propertyConverterVar, + Expression.Call( + optionsParam, + nameof(FormDataMapperOptions.ResolveConverter), + new[] { property.Type }, + Array.Empty())); + body.Add(propertyConverter); + + body.Add(Expression.TryCatchFinally( + // try + // { + // reader.PushPrefix("PropertyInfo"); + // succeeded &= propertyConverter.TryRead(ref reader, typeof(string), options, out propertyVar, out foundProperty); + // } + // finally + // { + // reader.PopPrefix("PropertyInfo"); + // } + body: Expression.Block( + // reader.PushPrefix("PropertyInfo"); + Expression.Call( + readerParam, + nameof(FormDataReader.PushPrefix), + Array.Empty(), + Expression.Constant(property.Name)), + + // succeeded &= propertyConverter.TryRead(ref reader, typeof(string), options, out propertyVar, out foundProperty); + Expression.AndAssign( + succeeded, + Expression.Call( + propertyConverterVar, + nameof(FormDataConverter.TryRead), + Type.EmptyTypes, + readerParam, + Expression.Constant(property.Type), + optionsParam, + GetValueLocalVariableValueExpression(propertyVar), + propertyFoundValue))), + // reader.PopPrefix("PropertyInfo"); + @finally: Expression.Call( + readerParam, + nameof(FormDataReader.PopPrefix), + Array.Empty(), + Expression.Constant(property.Name)), + handlers: Expression.Catch( + exceptionVar, + Expression.Block( + Expression.Call( + readerParam, + nameof(FormDataReader.AddMappingError), + Array.Empty(), + exceptionVar, + Expression.Constant(null, typeof(string))), + Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))) + )))); + + // parameter.found = foundProperty; + body.Add(Expression.Assign(GetValueLocalVariableFoundExpression(propertyVar), propertyFoundValue)); + body.Add(Expression.OrAssign(localFoundValueVar, propertyFoundValue)); + } + } + + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + private static void MapConstructorParameters( + IList constructorParameters, + ParameterExpression readerParam, + ParameterExpression optionsParam, + ParameterExpression propertyFoundValue, + ParameterExpression succeeded, + ParameterExpression localFoundValueVar, + ParameterExpression exceptionVar, + List variables, + List constructorParameterValueLocals, + List body) + { + // Create the constructor property blocks + + // var parameterConverter = options.ResolveConverter(typeof(string)); + // reader.PushPrefix("PropertyInfo"); + // succeeded &= parameterConverter.TryRead(ref reader, typeof(string), options, out constructorParameterVar, out foundProperty); + // found ||= foundProperty; + // reader.PopPrefix("PropertyInfo"); + for (var i = 0; i < constructorParameters.Count; i++) + { + // Declare variable for the converter + var constructorParameter = constructorParameters[i]; + var constructorParameterConverterType = typeof(FormDataConverter<>).MakeGenericType(constructorParameter.Type); + var constructorParameterConverterVar = Expression.Variable(constructorParameterConverterType, $"{constructorParameter.Name}Converter"); + variables.Add(constructorParameterConverterVar); + + // Declare variable for constructorParameter value. + var constructorParameterVar = CreateValueLocalVariable(constructorParameter); + constructorParameterValueLocals.Add(constructorParameterVar); + + // Resolve and assign converter + // Create the block to try and map the constructorParameter and update propsLocals. + // returnParam &= { PushPrefix(constructorParameter.Name); var res = TryRead(...); PopPrefix(...); return res; } + // var constructorParameterConverter = options.ResolveConverter()); + var constructorParameterConverter = Expression.Assign( + constructorParameterConverterVar, + Expression.Call( + optionsParam, + nameof(FormDataMapperOptions.ResolveConverter), + new[] { constructorParameter.Type }, + Array.Empty())); + body.Add(constructorParameterConverter); + + // try + // { + // reader.PushPrefix("PropertyInfo"); + // succeeded &= constructorParameterConverter.TryRead(ref reader, typeof(string), options, out constructorParameterVar, out foundProperty); + // if(!succeeded || !found) + // { + // reader.AddMappingError("Missing required value for constructor property {0}", constructorParameter.Name); + // } + // } + // finally + // { + // reader.PopPrefix("PropertyInfo"); + // } + body.Add(Expression.TryCatchFinally( + body: Expression.Block( + // reader.PushPrefix("PropertyInfo"); + Expression.Call( + readerParam, + nameof(FormDataReader.PushPrefix), + Array.Empty(), + Expression.Constant(constructorParameter.Name)), + // succeeded &= constructorParameterConverter.TryRead(ref reader, typeof(string), options, out constructorParameterVar, out foundProperty); + Expression.AndAssign( + succeeded, + Expression.Call( + constructorParameterConverterVar, + nameof(FormDataConverter.TryRead), + Type.EmptyTypes, + readerParam, + Expression.Constant(constructorParameter.Type), + optionsParam, + GetValueLocalVariableValueExpression(constructorParameterVar), + propertyFoundValue))), + // reader.PopPrefix("PropertyInfo"); + @finally: Expression.Call( + readerParam, + nameof(FormDataReader.PopPrefix), + Array.Empty(), + Expression.Constant(constructorParameter.Name)), + handlers: Expression.Catch( + exceptionVar, + Expression.Block( + Expression.Call( + readerParam, + nameof(FormDataReader.AddMappingError), + Array.Empty(), + exceptionVar, + Expression.Constant(null, typeof(string))), + Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))) + )))); + + // parameter.found = foundProperty; + body.Add(Expression.Assign(GetValueLocalVariableFoundExpression(constructorParameterVar), propertyFoundValue)); + body.Add(Expression.OrAssign(localFoundValueVar, propertyFoundValue)); + } + } + + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + private static Expression GetValueLocalVariableFoundExpression(ParameterExpression constructorParameterVar) + { + return Expression.PropertyOrField(constructorParameterVar, nameof(ValueTuple.Item1)); + } + + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + private static Expression GetValueLocalVariableValueExpression(ParameterExpression constructorParameterVar) => + Expression.PropertyOrField(constructorParameterVar, nameof(ValueTuple.Item2)); + + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + private static ParameterExpression CreateValueLocalVariable(IFormDataValue constructorParameter) + { + return Expression.Variable(typeof(ValueTuple<,>).MakeGenericType(typeof(bool), constructorParameter.Type), constructorParameter.Name); + } + + // For recursive types we need to do a prefix check. + // if(!reader.CurrentPrefixExists()) + // { + // found = false; + // return true; + // } + // + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + private static ConditionalExpression CreatePrefixCheckForRecursiveTypes(ParameterExpression readerParam, ParameterExpression foundValueParam, ParameterExpression succeeded, LabelTarget end) + { + return Expression.IfThen( + Expression.Not(Expression.Call(readerParam, nameof(FormDataReader.CurrentPrefixExists), Array.Empty())), + Expression.Block( + Expression.Assign(foundValueParam, Expression.Constant(false)), + Expression.Assign(succeeded, Expression.Constant(true)), + Expression.Goto(end))); + } + + private static CompiledComplexTypeConverter.ConverterDelegate CreateConverterFunction( + List parameters, + List variables, + List body) + { + var lambda = Expression.Lambda.ConverterDelegate>( + Expression.Block(variables, body), + parameters); + + return lambda.Compile(); + } + + private static FormDataConverterReadParameters CreateFormDataConverterParameters() + { + return new( + Expression.Parameter(typeof(FormDataReader).MakeByRefType(), "reader"), + Expression.Parameter(typeof(Type), "type"), + Expression.Parameter(typeof(FormDataMapperOptions), "options"), + Expression.Parameter(typeof(T).MakeByRefType(), "result"), + Expression.Parameter(typeof(bool).MakeByRefType(), "foundValue")); + } + + private readonly struct FormDataConverterReadParameters + { + public ParameterExpression ReaderParam { get; } + + public ParameterExpression TypeParam { get; } + + public ParameterExpression OptionsParam { get; } + + public ParameterExpression ResultParam { get; } + + public ParameterExpression FoundValueParam { get; } + + public FormDataConverterReadParameters( + ParameterExpression readerParam, + ParameterExpression typeParam, + ParameterExpression optionsParam, + ParameterExpression resultParam, + ParameterExpression foundValueParam) + { + ReaderParam = readerParam; + TypeParam = typeParam; + OptionsParam = optionsParam; + ResultParam = resultParam; + FoundValueParam = foundValueParam; + } + + public void Deconstruct( + out ParameterExpression readerParam, + out ParameterExpression typeParam, + out ParameterExpression optionsParam, + out ParameterExpression resultParam, + out ParameterExpression foundValueParam) + { + readerParam = ReaderParam; + typeParam = TypeParam; + optionsParam = OptionsParam; + resultParam = ResultParam; + foundValueParam = FoundValueParam; + } + } +} + +=== baseTip 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/Metadata/FormDataMetadataFactory.cs:1-428 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.Serialization; +using Microsoft.Extensions.Internal; +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping.Metadata; + +internal partial class FormDataMetadataFactory(List factories, ILoggerFactory loggerFactory) +{ + private readonly object _lock = new object(); + private readonly FormMetadataContext _context = new(); + private readonly ParsableConverterFactory _parsableFactory = factories.OfType().Single(); + private readonly DictionaryConverterFactory _dictionaryFactory = factories.OfType().Single(); + private readonly FileConverterFactory _fileConverterFactory = factories.OfType().Single(); + private readonly CollectionConverterFactory _collectionFactory = factories.OfType().Single(); + private readonly ILogger _logger = loggerFactory.CreateLogger(); + + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + public FormDataTypeMetadata? GetOrCreateMetadataFor(Type type, FormDataMapperOptions options) + { + var shouldClearContext = !_context.ResolutionInProgress; + lock (_lock) + { + try + { + // We are walking the graph in order to detect recursive types. + // We evaluate whether a type is: + // 1. Primitive + // 2. Dictionary + // 3. Collection + // 4. Complex + // Only complex types can be recursive. + // We only compute metadata when we are dealing with objects, other classes of + // types are handled directly by the appropriate converters. + // We keep track of the metadata for the types because it is useful when we generate + // the specific object converter for a type. + // The code generation varies depending on whether there is recursion or not within + // the type graph. + if (shouldClearContext) + { + Log.StartResolveMetadataGraph(_logger, type); + _context.BeginResolveGraph(); + } + + // Try to get the metadata for the type or create and add a new instance. + var result = _context.TypeMetadata.TryGetValue(type, out var value) ? value : new FormDataTypeMetadata(type); + if (value == null) + { + Log.NoMetadataFound(_logger, type); + _context.TypeMetadata[type] = result; + } + else + { + Log.MetadataFound(_logger, type); + } + + if (type.IsGenericTypeDefinition) + { + Log.GenericTypeDefinitionNotSupported(_logger, type); + _context.TypeMetadata.Remove(type); + return null; + } + + // Check for cycles and mark any type as recursive if needed. + DetectCyclesAndMarkMetadataTypesAsRecursive(type, result); + + // We found the value on the existing metadata, we can return it. + if (value != null) + { + return result; + } + + // These blocks are evaluated in a specific order. + if (_parsableFactory.CanConvert(type, options) || type.IsEnum || + (Nullable.GetUnderlyingType(type) is { } underlyingType && + _parsableFactory.CanConvert(underlyingType, options))) + { + Log.PrimitiveType(_logger, type); + result.Kind = FormDataTypeKind.Primitive; + return result; + } + + if (_fileConverterFactory.CanConvert(type, options)) + { + result.Kind = FormDataTypeKind.File; + return result; + } + + if (WellKnownConverters.Converters.TryGetValue(type, out var converter)) + { + result.Kind = FormDataTypeKind.Primitive; + return result; + } + + if (_dictionaryFactory.CanConvert(type, options)) + { + Log.DictionaryType(_logger, type); + result.Kind = FormDataTypeKind.Dictionary; + var (keyType, valueType) = DictionaryConverterFactory.ResolveDictionaryTypes(type)!; + result.KeyType = GetOrCreateMetadataFor(keyType, options); + result.ValueType = GetOrCreateMetadataFor(valueType, options); + return result; + } + + if (_collectionFactory.CanConvert(type, options)) + { + Log.CollectionType(_logger, type); + result.Kind = FormDataTypeKind.Collection; + result.ElementType = GetOrCreateMetadataFor(CollectionConverterFactory.ResolveElementType(type)!, options); + return result; + } + + Log.ObjectType(_logger, type); + result.Kind = FormDataTypeKind.Object; + _context.Track(type); + var constructors = type.GetConstructors(); + + if (constructors.Length == 1) + { + result.Constructor = constructors[0]; + if (type.IsAbstract) + { + Log.AbstractClassesNotSupported(_logger, type); + _context.TypeMetadata.Remove(type); + return null; + } + } + else if (constructors.Length > 1) + { + // We can't select the constructor when there are multiple of them. + Log.MultiplePublicConstructorsFound(_logger, type); + return null; + } + else if (!type.IsValueType) + { + if (type.IsInterface) + { + Log.InterfacesNotSupported(_logger, type); + } + else if (type.IsAbstract) + { + Log.AbstractClassesNotSupported(_logger, type); + } + else + { + Log.NoPublicConstructorFound(_logger, type); + } + + _context.TypeMetadata.Remove(type); + // We can't bind to reference types without constructors. + return null; + } + + if (result.Constructor != null) + { + if (_logger.IsEnabled(LogLevel.Debug)) + { + var parameters = $"({string.Join(", ", result.Constructor.GetParameters().Select(p => p.ParameterType.Name))})"; + Log.ConstructorFound(_logger, type, parameters); + } + + var values = result.Constructor.GetParameters(); + + foreach (var parameter in values) + { + Log.ConstructorParameter(_logger, type, parameter.Name!, parameter.ParameterType); + var parameterTypeInfo = GetOrCreateMetadataFor(parameter.ParameterType, options); + if (parameterTypeInfo == null) + { + Log.ConstructorParameterTypeNotSupported(_logger, type, parameter.Name!, parameter.ParameterType); + _context.TypeMetadata.Remove(type); + return null; + } + + result.ConstructorParameters.Add(new FormDataParameterMetadata(parameter, parameterTypeInfo)); + } + } + + var candidateProperty = PropertyHelper.GetVisibleProperties(type); + foreach (var propertyHelper in candidateProperty) + { + var property = propertyHelper.Property; + Log.CandidateProperty(_logger, propertyHelper.Name, property.PropertyType); + var matchingConstructorParameter = result + .ConstructorParameters + .FirstOrDefault(p => string.Equals(p.Name, property.Name, StringComparison.OrdinalIgnoreCase)); + + if (matchingConstructorParameter != null) + { + Log.MatchingConstructorParameterFound(_logger, matchingConstructorParameter.Name, property.Name); + var dataMember = property.GetCustomAttribute(); + if (dataMember != null && dataMember.IsNameSetExplicitly && dataMember.Name != null) + { + Log.CustomParameterNameMetadata(_logger, dataMember.Name, property.Name); + matchingConstructorParameter.Name = dataMember.Name; + } + + // The propertyHelper is already present in the constructor, we don't need to add it again. + continue; + } + + var ignoreDataMember = property.GetCustomAttribute(); + if (ignoreDataMember != null) + { + Log.IgnoredProperty(_logger, property.Name); + // The propertyHelper is marked as ignored, we don't need to add it. + continue; + } + + if (property.SetMethod == null || !property.SetMethod.IsPublic) + { + Log.NonPublicSetter(_logger, property.Name); + // The property is readonly, we don't need to add it. + continue; + } + + var propertyTypeInfo = GetOrCreateMetadataFor(property.PropertyType, options); + if (propertyTypeInfo == null) + { + Log.PropertyTypeNotSupported(_logger, type, property.Name, property.PropertyType); + _context.TypeMetadata.Remove(type); + return null; + } + var propertyInfo = new FormDataPropertyMetadata(property, propertyTypeInfo); + + var dataMemberAttribute = property.GetCustomAttribute(); + if (dataMemberAttribute != null && dataMemberAttribute.IsNameSetExplicitly && dataMemberAttribute.Name != null) + { + Log.CustomParameterNameMetadata(_logger, dataMemberAttribute.Name, property.Name); + propertyInfo.Name = dataMemberAttribute.Name; + propertyInfo.Required = dataMemberAttribute.IsRequired; + Log.PropertyRequired(_logger, propertyInfo.Name); + } + + var requiredAttribute = property.GetCustomAttribute(); + if (requiredAttribute != null) + { + propertyInfo.Required = true; + Log.PropertyRequired(_logger, propertyInfo.Name); + } + + result.Properties.Add(propertyInfo); + } + + Log.MetadataComputed(_logger, type); + return result; + } + finally + { + _context.Untrack(type); + if (shouldClearContext) + { + Log.EndResolveMetadataGraph(_logger, type); + _context.EndResolveGraph(); + } + } + } + } + + internal bool HasMetadataFor(Type type) => _context.TypeMetadata.ContainsKey(type); + + private void DetectCyclesAndMarkMetadataTypesAsRecursive(Type type, FormDataTypeMetadata result) + { + // Mark any type as recursive if its already present in the current resolution graph or + // if there is a base type for it on the resolution graph. + // For example, given A and B : A. With A having a propertyHelper of type B. + // when we inspect B, we can tell that A is recursive because you can have A -> B -> B -> B -> ... + // The opposite scenario is not something we need to worry about because we don't support polymorphism, + // meaning that we will never create an instance of B if the declared type is A. + // In that scenario, A and B : A. With B having a propertyHelper of type A. + // The recursion stops at A, because A doesn't define the propertyHelper and we will never bind B to A. + // If in the future we support polymorphism, it's a matter or updating the logic below to account for it. + for (var i = 0; i < _context.CurrentTypes.Count; i++) + { + if (_context.CurrentTypes[i] == type) + { + // We found an exact match in the current resolution graph. + // This means that the type is recursive. + result.IsRecursive = true; + ReportRecursiveChain(type); + + } + else if (type.IsSubclassOf(_context.CurrentTypes[i])) + { + // We found a type that is assignable from the current type. + // This means that the type is recursive. + var existingType = _context.TypeMetadata[_context.CurrentTypes[i]]; + ReportRecursiveChain(type); + existingType.IsRecursive = true; + } + + // We don't need to check for interfaces here because we never map to an interface, so if we encounter one, we will fail, + // as we can't construct the converter to map the interface to a concrete instance. + } + + void ReportRecursiveChain(Type type) + { + if (_logger.IsEnabled(LogLevel.Debug)) + { + var chain = string.Join(" -> ", _context.CurrentTypes.Append(type).Select(t => t.Name)); + Log.RecursiveTypeFound(_logger, type, chain); + } + } + } + + private class FormMetadataContext + { + public Dictionary TypeMetadata { get; set; } = new(); + + public List CurrentTypes { get; set; } = new(); + + public bool ResolutionInProgress { get; internal set; } + + internal void BeginResolveGraph() + { + if (ResolutionInProgress) + { + throw new InvalidOperationException("Cannot begin a new resolution graph while one is already in progress."); + } + ResolutionInProgress = true; + } + + internal void EndResolveGraph() + { + if (!ResolutionInProgress) + { + throw new InvalidOperationException("Cannot end a resolution graph while one is not in progress."); + } + ResolutionInProgress = false; + CurrentTypes.Clear(); + } + + internal void Track(Type type) + { + CurrentTypes.Add(type); + } + + internal void Untrack(Type type) + { + CurrentTypes.Remove(type); + } + } + + private static partial class Log + { + [LoggerMessage(1, LogLevel.Debug, "Begin resolve metadata graph for type '{Type}'.", EventName = nameof(StartResolveMetadataGraph))] + public static partial void StartResolveMetadataGraph(ILogger logger, Type type); + + [LoggerMessage(2, LogLevel.Debug, "End resolve metadata graph for type '{Type}'.", EventName = nameof(EndResolveMetadataGraph))] + public static partial void EndResolveMetadataGraph(ILogger logger, Type type); + + [LoggerMessage(3, LogLevel.Debug, "Cached metadata found for type '{Type}'.", EventName = nameof(Metadata))] + public static partial void MetadataFound(ILogger logger, Type type); + + [LoggerMessage(4, LogLevel.Debug, "No cached metadata graph for type '{Type}'.", EventName = nameof(NoMetadataFound))] + public static partial void NoMetadataFound(ILogger logger, Type type); + + [LoggerMessage(5, LogLevel.Debug, "Recursive type '{Type}' found in the resolution graph '{Chain}'.", EventName = nameof(RecursiveTypeFound))] + public static partial void RecursiveTypeFound(ILogger logger, Type type, string chain); + + [LoggerMessage(6, LogLevel.Debug, "'{Type}' identified as primitive.", EventName = nameof(PrimitiveType))] + public static partial void PrimitiveType(ILogger logger, Type type); + + [LoggerMessage(7, LogLevel.Debug, "'{Type}' identified as dictionary.", EventName = nameof(DictionaryType))] + public static partial void DictionaryType(ILogger logger, Type type); + + [LoggerMessage(8, LogLevel.Debug, "'{Type}' identified as collection.", EventName = nameof(CollectionType))] + public static partial void CollectionType(ILogger logger, Type type); + + [LoggerMessage(9, LogLevel.Debug, "'{Type}' identified as object.", EventName = nameof(ObjectType))] + public static partial void ObjectType(ILogger logger, Type type); + + [LoggerMessage(10, LogLevel.Debug, "Constructor found for type '{Type}' with parameters '{Parameters}'.", EventName = nameof(ConstructorFound))] + public static partial void ConstructorFound(ILogger logger, Type type, string parameters); + + [LoggerMessage(11, LogLevel.Debug, "Constructor parameter '{Name}' of type '{ParameterType}' found for type '{Type}'.", EventName = nameof(ConstructorParameter))] + public static partial void ConstructorParameter(ILogger logger, Type type, string name, Type parameterType); + + [LoggerMessage(12, LogLevel.Debug, "Candidate property '{Name}' of type '{PropertyType}'.", EventName = nameof(CandidateProperty))] + public static partial void CandidateProperty(ILogger logger, string name, Type propertyType); + + [LoggerMessage(13, LogLevel.Debug, "Candidate property {PropertyName} has a matching constructor parameter '{ConstructorParameterName}'.", EventName = nameof(MatchingConstructorParameterFound))] + public static partial void MatchingConstructorParameterFound(ILogger logger, string constructorParameterName, string propertyName); + + [LoggerMessage(14, LogLevel.Debug, "Candidate property or constructor parameter {PropertyName} defines a custom name '{CustomName}'.", EventName = nameof(CustomParameterNameMetadata))] + public static partial void CustomParameterNameMetadata(ILogger logger, string customName, string propertyName); + + [LoggerMessage(15, LogLevel.Debug, "Candidate property {Name} will not be mapped. It has been explicitly ignored.", EventName = nameof(IgnoredProperty))] + public static partial void IgnoredProperty(ILogger logger, string name); + + [LoggerMessage(16, LogLevel.Debug, "Candidate property {Name} will not be mapped. It has no public setter.", EventName = nameof(NonPublicSetter))] + public static partial void NonPublicSetter(ILogger logger, string name); + + [LoggerMessage(17, LogLevel.Debug, "Candidate property {Name} is marked as required.", EventName = nameof(PropertyRequired))] + public static partial void PropertyRequired(ILogger logger, string name); + + [LoggerMessage(18, LogLevel.Debug, "Metadata created for {Type}.", EventName = nameof(MetadataComputed))] + public static partial void MetadataComputed(ILogger logger, Type type); + + [LoggerMessage(19, LogLevel.Debug, "Can not map type generic type definition '{Type}'.", EventName = nameof(GenericTypeDefinitionNotSupported))] + public static partial void GenericTypeDefinitionNotSupported(ILogger logger, Type type); + + [LoggerMessage(20, LogLevel.Debug, "Unable to select a constructor. Multiple public constructors found for type '{Type}'.", EventName = nameof(MultiplePublicConstructorsFound))] + public static partial void MultiplePublicConstructorsFound(ILogger logger, Type type); + + [LoggerMessage(21, LogLevel.Debug, "Can not map interface type '{Type}'.", EventName = nameof(InterfacesNotSupported))] + public static partial void InterfacesNotSupported(ILogger logger, Type type); + + [LoggerMessage(22, LogLevel.Debug, "Can not map abstract type '{Type}'.", EventName = nameof(AbstractClassesNotSupported))] + public static partial void AbstractClassesNotSupported(ILogger logger, Type type); + + [LoggerMessage(23, LogLevel.Debug, "Unable to select a constructor. No public constructors found for type '{Type}'.", EventName = nameof(NoPublicConstructorFound))] + public static partial void NoPublicConstructorFound(ILogger logger, Type type); + + [LoggerMessage(24, LogLevel.Debug, "Can not map type '{Type}'. Constructor parameter {Name} of type {ParameterType} is not supported.", EventName = nameof(ConstructorParameterTypeNotSupported))] + public static partial void ConstructorParameterTypeNotSupported(ILogger logger, Type type, string name, Type parameterType); + + [LoggerMessage(25, LogLevel.Debug, "Can not map type '{Type}'. Property {Name} of type {PropertyType} is not supported.", EventName = nameof(PropertyTypeNotSupported))] + public static partial void PropertyTypeNotSupported(ILogger logger, Type type, string name, Type propertyType); + } +} + +=== baseTip 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/Metadata/FormDataParameterMetadata.cs:1-25 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Reflection; + +namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping.Metadata; +internal class FormDataParameterMetadata(ParameterInfo parameter, FormDataTypeMetadata parameterTypeInfo) : IFormDataValue +{ + public ParameterInfo Parameter { get; } = parameter; + public string Name { get; set; } = parameter.Name!; + public Type Type { get; set; } = parameter.ParameterType; + + public bool Required => true; + + internal FormDataTypeMetadata ParameterMetadata { get; } = parameterTypeInfo; +} + +internal interface IFormDataValue +{ + public string Name { get; } + + public Type Type { get; } + + public bool Required { get; } +} + +=== baseTip 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/FormDataReader.cs:1-318 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Runtime.CompilerServices; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.WebUtilities; +using Microsoft.Extensions.Primitives; + +namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping; + +[DebuggerDisplay($"{{{nameof(DebuggerDisplay)}(),nq}}")] +internal struct FormDataReader : IDisposable +{ + private readonly IReadOnlyDictionary _readOnlyMemoryKeys; + private readonly Memory _prefixBuffer; + private Memory _currentPrefixBuffer; + private int _currentDepth; + private int _errorCount; + + // As an implementation detail, reuse FormKey for the values. + // It's just a thin wrapper over ReadOnlyMemory that caches + // the computed hash code. + + private PrefixResolver _prefixResolver; + + public FormDataReader(IReadOnlyDictionary formCollection, CultureInfo culture, Memory buffer) + { + _readOnlyMemoryKeys = formCollection; + Culture = culture; + _prefixBuffer = buffer; + } + + public FormDataReader(IReadOnlyDictionary formCollection, CultureInfo culture, Memory buffer, IFormFileCollection formFileCollection) + : this(formCollection, culture, buffer) + { + FormFileCollection = formFileCollection; + } + + internal ReadOnlyMemory CurrentPrefix => _currentPrefixBuffer; + + public IFormatProvider Culture { get; } + + public IFormFileCollection? FormFileCollection { get; internal set; } + + public int MaxRecursionDepth { get; set; } = 64; + + public int MaxCollectionSize { get; set; } = FormReader.DefaultValueCountLimit; + + public Action? ErrorHandler { get; set; } + + public Action? AttachInstanceToErrorsHandler { get; set; } + + public int MaxErrorCount { get; set; } = 200; + + public void AddMappingError(FormattableString errorMessage, string? attemptedValue) + { + ArgumentNullException.ThrowIfNull(errorMessage); + + if (ErrorHandler == null) + { + throw new FormDataMappingException(new FormDataMappingError(_currentPrefixBuffer.ToString(), errorMessage, attemptedValue)); + } + + _errorCount++; + if (_errorCount == MaxErrorCount) + { + ErrorHandler.Invoke( + _currentPrefixBuffer.ToString(), + FormattableStringFactory.Create($"Maximum number of errors ({MaxErrorCount}) reached. Further errors will be suppressed."), + null); + } + + if (_errorCount >= MaxErrorCount) + { + return; + } + + ErrorHandler.Invoke(_currentPrefixBuffer.ToString(), errorMessage, attemptedValue); + } + + public void AddMappingError(Exception exception, string? attemptedValue) + { + ArgumentNullException.ThrowIfNull(exception); + + // Avoid re-wrapping the exception if it is already a FormDataMappingException + // and we don't have an ErrorHandler configured. + if (exception is FormDataMappingException && ErrorHandler == null) + { + throw exception; + } + + var errorMessage = FormattableStringFactory.Create(exception.Message); + AddMappingError(errorMessage, attemptedValue); + } + + public void AttachInstanceToErrors(object value) + { + if (AttachInstanceToErrorsHandler == null) + { + return; + } + + AttachInstanceToErrorsHandler(_currentPrefixBuffer.ToString(), value); + } + + internal FormKeyCollection GetKeys() + { + // Scan the input dictionary for keys matching the current prefix followed by a bracket segment. + // This avoids building a large upfront dictionary of all prefix→key mappings. + var prefix = _currentPrefixBuffer; + var result = new HashSet(); + + foreach (var kvp in _readOnlyMemoryKeys) + { + var key = kvp.Key.Value; + + // The key must start with the current prefix (case-insensitive). + if (key.Length <= prefix.Length || + !key.Span[..prefix.Length].Equals(prefix.Span, StringComparison.OrdinalIgnoreCase)) + { + continue; + } + + // Immediately after the prefix, there must be a '['. + if (key.Span[prefix.Length] != '[') + { + continue; + } + + // Find the closing ']' after the '['. + var remaining = key[prefix.Length..]; + var closeIndex = remaining.Span[1..].IndexOf(']'); + if (closeIndex == -1) + { + // Malformed key — no closing bracket. Skip it. + continue; + } + + // Extract "[value]" (closeIndex is relative to position 1, so add 2 for the full segment). + var segment = remaining[..(closeIndex + 2)]; + result.Add(new FormKey(segment)); + + // Allow one extra item through so collection/dictionary binding can still detect overflow + // and report the existing max-size error instead of silently truncating the input. + if (result.Count > MaxCollectionSize) + { + break; + } + } + + return result.Count > 0 + ? new FormKeyCollection(result) + : FormKeyCollection.Empty; + } + + // This only ever gets invoked if we have a recursive type. + // Recursive types make an existential check for the current prefix to determine if they + // need to continue mapping data. + // At that point, we are placing the keys into a sorted array, and we use binary search to + // determine if the prefix exists. + // We only make this search on recursive paths, as opposed to in every new scope that we push. + internal bool CurrentPrefixExists() + { + if (CurrentPrefix.Span.Length == 0) + { + // Avoid creating the prefix array at the root level. + return _readOnlyMemoryKeys.Count > 0; + } + + if (!_prefixResolver.HasValues) + { + _prefixResolver = new PrefixResolver(_readOnlyMemoryKeys.Keys, _readOnlyMemoryKeys.Count); + } + + return _prefixResolver.HasPrefix(_currentPrefixBuffer); + } + + internal void PopPrefix(string key) + { + PopPrefix(key.AsSpan()); + } + + internal void PopPrefix(ReadOnlySpan key) + { + if (_currentDepth > MaxRecursionDepth) + { + return; + } + + _currentDepth--; + Debug.Assert(_currentDepth >= 0); + var keyLength = key.Length; + // If keyLength is bigger than the current scope keyLength typically means there is a + // bug where some part of the code has not popped the scope appropriately. + Debug.Assert(_currentPrefixBuffer.Length >= keyLength); + if (_currentPrefixBuffer.Length == keyLength || _currentPrefixBuffer.Span[^(keyLength + 1)] != '.') + { + _currentPrefixBuffer = _currentPrefixBuffer[..^keyLength]; + } + else + { + _currentPrefixBuffer = _currentPrefixBuffer[..^(keyLength + 1)]; + } + } + + internal void PushPrefix(string key) + { + PushPrefix(key.AsSpan()); + } + + internal void PushPrefix(scoped ReadOnlySpan key) + { + _currentDepth++; + // We automatically append a "." before adding the suffix, except when its the first element pushed to the + // scope, or when we are accessing a property after a collection or an indexer like items[1]. + var separator = _currentPrefixBuffer.Length > 0 && key[0] != '[' + ? ".".AsSpan() + : "".AsSpan(); + if (_currentDepth > MaxRecursionDepth) + { + throw new InvalidOperationException($"The maximum recursion depth of '{MaxRecursionDepth}' was exceeded for '{_currentPrefixBuffer}{separator}{key}'."); + } + + Debug.Assert(_prefixBuffer.Length >= (_currentPrefixBuffer.Length + separator.Length)); + + separator.CopyTo(_prefixBuffer.Span[_currentPrefixBuffer.Length..]); + + var startingPoint = _currentPrefixBuffer.Length + separator.Length; + _currentPrefixBuffer = _prefixBuffer.Slice(0, startingPoint + key.Length); + key.CopyTo(_prefixBuffer[startingPoint..].Span); + } + + internal readonly bool TryGetValue([NotNullWhen(true)] out string? value) + { + var foundSingleValue = _readOnlyMemoryKeys.TryGetValue(new FormKey(_currentPrefixBuffer), out var result) || result.Count == 1; + if (foundSingleValue) + { + value = result[0]; + } + else + { + value = null; + } + + return foundSingleValue; + } + + internal readonly bool TryGetValues(out StringValues values) => + _readOnlyMemoryKeys.TryGetValue(new FormKey(_currentPrefixBuffer), out values); + + internal string GetPrefix() => _currentPrefixBuffer.ToString(); + + internal string GetLastPrefixSegment() + { + var index = _currentPrefixBuffer.Span.LastIndexOfAny(".["); + if (index == -1) + { + return _currentPrefixBuffer.ToString(); + } + if (_currentPrefixBuffer.Span[index] == '.') + { + return _currentPrefixBuffer.Span[(index + 1)..].ToString(); + } + else + { + // Return the value without the closing bracket ] + return _currentPrefixBuffer.Span[(index + 1)..^1].ToString(); + } + } + + public void Dispose() + { + _prefixResolver.Dispose(); + } + + internal readonly struct FormKeyCollection : IEnumerable> + { + private readonly HashSet _values; + internal static readonly FormKeyCollection Empty; + + public bool HasValues() => _values != null; + + public FormKeyCollection(HashSet values) => _values = values; + + public Enumerator GetEnumerator() => new Enumerator(_values.GetEnumerator()); + + IEnumerator> IEnumerable>.GetEnumerator() => GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + + internal struct Enumerator : IEnumerator> + { + private HashSet.Enumerator _enumerator; + + public Enumerator(HashSet.Enumerator enumerator) + { + _enumerator = enumerator; + } + + public ReadOnlyMemory Current => _enumerator.Current.Value; + + object IEnumerator.Current => _enumerator.Current; + + void IDisposable.Dispose() => _enumerator.Dispose(); + + public bool MoveNext() => _enumerator.MoveNext(); + + void IEnumerator.Reset() { } + } + } + + private readonly string DebuggerDisplay => + $"Key count = {_readOnlyMemoryKeys.Count}, Prefix = {_currentPrefixBuffer}, Error count = {_errorCount}, Current depth = {_currentDepth}"; +} + +=== baseTip 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/FormDataMapper.cs:1-48 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +using Microsoft.Extensions.Logging; + +namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping; + +internal static partial class FormDataMapper +{ + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + public static T? Map( + FormDataReader reader, + FormDataMapperOptions options) + { + FormDataConverter? converter; + try + { + converter = options.ResolveConverter(); + if (converter == null) + { + Log.CannotResolveConverter(options.Logger, typeof(T), null); + return default; + } + } + catch (Exception ex) + { + Log.CannotResolveConverter(options.Logger, typeof(T), ex); + return default; + } + + if (converter.TryRead(ref reader, typeof(T), options, out var result, out _)) + { + return result; + } + + // Always return the result, even if it has failures. This is because we do not want + // to loose the data that we were able to deserialize. + return result; + } + + private static partial class Log + { + [LoggerMessage(1, LogLevel.Warning, "Cannot resolve converter for type '{Type}'.", EventName = "CannotResolveConverter")] + public static partial void CannotResolveConverter(ILogger logger, Type type, Exception? ex); + } +} + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/case.source b/eng/skill-evals/review-pull-request/fixtures/case-02/case.source new file mode 100644 index 000000000000..a6e91438784d --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-02/case.source @@ -0,0 +1,8 @@ +Repository: dotnet/aspnetcore +Pull request: https://github.com/dotnet/aspnetcore/pull/69782 +Head: cfe304ed94f2c9de0e1069947ba51c8c82690ba7 +Merge base: 4f556f73a610b386e5ec29355a300e493d30c4c5 +Base tip: 4f556f73a610b386e5ec29355a300e493d30c4c5 +The source files are excerpts, not a complete ready version-2 review bundle. +provenance.json maps every excerpt to its original source path and lines. +C1: Changing found to false for an unmatched IReadOnlyList causes a required constructor parameter to report a mapping error where the old mapper supplied an empty collection. Consider mapping a complex type with constructor IReadOnlyList files and a populated non-file property, with form files named otherFile and none named files. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/change.diff b/eng/skill-evals/review-pull-request/fixtures/case-02/change.diff new file mode 100644 index 000000000000..e7645aff4bd1 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-02/change.diff @@ -0,0 +1,34 @@ +diff --git a/src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs b/src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs +index fb2d1b74ea..1218cae3d7 100644 +--- a/src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs ++++ b/src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs +@@ -44,22 +44,25 @@ internal sealed class FileConverter : FormDataConverter + buffer = ReadOnlyCollectionBufferAdapter.Add(ref buffer, new BrowserFileFromFormFile(targetFiles[i])); + } + result = (T)(IReadOnlyList)ReadOnlyCollectionBufferAdapter.ToResult(buffer); +- found = true; ++ found = targetFiles.Count > 0; + return true; + } + #endif + + if (typeof(T) == typeof(IReadOnlyList)) + { +- result = (T)reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); +- found = true; ++ var targetFiles = reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); ++ result = (T)targetFiles; ++ found = targetFiles.Count > 0; + return true; + } + + if (typeof(T) == typeof(IFormFileCollection)) + { + result = (T)reader.FormFileCollection; +- found = true; ++ found = reader.CurrentPrefix.Span.IndexOf('[') < 0 ++ ? reader.FormFileCollection.Count > 0 ++ : reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()).Count > 0; + return true; + } + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/context.source b/eng/skill-evals/review-pull-request/fixtures/case-02/context.source new file mode 100644 index 000000000000..992e68d82656 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-02/context.source @@ -0,0 +1,19 @@ +=== head cfe304ed94f2c9de0e1069947ba51c8c82690ba7 src/Components/Endpoints/test/Binding/FormDataMapperTests.cs:2512-2528 === + public void CanDeserialize_ComplexType_IReadOnlyListFormFileWithNoMatches_IsNotFound() + { + var formFileCollection = new FormFileCollection + { + new FormFile(Stream.Null, 0, 10, "otherFile", "file.txt"), + }; + var data = new Dictionary(); + var reader = CreateFormDataReader(data, CultureInfo.InvariantCulture, formFileCollection); + reader.PushPrefix("file"); + var converter = new FileConverter>(); + + var succeeded = converter.TryRead(ref reader, typeof(IReadOnlyList), default!, out var result, out var found); + + Assert.True(succeeded); + Assert.False(found); + Assert.Empty(result); + } + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/head.source b/eng/skill-evals/review-pull-request/fixtures/case-02/head.source new file mode 100644 index 000000000000..9ffd38a2455f --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-02/head.source @@ -0,0 +1,91 @@ +=== head cfe304ed94f2c9de0e1069947ba51c8c82690ba7 src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs:1-89 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +#if COMPONENTS +using Microsoft.AspNetCore.Components.Forms; +#endif +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping; + +internal sealed class FileConverter : FormDataConverter +{ + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + internal override bool TryRead(ref FormDataReader reader, Type type, FormDataMapperOptions options, out T? result, out bool found) + { + if (reader.FormFileCollection == null) + { + result = default; + found = false; + return true; + } + +#if COMPONENTS + if (typeof(T) == typeof(IBrowserFile)) + { + var targetFile = reader.FormFileCollection.GetFile(reader.CurrentPrefix.ToString()); + if (targetFile != null) + { + var browserFile = new BrowserFileFromFormFile(targetFile); + result = (T)(IBrowserFile)browserFile; + found = true; + return true; + } + } + + if (typeof(T) == typeof(IReadOnlyList)) + { + var targetFiles = reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); + var buffer = ReadOnlyCollectionBufferAdapter.CreateBuffer(); + for (var i = 0; i < targetFiles.Count; i++) + { + buffer = ReadOnlyCollectionBufferAdapter.Add(ref buffer, new BrowserFileFromFormFile(targetFiles[i])); + } + result = (T)(IReadOnlyList)ReadOnlyCollectionBufferAdapter.ToResult(buffer); + found = targetFiles.Count > 0; + return true; + } +#endif + + if (typeof(T) == typeof(IReadOnlyList)) + { + var targetFiles = reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); + result = (T)targetFiles; + found = targetFiles.Count > 0; + return true; + } + + if (typeof(T) == typeof(IFormFileCollection)) + { + result = (T)reader.FormFileCollection; + found = reader.CurrentPrefix.Span.IndexOf('[') < 0 + ? reader.FormFileCollection.Count > 0 + : reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()).Count > 0; + return true; + } + + var formFileCollection = reader.FormFileCollection; + if (formFileCollection.Count == 0) + { + result = default; + found = false; + return true; + } + + var file = formFileCollection.GetFile(reader.CurrentPrefix.ToString()); + if (file != null) + { + result = (T)file; + found = true; + return true; + } + + result = default; + found = false; + return true; + } +} + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/mergeBase.source b/eng/skill-evals/review-pull-request/fixtures/case-02/mergeBase.source new file mode 100644 index 000000000000..528e2e1a1123 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-02/mergeBase.source @@ -0,0 +1,88 @@ +=== mergeBase 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs:1-86 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +#if COMPONENTS +using Microsoft.AspNetCore.Components.Forms; +#endif +using Microsoft.AspNetCore.Http; + +namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping; + +internal sealed class FileConverter : FormDataConverter +{ + [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] + [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] + internal override bool TryRead(ref FormDataReader reader, Type type, FormDataMapperOptions options, out T? result, out bool found) + { + if (reader.FormFileCollection == null) + { + result = default; + found = false; + return true; + } + +#if COMPONENTS + if (typeof(T) == typeof(IBrowserFile)) + { + var targetFile = reader.FormFileCollection.GetFile(reader.CurrentPrefix.ToString()); + if (targetFile != null) + { + var browserFile = new BrowserFileFromFormFile(targetFile); + result = (T)(IBrowserFile)browserFile; + found = true; + return true; + } + } + + if (typeof(T) == typeof(IReadOnlyList)) + { + var targetFiles = reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); + var buffer = ReadOnlyCollectionBufferAdapter.CreateBuffer(); + for (var i = 0; i < targetFiles.Count; i++) + { + buffer = ReadOnlyCollectionBufferAdapter.Add(ref buffer, new BrowserFileFromFormFile(targetFiles[i])); + } + result = (T)(IReadOnlyList)ReadOnlyCollectionBufferAdapter.ToResult(buffer); + found = true; + return true; + } +#endif + + if (typeof(T) == typeof(IReadOnlyList)) + { + result = (T)reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); + found = true; + return true; + } + + if (typeof(T) == typeof(IFormFileCollection)) + { + result = (T)reader.FormFileCollection; + found = true; + return true; + } + + var formFileCollection = reader.FormFileCollection; + if (formFileCollection.Count == 0) + { + result = default; + found = false; + return true; + } + + var file = formFileCollection.GetFile(reader.CurrentPrefix.ToString()); + if (file != null) + { + result = (T)file; + found = true; + return true; + } + + result = default; + found = false; + return true; + } +} + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/provenance.json b/eng/skill-evals/review-pull-request/fixtures/case-02/provenance.json new file mode 100644 index 000000000000..0965e2678f3f --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-02/provenance.json @@ -0,0 +1,151 @@ +{ + "repository": "dotnet/aspnetcore", + "pullRequest": 69782, + "sourceRoles": { + "mergeBase": "4f556f73a610b386e5ec29355a300e493d30c4c5", + "head": "cfe304ed94f2c9de0e1069947ba51c8c82690ba7", + "baseTip": "4f556f73a610b386e5ec29355a300e493d30c4c5" + }, + "files": [ + { + "file": "mergeBase.source", + "sha256": "8abba8f0360a7d24e52517cecef7e365f689fa554df5dd81ad58aa6e7d9f5f4a", + "sources": [ + { + "role": "mergeBase", + "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", + "path": "src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs", + "blob": "fb2d1b74eae55c6c61cfb3bfbf30b4f08c2c79ff", + "ranges": [ + [ + 1, + 86 + ] + ] + } + ] + }, + { + "file": "head.source", + "sha256": "69b46771aa41acfbc6394eb67e7024eaf1900485561a562cbd78dff3e2b15571", + "sources": [ + { + "role": "head", + "commit": "cfe304ed94f2c9de0e1069947ba51c8c82690ba7", + "path": "src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs", + "blob": "1218cae3d76bff951a6711a966648ed08fc66b6b", + "ranges": [ + [ + 1, + 89 + ] + ] + } + ] + }, + { + "file": "baseTip.source", + "sha256": "70227fa96f82af98184a4ee45d5f34fcad6aae1c595f2efce558235dc5b335a6", + "sources": [ + { + "role": "baseTip", + "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", + "path": "src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs", + "blob": "fb2d1b74eae55c6c61cfb3bfbf30b4f08c2c79ff", + "ranges": [ + [ + 1, + 86 + ] + ] + }, + { + "role": "baseTip", + "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", + "path": "src/Components/Endpoints/src/FormMapping/Factories/ComplexType/ComplexTypeExpressionConverterFactoryOfT.cs", + "blob": "96146387c11ca2a7fa96a06b9e1fbdea515923b6", + "ranges": [ + [ + 1, + 621 + ] + ] + }, + { + "role": "baseTip", + "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", + "path": "src/Components/Endpoints/src/FormMapping/Metadata/FormDataMetadataFactory.cs", + "blob": "ff2fa90f11333969775a6b426c46581310936114", + "ranges": [ + [ + 1, + 428 + ] + ] + }, + { + "role": "baseTip", + "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", + "path": "src/Components/Endpoints/src/FormMapping/Metadata/FormDataParameterMetadata.cs", + "blob": "1d631872df400af8e691dbed26218491bb3daed2", + "ranges": [ + [ + 1, + 25 + ] + ] + }, + { + "role": "baseTip", + "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", + "path": "src/Components/Endpoints/src/FormMapping/FormDataReader.cs", + "blob": "f142f0e9e003ea913fbc66149ca9634449e99b1b", + "ranges": [ + [ + 1, + 318 + ] + ] + }, + { + "role": "baseTip", + "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", + "path": "src/Components/Endpoints/src/FormMapping/FormDataMapper.cs", + "blob": "00873d0f9baf500d71c719697aabd3d10cfc632a", + "ranges": [ + [ + 1, + 48 + ] + ] + } + ] + }, + { + "file": "context.source", + "sha256": "8217b34af259159122162b8dc3ed55bbac2546d86c7dca8ed69cdb8a6cf2230b", + "sources": [ + { + "role": "head", + "commit": "cfe304ed94f2c9de0e1069947ba51c8c82690ba7", + "path": "src/Components/Endpoints/test/Binding/FormDataMapperTests.cs", + "blob": "1c8d7e66f14c3cb1264589608657ed6bdb7bbb30", + "ranges": [ + [ + 2512, + 2528 + ] + ] + } + ] + }, + { + "file": "change.diff", + "sha256": "19e641ec597c9b3d9d3d3985178bc2e34713fa628eeb0616cca4ba757b025f56" + }, + { + "file": "case.source", + "sha256": "4325461840a90e04aef5ad5eff7734c3e386343a21e45aa158a4474710b12985" + } + ] +} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/baseTip.source b/eng/skill-evals/review-pull-request/fixtures/case-03/baseTip.source new file mode 100644 index 000000000000..67c86497d5b8 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-03/baseTip.source @@ -0,0 +1,127 @@ +=== baseTip 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 src/Components/Components/src/RenderHandle.cs:1-125 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +using Microsoft.AspNetCore.Components.HotReload; +using Microsoft.AspNetCore.Components.RenderTree; +using Microsoft.AspNetCore.Components.Sections; + +namespace Microsoft.AspNetCore.Components; + +/// +/// Allows a component to interact with its renderer. +/// +public readonly struct RenderHandle +{ + private readonly Renderer? _renderer; + private readonly int _componentId; + + internal RenderHandle(Renderer renderer, int componentId) + { + _renderer = renderer ?? throw new ArgumentNullException(nameof(renderer)); + _componentId = componentId; + } + + internal ComponentsMetrics? ComponentMetrics => _renderer?.ComponentMetrics; + internal ComponentsActivitySource? ComponentActivitySource => _renderer?.ComponentActivitySource; + internal SectionRegistry SectionRegistry => _renderer?.SectionRegistry ?? throw new InvalidOperationException("No renderer has been initialized."); + + /// + /// Gets the associated with the component. + /// + public Dispatcher Dispatcher + { + get + { + if (_renderer == null) + { + ThrowNotInitialized(); + } + + return _renderer.Dispatcher; + } + } + + /// + /// Gets a value that indicates whether the has been + /// initialized and is ready to use. + /// + public bool IsInitialized => _renderer is not null; + + /// + /// Gets a value that determines if the is triggering a render in response to a metadata update (hot-reload) change. + /// + public bool IsRenderingOnMetadataUpdate => HotReloadManager.IsSupported && (_renderer?.IsRenderingOnMetadataUpdate ?? false); + + internal bool IsFirstHotReloadRender() => IsRenderingOnMetadataUpdate && _renderer?.IsFirstHotReloadRender(_componentId) == true; + + internal bool IsRendererDisposed => _renderer?.Disposed + ?? throw new InvalidOperationException("No renderer has been initialized."); + + /// + /// Gets the the component is running on. + /// + public RendererInfo RendererInfo => _renderer?.RendererInfo ?? throw new InvalidOperationException("No renderer has been initialized."); + + /// + /// Retrieves the assigned to the component. + /// + /// The assigned to the component. + public IComponentRenderMode? RenderMode + { + get + { + if (_renderer == null) + { + throw new InvalidOperationException("No renderer has been initialized."); + } + + return _renderer.GetComponentRenderMode(_componentId); + } + } + + /// + /// Gets the associated with the . + /// + public ResourceAssetCollection Assets + { + get + { + return _renderer?.Assets ?? throw new InvalidOperationException("No renderer has been initialized."); + } + } + + /// + /// Notifies the renderer that the component should be rendered. + /// + /// The content that should be rendered. + public void Render(RenderFragment renderFragment) + { + if (_renderer == null) + { + ThrowNotInitialized(); + } + + _renderer.AddToRenderQueue(_componentId, renderFragment); + } + + /// + /// Dispatches an to the . + /// + /// The that will be dispatched to the renderer. + /// A that will be completed when the exception has finished dispatching. + public Task DispatchExceptionAsync(Exception exception) + { + var renderer = _renderer; + var componentId = _componentId; + return Dispatcher.InvokeAsync(() => renderer!.HandleComponentException(exception, componentId)); + } + + [DoesNotReturn] + private static void ThrowNotInitialized() + { + throw new InvalidOperationException("The render handle is not yet assigned."); + } +} + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/case.source b/eng/skill-evals/review-pull-request/fixtures/case-03/case.source new file mode 100644 index 000000000000..61014c106768 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-03/case.source @@ -0,0 +1,8 @@ +Repository: dotnet/aspnetcore +Pull request: https://github.com/dotnet/aspnetcore/pull/70304 +Head: fd7be3828242ffabf3f64d230bfb511bbe42f553 +Merge base: 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 +Base tip: 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 +The source files are excerpts, not a complete ready version-2 review bundle. +provenance.json maps every excerpt to its original source path and lines. +C1: The new _rendererIsDisposed guard removes previously functioning ErrorBoundary delivery for DispatchExceptionAsync called by background work after Renderer.Dispose completes. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/change.diff b/eng/skill-evals/review-pull-request/fixtures/case-03/change.diff new file mode 100644 index 000000000000..8dbf27563705 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-03/change.diff @@ -0,0 +1,20 @@ +diff --git a/src/Components/Components/src/RenderTree/Renderer.cs b/src/Components/Components/src/RenderTree/Renderer.cs +index 43130ce396..1b66058ffd 100644 +--- a/src/Components/Components/src/RenderTree/Renderer.cs ++++ b/src/Components/Components/src/RenderTree/Renderer.cs +@@ -1180,7 +1180,14 @@ public abstract partial class Renderer : IDisposable, IAsyncDisposable + } + + internal void HandleComponentException(Exception exception, int componentId) +- => HandleExceptionViaErrorBoundary(exception, GetRequiredComponentState(componentId)); ++ { ++ if (_rendererIsDisposed) ++ { ++ return; ++ } ++ ++ HandleExceptionViaErrorBoundary(exception, GetRequiredComponentState(componentId)); ++ } + + /// + /// If the exception can be routed to an error boundary around , do so. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/context.source b/eng/skill-evals/review-pull-request/fixtures/case-03/context.source new file mode 100644 index 000000000000..139698b0fd40 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-03/context.source @@ -0,0 +1,116 @@ +=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/test/RendererTest.cs:6095-6106 === + public async Task DispatchExceptionAsync_AfterRendererIsDisposed_DoesNotThrow() + { + var renderer = new TestRenderer(); + var component = new DispatchExceptionComponent(); + var componentId = renderer.AssignRootComponentId(component); + await renderer.RenderRootComponentAsync(componentId); + renderer.Dispose(); + + await component.DispatchAsync(new InvalidTimeZoneException("Test exception")); + + Assert.Empty(renderer.HandledExceptions); + } + +=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/test/RendererTest.cs:6109-6121 === + public async Task DispatchExceptionAsync_AfterComponentIsRemoved_Throws() + { + var renderer = new TestRenderer(); + var component = new DispatchExceptionComponent(); + var componentId = renderer.AssignRootComponentId(component); + await renderer.RenderRootComponentAsync(componentId); + await renderer.Dispatcher.InvokeAsync(() => renderer.RemoveRootComponent(componentId)); + + var exception = await Assert.ThrowsAsync(() => component.DispatchAsync(new InvalidTimeZoneException("Test exception"))); + + Assert.Equal($"The renderer does not have a component with ID {componentId}.", exception.Message); + Assert.Empty(renderer.HandledExceptions); + } + +=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/test/RendererTest.cs:6232-6258 === + public async Task DispatchExceptionAsync_LiveComponent_UsesClosestErrorBoundary() + { + var renderer = new TestRenderer(); + var rootComponentId = renderer.AssignRootComponentId(new TestComponent(builder => + { + TestErrorBoundary.RenderNestedErrorBoundaries(builder, builder => + { + builder.OpenComponent(0); + builder.CloseComponent(); + }); + })); + await renderer.RenderRootComponentAsync(rootComponentId); + var batch = Assert.Single(renderer.Batches); + var componentFrame = Assert.Single(batch.GetComponentFrames()); + var component = (DispatchExceptionComponent)componentFrame.Component; + var errorBoundaries = batch.GetComponentFrames() + .Select(frame => (TestErrorBoundary)frame.Component).ToArray(); + var exception = new InvalidTimeZoneException("Test exception"); + + await component.DispatchAsync(exception); + + Assert.Collection(errorBoundaries, + boundary => Assert.Null(boundary.ReceivedException), + boundary => Assert.Same(exception, boundary.ReceivedException)); + Assert.Empty(renderer.HandledExceptions); + Assert.Equal(componentFrame.ComponentId, Assert.Single(renderer.Batches[1].DisposedComponentIDs)); + } + +=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/test/RendererTest.cs:6291-6294 === + private class DispatchExceptionComponent : ComponentBase + { + public Task DispatchAsync(Exception exception) => DispatchExceptionAsync(exception); + } + + +=== https://github.com/dotnet/aspnetcore/issues/66322 === +### Describe the bug + +I originally reported this issue on the .NET MAUI side: https://github.com/dotnet/maui/issues/34855. While investigating, I encountered several exceptions, and I believe the specific case described below belongs in this repository. + +Consider the following: + +```csharp +@code { + private bool _loading; + + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + _ = BackgroundWork(); + } + + private async Task BackgroundWork() + { + _loading = true; + await InvokeAsync(StateHasChanged); + + try + { + await Task.Delay(5000); + throw new Exception("Exception"); + } + catch (Exception exception) + { + // MainLayout needs to be wrapped in ErrorBoundary + await DispatchExceptionAsync(exception); + } + finally + { + _loading = false; + await InvokeAsync(StateHasChanged); + } + } +} +``` + +If the browser is closed while `Task.Delay` is still in progress and the WebView is **explicitly disposed**(!!!) via `BlazorWebView.DisposeAsync()`, an exception `Renderer does not have a component with ID XX` is thrown. +If the WebView is not explicitly disposed, a different exception occurs instead, related to the `WebView2` control already being disposed. + +This behavior has been reproduced in WPF. I have not tested WinForms, but I expect similar behavior since most of the code is shared (aside from the dispatcher). I have also not verified whether this affects MAUI Hybrid. + + +### Expected Behavior + +Not to throw exception when webview is disposed. + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/head.source b/eng/skill-evals/review-pull-request/fixtures/case-03/head.source new file mode 100644 index 000000000000..4f8cffe2c414 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-03/head.source @@ -0,0 +1,182 @@ +=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/src/RenderTree/Renderer.cs:802-805 === + internal ComponentState GetRequiredComponentState(int componentId) + => _componentStateById.TryGetValue(componentId, out var componentState) + ? componentState + : throw new ArgumentException($"The renderer does not have a component with ID {componentId}."); + +=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/src/RenderTree/Renderer.cs:1182-1190 === + internal void HandleComponentException(Exception exception, int componentId) + { + if (_rendererIsDisposed) + { + return; + } + + HandleExceptionViaErrorBoundary(exception, GetRequiredComponentState(componentId)); + } + +=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/src/RenderTree/Renderer.cs:1196-1240 === + private void HandleExceptionViaErrorBoundary(Exception error, ComponentState? errorSourceOrNull) + { + // We only get here in specific situations. Currently, all of them are when we're + // already on the sync context (and if not, we have a bug we want to know about). + Dispatcher.AssertAccess(); + + // We don't allow NavigationException instances to be caught by error boundaries. + // These are special exceptions whose purpose is to be as invisible as possible to + // user code and bubble all the way up to get handled by the framework as a redirect. + if (error is NavigationException) + { + HandleException(error); + return; + } + + // Find the closest error boundary, if any + var candidate = errorSourceOrNull; + while (candidate is not null) + { + if (candidate.Component is IErrorBoundary errorBoundary) + { + // Don't just trust the error boundary to dispose its subtree - force it to do so by + // making it render an empty fragment. Ensures that failed components don't continue to + // operate, which would be a whole new kind of edge case to support forever. + AddToRenderQueue(candidate.ComponentId, builder => { }); + + try + { + errorBoundary.HandleException(error); + } + catch (Exception errorBoundaryException) + { + // If *notifying* about an exception fails, it's OK for that to be fatal + HandleException(errorBoundaryException); + } + + return; // Handled successfully + } + + candidate = candidate.LogicalParentComponentState; + } + + // It's unhandled, so treat as fatal + HandleException(error); + } + +=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/src/RenderTree/Renderer.cs:1246-1361 === + protected virtual void Dispose(bool disposing) + { + // Unlike other Renderer APIs, we need Dispose to be thread-safe + // (and not require being called only from the sync context) + // because other classes many need to dispose a Renderer during their own Dispose (rather than DisposeAsync) + // and we don't want to force that other code to deal with calling InvokeAsync from a synchronous method. + lock (_lockObject) + { + if (_rendererIsDisposed) + { + // quitting synchronously as soon as possible is avoiding + // possible async dispatch to another thread and + // possible deadlock on synchronous `done.Wait()` below. + return; + } + } + + if (!Dispatcher.CheckAccess()) + { + // It's important that we only call the components' Dispose/DisposeAsync lifecycle methods + // on the sync context, like other lifecycle methods. In almost all cases we'd already be + // on the sync context here since DisposeAsync dispatches, but just in case someone is using + // Dispose directly, we'll dispatch and block. + var done = Dispatcher.InvokeAsync(() => Dispose(disposing)); + + // only block caller when this is not finalizer + if (disposing) + { + done.Wait(); + } + + return; + } + + lock (_lockObject) + { + _rendererIsDisposed = true; + } + + if (HotReload.HotReloadManager.IsSupported && HotReloadManager != null && _hotReloadInitialized && _hotReloadRenderHandler is not null) + { + HotReloadManager.OnDeltaApplied -= _hotReloadRenderHandler.RerenderOnHotReload; + } + + // It's important that we handle all exceptions here before reporting any of them. + // This way we can dispose all components before an error handler kicks in. + List exceptions = null; + List asyncDisposables = null; + foreach (var componentState in _componentStateById.Values) + { + Log.DisposingComponent(_logger, componentState); + + try + { + var task = componentState.DisposeAsync(); + if (task.IsCompletedSuccessfully) + { + // If it's a IValueTaskSource backed ValueTask, + // inform it its result has been read so it can reset + task.GetAwaiter().GetResult(); + } + else + { + asyncDisposables ??= new(); + asyncDisposables.Add(task.AsTask()); + } + } + catch (Exception exception) + { + exceptions ??= new List(); + exceptions.Add(exception); + } + } + + _componentStateById.Clear(); // So we know they were all disposed + _componentStateByComponent.Clear(); + _batchBuilder.Dispose(); + + NotifyExceptions(exceptions); + + if (asyncDisposables?.Count >= 1) + { + _disposeTask = HandleAsyncExceptions(asyncDisposables); + } + + async Task HandleAsyncExceptions(List tasks) + { + List asyncExceptions = null; + foreach (var task in tasks) + { + try + { + await task; + } + catch (Exception exception) + { + asyncExceptions ??= new List(); + asyncExceptions.Add(exception); + } + } + + NotifyExceptions(asyncExceptions); + } + + void NotifyExceptions(List exceptions) + { + if (exceptions?.Count > 1) + { + HandleException(new AggregateException("Exceptions were encountered while disposing components.", exceptions)); + } + else if (exceptions?.Count == 1) + { + HandleException(exceptions[0]); + } + } + } + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/mergeBase.source b/eng/skill-evals/review-pull-request/fixtures/case-03/mergeBase.source new file mode 100644 index 000000000000..f7cadb6f4a2e --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-03/mergeBase.source @@ -0,0 +1,175 @@ +=== mergeBase 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 src/Components/Components/src/RenderTree/Renderer.cs:802-805 === + internal ComponentState GetRequiredComponentState(int componentId) + => _componentStateById.TryGetValue(componentId, out var componentState) + ? componentState + : throw new ArgumentException($"The renderer does not have a component with ID {componentId}."); + +=== mergeBase 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 src/Components/Components/src/RenderTree/Renderer.cs:1182-1183 === + internal void HandleComponentException(Exception exception, int componentId) + => HandleExceptionViaErrorBoundary(exception, GetRequiredComponentState(componentId)); + +=== mergeBase 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 src/Components/Components/src/RenderTree/Renderer.cs:1189-1233 === + private void HandleExceptionViaErrorBoundary(Exception error, ComponentState? errorSourceOrNull) + { + // We only get here in specific situations. Currently, all of them are when we're + // already on the sync context (and if not, we have a bug we want to know about). + Dispatcher.AssertAccess(); + + // We don't allow NavigationException instances to be caught by error boundaries. + // These are special exceptions whose purpose is to be as invisible as possible to + // user code and bubble all the way up to get handled by the framework as a redirect. + if (error is NavigationException) + { + HandleException(error); + return; + } + + // Find the closest error boundary, if any + var candidate = errorSourceOrNull; + while (candidate is not null) + { + if (candidate.Component is IErrorBoundary errorBoundary) + { + // Don't just trust the error boundary to dispose its subtree - force it to do so by + // making it render an empty fragment. Ensures that failed components don't continue to + // operate, which would be a whole new kind of edge case to support forever. + AddToRenderQueue(candidate.ComponentId, builder => { }); + + try + { + errorBoundary.HandleException(error); + } + catch (Exception errorBoundaryException) + { + // If *notifying* about an exception fails, it's OK for that to be fatal + HandleException(errorBoundaryException); + } + + return; // Handled successfully + } + + candidate = candidate.LogicalParentComponentState; + } + + // It's unhandled, so treat as fatal + HandleException(error); + } + +=== mergeBase 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 src/Components/Components/src/RenderTree/Renderer.cs:1239-1354 === + protected virtual void Dispose(bool disposing) + { + // Unlike other Renderer APIs, we need Dispose to be thread-safe + // (and not require being called only from the sync context) + // because other classes many need to dispose a Renderer during their own Dispose (rather than DisposeAsync) + // and we don't want to force that other code to deal with calling InvokeAsync from a synchronous method. + lock (_lockObject) + { + if (_rendererIsDisposed) + { + // quitting synchronously as soon as possible is avoiding + // possible async dispatch to another thread and + // possible deadlock on synchronous `done.Wait()` below. + return; + } + } + + if (!Dispatcher.CheckAccess()) + { + // It's important that we only call the components' Dispose/DisposeAsync lifecycle methods + // on the sync context, like other lifecycle methods. In almost all cases we'd already be + // on the sync context here since DisposeAsync dispatches, but just in case someone is using + // Dispose directly, we'll dispatch and block. + var done = Dispatcher.InvokeAsync(() => Dispose(disposing)); + + // only block caller when this is not finalizer + if (disposing) + { + done.Wait(); + } + + return; + } + + lock (_lockObject) + { + _rendererIsDisposed = true; + } + + if (HotReload.HotReloadManager.IsSupported && HotReloadManager != null && _hotReloadInitialized && _hotReloadRenderHandler is not null) + { + HotReloadManager.OnDeltaApplied -= _hotReloadRenderHandler.RerenderOnHotReload; + } + + // It's important that we handle all exceptions here before reporting any of them. + // This way we can dispose all components before an error handler kicks in. + List exceptions = null; + List asyncDisposables = null; + foreach (var componentState in _componentStateById.Values) + { + Log.DisposingComponent(_logger, componentState); + + try + { + var task = componentState.DisposeAsync(); + if (task.IsCompletedSuccessfully) + { + // If it's a IValueTaskSource backed ValueTask, + // inform it its result has been read so it can reset + task.GetAwaiter().GetResult(); + } + else + { + asyncDisposables ??= new(); + asyncDisposables.Add(task.AsTask()); + } + } + catch (Exception exception) + { + exceptions ??= new List(); + exceptions.Add(exception); + } + } + + _componentStateById.Clear(); // So we know they were all disposed + _componentStateByComponent.Clear(); + _batchBuilder.Dispose(); + + NotifyExceptions(exceptions); + + if (asyncDisposables?.Count >= 1) + { + _disposeTask = HandleAsyncExceptions(asyncDisposables); + } + + async Task HandleAsyncExceptions(List tasks) + { + List asyncExceptions = null; + foreach (var task in tasks) + { + try + { + await task; + } + catch (Exception exception) + { + asyncExceptions ??= new List(); + asyncExceptions.Add(exception); + } + } + + NotifyExceptions(asyncExceptions); + } + + void NotifyExceptions(List exceptions) + { + if (exceptions?.Count > 1) + { + HandleException(new AggregateException("Exceptions were encountered while disposing components.", exceptions)); + } + else if (exceptions?.Count == 1) + { + HandleException(exceptions[0]); + } + } + } + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/provenance.json b/eng/skill-evals/review-pull-request/fixtures/case-03/provenance.json new file mode 100644 index 000000000000..6dd3c117dfe3 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-03/provenance.json @@ -0,0 +1,131 @@ +{ + "repository": "dotnet/aspnetcore", + "pullRequest": 70304, + "sourceRoles": { + "mergeBase": "1c94b15aa54d3d490d0ee060b7d496db3cb291e7", + "head": "fd7be3828242ffabf3f64d230bfb511bbe42f553", + "baseTip": "1c94b15aa54d3d490d0ee060b7d496db3cb291e7" + }, + "files": [ + { + "file": "mergeBase.source", + "sha256": "ecb8038853cbc557a8bf189df33bf00820761e1cc05b088fe0ada1e70a1f0236", + "sources": [ + { + "role": "mergeBase", + "commit": "1c94b15aa54d3d490d0ee060b7d496db3cb291e7", + "path": "src/Components/Components/src/RenderTree/Renderer.cs", + "blob": "43130ce39615fad333f5e7ecf9401c0f4d0dc540", + "ranges": [ + [ + 802, + 805 + ], + [ + 1182, + 1183 + ], + [ + 1189, + 1233 + ], + [ + 1239, + 1354 + ] + ] + } + ] + }, + { + "file": "head.source", + "sha256": "1f92291015003c6ac6993efec14449443ef38d470899beb1c0e7d086424fd824", + "sources": [ + { + "role": "head", + "commit": "fd7be3828242ffabf3f64d230bfb511bbe42f553", + "path": "src/Components/Components/src/RenderTree/Renderer.cs", + "blob": "1b66058ffdc00d9a7f657057dadd8331815acb31", + "ranges": [ + [ + 802, + 805 + ], + [ + 1182, + 1190 + ], + [ + 1196, + 1240 + ], + [ + 1246, + 1361 + ] + ] + } + ] + }, + { + "file": "baseTip.source", + "sha256": "19fad0c5eb14bb14491bf45e2d097eed8d22016472bacd515dbc799e1d98d6db", + "sources": [ + { + "role": "baseTip", + "commit": "1c94b15aa54d3d490d0ee060b7d496db3cb291e7", + "path": "src/Components/Components/src/RenderHandle.cs", + "blob": "bc5e2eb02a019506941d1db8d572ff899b392096", + "ranges": [ + [ + 1, + 125 + ] + ] + } + ] + }, + { + "file": "context.source", + "sha256": "5f4ff01204f825cfab5d6e2dd22f619c1f17bb95608ccae181b1891455635c66", + "sources": [ + { + "role": "head", + "commit": "fd7be3828242ffabf3f64d230bfb511bbe42f553", + "path": "src/Components/Components/test/RendererTest.cs", + "blob": "8c5f99d695e75e9f5fd3d97b229d13e46e4cdb02", + "ranges": [ + [ + 6095, + 6106 + ], + [ + 6109, + 6121 + ], + [ + 6232, + 6258 + ], + [ + 6291, + 6294 + ] + ] + } + ], + "issue": { + "url": "https://github.com/dotnet/aspnetcore/issues/66322", + "updatedAt": "2026-10-07T19:08:14Z" + } + }, + { + "file": "change.diff", + "sha256": "7d4f8a6cb6d9989d849a9a3c485e85238cbb1c844408c7ab9b724807f98ac975" + }, + { + "file": "case.source", + "sha256": "769c32c864e5c768a7e2351f3bcf188ee703912c8bce2a07cbb0e61bdf5be807" + } + ] +} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/baseTip.source b/eng/skill-evals/review-pull-request/fixtures/case-04/baseTip.source new file mode 100644 index 000000000000..f78793112cca --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-04/baseTip.source @@ -0,0 +1,517 @@ +=== baseTip 66e2adb4e0297e445686cb7a70d6c9aa84dcf3af src/Components/WebAssembly/Authentication.Msal/src/Interop/AuthenticationService.ts:1-515 === +import * as Msal from '@azure/msal-browser'; + +interface AccessTokenRequestOptions { + scopes: string[]; + returnUrl: string; +} + +interface AccessTokenResult { + status: AccessTokenResultStatus; + token?: AccessToken; +} + +interface AccessToken { + value: string; + expires: Date | null; + grantedScopes: string[]; +} + +enum AccessTokenResultStatus { + Success = "success", + RequiresRedirect = "requiresRedirect" +} + +enum AuthenticationResultStatus { + Redirect = "redirect", + Success = "success", + Failure = "failure", + OperationCompleted = "operationCompleted" +} + +interface AuthenticationResult { + status: AuthenticationResultStatus; + state?: any; + message?: string; +} + +interface AuthorizeService { + getUser(): Promise; + getAccessToken(request?: AccessTokenRequestOptions): Promise; + signIn(state: any): Promise; + completeSignIn(state: any): Promise; + signOut(state: any): Promise; + completeSignOut(url: string): Promise; +} + +// These are the values for the .NET logger LogLevel. +// We only use debug and trace +export enum LogLevel { + Trace = 0, + Debug = 1 +} + +interface JavaScriptLoggingOptions { + debugEnabled: boolean; + traceEnabled: boolean; +} + +export class Logger { + public debug: boolean; + public trace: boolean; + public constructor(options: JavaScriptLoggingOptions) { + this.debug = options.debugEnabled; + this.trace = options.traceEnabled; + } + + log(level: LogLevel, message: string): void { + if ((level == LogLevel.Trace && this.trace) || + (level == LogLevel.Debug && this.debug)) { + const levelString = level == LogLevel.Trace ? 'trce' : 'dbug'; + console.debug( + // Logs in the following format to keep consistency with the way ASP.NET Core logs to the console while avoiding the + // additional overhead of passing the logger as a JSObjectReference + // dbug: Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService[0] + // <> + // trce: Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService[0] + // <> + `${levelString}: Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService[0] + ${message}`); + } + } +} + +export interface AuthenticationContext { + state?: unknown; + interactiveRequest: InteractiveAuthenticationRequest; +} + +export interface InteractiveAuthenticationRequest { + interaction: string; + scopes?: string[]; + additionalRequestParameters?: { [key: string]: any }; +}; + +interface AuthorizeServiceConfiguration extends Msal.Configuration { + defaultAccessTokenScopes: string[]; + additionalScopesToConsent: string[]; + loginMode: string; +} + +class MsalAuthorizeService implements AuthorizeService { + private readonly _msalApplication: Msal.PublicClientApplication; + private _account: Msal.AccountInfo | null | undefined; + private _redirectCallback: Promise | undefined; + + constructor(private readonly _settings: AuthorizeServiceConfiguration, private readonly _logger: Logger) { + if (this._settings.auth?.knownAuthorities?.length == 0) { + this._settings.auth.knownAuthorities = [new URL(this._settings.auth.authority!).hostname] + } + + this._settings.system = this._settings.system || {}; + + this._settings.system.navigationClient = { + async navigateInternal(url: string, options: Msal.NavigationOptions): Promise { + // We always replace the URL + _logger.log(LogLevel.Trace, `Navigating to ${url}`); + location.replace(url); + return false; + }, + async navigateExternal(url: string, options: Msal.NavigationOptions): Promise { + // We always replace the URL + _logger.log(LogLevel.Trace, `Navigating to ${url}`); + location.replace(url); + return false; + } + } + + this._settings.system.loggerOptions = { + logLevel: _logger.trace ? Msal.LogLevel.Trace : (_logger.debug ? Msal.LogLevel.Verbose : Msal.LogLevel.Warning), + loggerCallback: (level, message, containsPii) => { + if (containsPii) { + return; + } + if (level === Msal.LogLevel.Trace) { + _logger.log(LogLevel.Trace, message); + return; + } + + // We only have Debug/Trace, so anything above, we only log when Debug is enabled. + _logger.log(LogLevel.Debug, message); + return; + } + }; + + this._msalApplication = new Msal.PublicClientApplication(this._settings); + } + + async initialize(): Promise { + await this._msalApplication.initialize(); + } + + getAccount() { + if (this._account) { + return this._account; + } + + const accounts = this._msalApplication.getAllAccounts(); + if (accounts && accounts.length) { + return accounts[0]; + } + + return null; + } + + async getUser() { + const account = this.getAccount(); + if (!account) { + return; + } + + return account.idTokenClaims; + } + + async getAccessToken(request?: AccessTokenRequestOptions): Promise { + try { + this.trace('getAccessToken', request); + const newToken = await this.getTokenCore(request?.scopes); + return { + status: AccessTokenResultStatus.Success, + token: newToken + }; + } catch (e) { + return { + status: AccessTokenResultStatus.RequiresRedirect + }; + } + } + + async getTokenCore(scopes?: string[]): Promise { + const account = this.getAccount(); + if (!account) { + throw new Error('Failed to retrieve token, no account found.'); + } + + const silentRequest = { + redirectUri: this._settings.auth?.redirectUri, + account: account, + scopes: scopes || this._settings.defaultAccessTokenScopes + }; + + this.debug(`Provisioning a token silently for scopes '${silentRequest.scopes}'`) + this.trace('_msalApplication.acquireTokenSilent', silentRequest); + const response = await this._msalApplication.acquireTokenSilent(silentRequest); + this.trace('_msalApplication.acquireTokenSilent-response', response); + + if (response.scopes.length === 0 || response.accessToken === '') { + throw new Error('Scopes not granted.'); + } + + const result = { + value: response.accessToken, + grantedScopes: response.scopes, + expires: response.expiresOn + }; + + this.trace('getAccessToken-result', result); + + return result; + } + + async signIn(context: AuthenticationContext) { + this.trace('signIn', context); + try { + // Before we start any sign-in flow, clear out any previous state so that it doesn't pile up. + this.purgeState(); + + const { state, interactiveRequest } = context; + + if (interactiveRequest && interactiveRequest.interaction === 'GetToken') { + this.debug('Acquiring additional token.'); + const request: Msal.RedirectRequest = { + scopes: interactiveRequest.scopes || [], + state: this.saveState(context.state), + ...interactiveRequest.additionalRequestParameters + }; + this.trace('getInteractiveToken-Request', request); + await this._msalApplication.acquireTokenRedirect(request); + return this.success(state); + } else { + const request: Partial = { + redirectUri: this._settings.auth.redirectUri!, + state: this.saveState(context.state), + ...interactiveRequest?.additionalRequestParameters + }; + + request.scopes = request.scopes || this._settings.defaultAccessTokenScopes || []; + + const result = await this.signInCore(request); + this.trace('signIn-Response', result); + if (!result) { + return this.redirect(); + } else if (this.isMsalError(result)) { + return this.error(result.errorMessage); + } + + return this.success(state); + } + } catch (e) { + const message = (e as Error).message; + this.debug(`Sign in error '${message}'`); + return this.error(message); + } + } + + async signInCore(request: Partial): Promise { + this.trace('signIn-Request', request); + const loginMode = this._settings.loginMode.toLowerCase(); + if (loginMode === 'redirect') { + return this.signInWithRedirect(request as Msal.RedirectRequest); + } else { + return this.signInWithPopup(request as Msal.PopupRequest); + } + } + + private async signInWithRedirect(request: Msal.RedirectRequest) { + try { + this.debug('Starting sign-in redirect.'); + return await this._msalApplication.loginRedirect(request); + } catch (e) { + this.debug(`Sign-in redirect failed: '${(e as Error).message}'.`); + return e as any; + } + } + + private async signInWithPopup(request: Msal.PopupRequest) { + try { + this.debug('Starting sign-in pop-up'); + return await this._msalApplication.loginPopup(request); + } catch (e) { + // If the user explicitly cancelled the pop-up, avoid performing a redirect. + if (this.isMsalError(e) && e.errorCode !== Msal.BrowserAuthErrorCodes.userCancelled) { + this.signInWithRedirect(request); + } else { + this.debug(`Sign-in pop-up failed: '${(e as Error).message}'.`); + return e as any; + } + } + } + + async completeSignIn() { + // Make sure that the redirect handler has completed execution before + // completing sign in. + try { + this.debug('Completing sign-in redirect.'); + var authenticationResult = await this._redirectCallback; + this.trace('completeSignIn-result', authenticationResult); + if (authenticationResult) { + this.trace('completeSignIn-success', authenticationResult); + return authenticationResult; + } + this.debug('No authentication result.'); + return this.operationCompleted(); + } catch (e) { + this.debug(`completeSignIn-error:'${(e as Error).message}'`); + return this.error((e as Error).message); + } + } + + async signOut(context: AuthenticationContext) { + this.trace('signOut', context); + try { + // Before we start any sign-in flow, clear out any previous state so that it doesn't pile up. + this.purgeState(); + + const { state, interactiveRequest } = context; + + const request: Partial = { + postLogoutRedirectUri: this._settings.auth.postLogoutRedirectUri, + state: this.saveState(state), + ...interactiveRequest?.additionalRequestParameters + }; + this.trace('signOut-Request', request); + + await this._msalApplication.logoutRedirect(request); + + // We are about to be redirected. + return this.redirect(); + } catch (e) { + return this.error((e as Error).message); + } + } + + async completeSignOut(url: string) { + this.trace('completeSignOut-request', url); + try { + this.debug('Completing sign-out redirect.'); + var authenticationResult = await this._redirectCallback; + this.trace('completeSignOut-result', authenticationResult); + if (authenticationResult) { + this.trace('completeSignOut-success', authenticationResult); + return authenticationResult; + } + this.debug('No authentication result.'); + return this.operationCompleted(); + } catch (e) { + this.debug(`completeSignOut-error:'${(e as Error).message}'`); + return this.error((e as Error).message); + } + } + + // msal.js only allows a string as the account state and it simply attaches it to the sign-in request state. + // Given that we don't want to serialize the entire state and put it in the query string, we need to serialize the + // state ourselves and pass an identifier to retrieve it while in the callback flow. + saveState(state: T): string { + const identifier = window.crypto.randomUUID(); + sessionStorage.setItem(`${AuthenticationService._infrastructureKey}.AuthorizeService.${identifier}`, JSON.stringify(state)); + return identifier; + } + + retrieveState(url: string | null, providedState: string | null = null, isLogout: boolean = false): T | undefined { + let stateFromUrl; + // Parse the state key from the `search` query parameter in the URL if provided + if (url) { + const parsedUrl = new URL(url); + stateFromUrl = parsedUrl.searchParams && parsedUrl.searchParams.getAll('state'); + } + + // Chose the provided state from MSAL. Otherwise, choose the state computed from the URL + const state = providedState || stateFromUrl; + + if (!state) { + return undefined; + } + + const stateKey = `${AuthenticationService._infrastructureKey}.AuthorizeService.${state}`; + const stateString = sessionStorage.getItem(stateKey); + if (stateString) { + sessionStorage.removeItem(stateKey); + const savedState = JSON.parse(stateString); + return savedState; + } + + return undefined; + } + + purgeState() { + for (let i = 0; i < sessionStorage.length; i++) { + const key = sessionStorage.key(i); + if (key?.startsWith(AuthenticationService._infrastructureKey)) { + sessionStorage.removeItem(key); + } + } + } + + initializeMsalHandler() { + this._redirectCallback = this.completeAuthentication(); + } + + private async completeAuthentication() { + try { + const result = await this._msalApplication.handleRedirectPromise(); + const res = this.handleResult(result); + return res; + } catch (error) { + if (this.isMsalError(error)) { + return this.error(error.errorMessage); + } else { + return this.error((error as Error).message); + } + }; + } + + private handleResult(result: Msal.AuthenticationResult | null) { + const logoutState = this.retrieveState(location.href, undefined); + if (result) { + this._account = result.account; + return this.success(this.retrieveState(null, result.state)); + } else if (logoutState) { + return this.success(logoutState); + } else { + return this.operationCompleted(); + } + } + + private isMsalError(resultOrError: any): resultOrError is Msal.AuthError { + return resultOrError?.errorCode; + } + + private error(message: string) { + return { status: AuthenticationResultStatus.Failure, errorMessage: message }; + } + + private success(state: any) { + return { status: AuthenticationResultStatus.Success, state }; + } + + private redirect() { + return { status: AuthenticationResultStatus.Redirect }; + } + + private operationCompleted() { + return { status: AuthenticationResultStatus.OperationCompleted }; + } + + private debug(message: string) { + this._logger?.log(LogLevel.Debug, message); + } + + private trace(message: string, data: any) { + this._logger?.log(LogLevel.Trace, `${message}: ${JSON.stringify(data)}`); + } +} + +export class AuthenticationService { + + static _infrastructureKey = 'Microsoft.Authentication.WebAssembly.Msal'; + private static _initialization: Promise | undefined; + static instance: MsalAuthorizeService; + + public static async init(settings: AuthorizeServiceConfiguration, jsLoggingOptions: JavaScriptLoggingOptions) { + if (!AuthenticationService._initialization) { + const instance = new MsalAuthorizeService(settings, new Logger(jsLoggingOptions)); + AuthenticationService.instance = instance; + AuthenticationService._initialization = instance.initialize() + .then(() => instance.initializeMsalHandler()) + .catch(error => { + AuthenticationService._initialization = undefined; + throw error; + }); + } + return AuthenticationService._initialization; + } + + public static getUser() { + return AuthenticationService.instance.getUser(); + } + + public static getAccessToken(request: AccessTokenRequestOptions) { + return AuthenticationService.instance.getAccessToken(request); + } + + public static signIn(state: any) { + return AuthenticationService.instance.signIn(state); + } + + // url is not used in the msal.js implementation but we keep it here + // as it is part of the default RemoteAuthenticationService contract implementation. + // The unused parameter here just reflects that. + public static completeSignIn(url: string) { + return AuthenticationService.instance.completeSignIn(); + } + + public static signOut(state: any) { + return AuthenticationService.instance.signOut(state); + } + + public static completeSignOut(url: string) { + return AuthenticationService.instance.completeSignOut(url); + } +} + +declare global { + interface Window { AuthenticationService: AuthenticationService; } +} + +window.AuthenticationService = AuthenticationService; + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/case.source b/eng/skill-evals/review-pull-request/fixtures/case-04/case.source new file mode 100644 index 000000000000..c0e0d2cdd231 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-04/case.source @@ -0,0 +1,8 @@ +Repository: dotnet/aspnetcore +Pull request: https://github.com/dotnet/aspnetcore/pull/69721 +Head: 153f8ef684a760e30b43609e54a9d22027dc6b62 +Merge base: 66e2adb4e0297e445686cb7a70d6c9aa84dcf3af +Base tip: 66e2adb4e0297e445686cb7a70d6c9aa84dcf3af +The source files are excerpts, not a complete ready version-2 review bundle. +provenance.json maps every excerpt to its original source path and lines. +C1: The new RemoteMsalAuthenticationStartup token endpoint changes the observed result of NavigateDirectlyToLoginCallbackRestartsLoginWithoutInteropFailure because that browser scenario completes an exchange through this endpoint before its assertions. The concern is the asserted browser-test effect, not an independent endpoint policy claim. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/change.diff b/eng/skill-evals/review-pull-request/fixtures/case-04/change.diff new file mode 100644 index 000000000000..7feba2a36173 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-04/change.diff @@ -0,0 +1,108 @@ +diff --git a/src/Components/test/testassets/Components.TestServer/RemoteMsalAuthenticationStartup.cs b/src/Components/test/testassets/Components.TestServer/RemoteMsalAuthenticationStartup.cs +new file mode 100644 +index 0000000000..6e4e181c18 +--- /dev/null ++++ b/src/Components/test/testassets/Components.TestServer/RemoteMsalAuthenticationStartup.cs +@@ -0,0 +1,102 @@ ++// Licensed to the .NET Foundation under one or more agreements. ++// The .NET Foundation licenses this file to you under the MIT license. ++ ++using System.Globalization; ++using System.Reflection; ++using Components.TestServer.RazorComponents; ++using Microsoft.AspNetCore.Mvc; ++using Microsoft.IdentityModel.JsonWebTokens; ++using Microsoft.IdentityModel.Tokens; ++ ++namespace TestServer; ++ ++public class RemoteMsalAuthenticationStartup ++{ ++ public void ConfigureServices(IServiceCollection services) ++ { ++ services.AddRazorComponents() ++ .AddInteractiveWebAssemblyComponents(); ++ } ++ ++ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) ++ { ++ app.Map("/subdir", app => ++ { ++ app.UseRouting(); ++ ++ app.UseAntiforgery(); ++ app.UseEndpoints(endpoints => ++ { ++ var contentRootStaticAssetsPath = Path.Combine(env.ContentRootPath, "Components.TestServer.staticwebassets.endpoints.json"); ++ if (File.Exists(contentRootStaticAssetsPath)) ++ { ++ endpoints.MapStaticAssets(contentRootStaticAssetsPath); ++ } ++ else ++ { ++ endpoints.MapStaticAssets(); ++ } ++ ++ endpoints.MapRazorComponents() ++ .AddAdditionalAssemblies(Assembly.Load("Components.WasmMsalRemoteAuthentication")) ++ .AddInteractiveWebAssemblyRenderMode(options => options.PathPrefix = "/WasmMsalRemoteAuthentication"); ++ ++ var oidcEndpoints = endpoints.MapGroup("oidc"); ++ ++ var issuer = ""; ++ oidcEndpoints.MapGet(".well-known/openid-configuration", (HttpRequest request, [FromHeader] string host) => ++ { ++ issuer = $"{(request.IsHttps ? "https" : "http")}://{host}"; ++ return Results.Json(new ++ { ++ issuer, ++ authorization_endpoint = $"{issuer}/subdir/oidc/authorize", ++ token_endpoint = $"{issuer}/subdir/oidc/token", ++ }); ++ }); ++ ++ var lastCode = ""; ++ var interactiveAuthorizationRequests = 0; ++ oidcEndpoints.MapGet("authorize", (string redirect_uri, string? state, string? prompt) => ++ { ++ if (prompt == "none") ++ { ++ return Results.Redirect($"{redirect_uri}?error=interaction_required&state={state}"); ++ } ++ ++ interactiveAuthorizationRequests++; ++ lastCode = Random.Shared.Next().ToString(CultureInfo.InvariantCulture); ++ return Results.Redirect($"{redirect_uri}?code={lastCode}&state={state}"); ++ }); ++ ++ oidcEndpoints.MapGet("interactive-authorization-requests", () => interactiveAuthorizationRequests); ++ ++ var jwtHandler = new JsonWebTokenHandler(); ++ oidcEndpoints.MapPost("token", ([FromForm] string code) => ++ { ++ if (string.IsNullOrEmpty(lastCode) && code != lastCode) ++ { ++ return Results.BadRequest("Bad code"); ++ } ++ ++ return Results.Json(new ++ { ++ token_type = "Bearer", ++ scope = "openid profile", ++ expires_in = 3600, ++ id_token = jwtHandler.CreateToken(new SecurityTokenDescriptor ++ { ++ Issuer = issuer, ++ Audience = "s6BhdRkqt3", ++ Claims = new Dictionary ++ { ++ ["sub"] = "248289761001", ++ ["name"] = "Jane Doe", ++ }, ++ }), ++ }); ++ }).DisableAntiforgery(); ++ }); ++ }); ++ } ++} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/context.source b/eng/skill-evals/review-pull-request/fixtures/case-04/context.source new file mode 100644 index 000000000000..4aac59a38f84 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-04/context.source @@ -0,0 +1,164 @@ +=== head 153f8ef684a760e30b43609e54a9d22027dc6b62 src/Components/test/E2ETest/Tests/RemoteMsalAuthenticationTest.cs:1-37 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.E2ETest.Infrastructure; +using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; +using Microsoft.AspNetCore.E2ETesting; +using OpenQA.Selenium; +using TestServer; +using Xunit.Abstractions; + +namespace Microsoft.AspNetCore.Components.E2ETest.Tests; + +public class RemoteMsalAuthenticationTest : + ServerTestBase> +{ + public RemoteMsalAuthenticationTest( + BrowserFixture browserFixture, + TrimmingServerFixture serverFixture, + ITestOutputHelper output) + : base(browserFixture, serverFixture, output) + { + } + + [Fact] + public void NavigateDirectlyToLoginCallbackRestartsLoginWithoutInteropFailure() + { + Navigate("/subdir/msal-authentication/login-callback"); + + Browser.True(() => (bool?)((IJavaScriptExecutor)Browser).ExecuteScript( + "return window.__msalSignInCalled") == true); + + var browserLog = Browser.Manage().Logs.GetLog(LogType.Browser); + Assert.DoesNotContain(browserLog, entry => entry.Message.Contains( + "The value 'AuthenticationService.isTopLevelWindow' is not a function.", + StringComparison.Ordinal)); + } +} + +=== head 153f8ef684a760e30b43609e54a9d22027dc6b62 src/Components/test/testassets/Components.TestServer/RazorComponents/RemoteMsalAuthenticationApp.razor:1-30 === + + + + + + + + + + + + + + + + + + + +=== head 153f8ef684a760e30b43609e54a9d22027dc6b62 src/Components/test/testassets/Components.WasmMsalRemoteAuthentication/Program.cs:1-31 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; + +var builder = WebAssemblyHostBuilder.CreateDefault(args); +var authorityBaseUriBuilder = new UriBuilder(builder.HostEnvironment.BaseAddress) +{ + Host = "localhost", + Path = "subdir/oidc", +}; + +builder.Services.AddMsalAuthentication(options => +{ + options.ProviderOptions.Authentication.Authority = authorityBaseUriBuilder.Uri.AbsoluteUri; + options.ProviderOptions.Authentication.ClientId = "s6BhdRkqt3"; + options.ProviderOptions.Authentication.RedirectUri = "msal-authentication/login-callback"; + options.ProviderOptions.Authentication.PostLogoutRedirectUri = "msal-authentication/logout-callback"; + options.ProviderOptions.LoginMode = "redirect"; + options.AuthenticationPaths.LogInPath = "msal-authentication/login"; + options.AuthenticationPaths.LogInCallbackPath = "msal-authentication/login-callback"; + options.AuthenticationPaths.LogInFailedPath = "msal-authentication/login-failed"; + options.AuthenticationPaths.LogOutPath = "msal-authentication/logout"; + options.AuthenticationPaths.LogOutCallbackPath = "msal-authentication/logout-callback"; + options.AuthenticationPaths.LogOutFailedPath = "msal-authentication/logout-failed"; + options.AuthenticationPaths.LogOutSucceededPath = "msal-authentication/logged-out"; + options.AuthenticationPaths.ProfilePath = "msal-authentication/profile"; + options.AuthenticationPaths.RegisterPath = "msal-authentication/register"; +}); + +await builder.Build().RunAsync(); + +=== head 153f8ef684a760e30b43609e54a9d22027dc6b62 src/Components/WebAssembly/Authentication.Msal/src/Interop/AuthenticationService.ts:472-484 === + public static async init(settings: AuthorizeServiceConfiguration, jsLoggingOptions: JavaScriptLoggingOptions) { + if (!AuthenticationService._initialization) { + const instance = new MsalAuthorizeService(settings, new Logger(jsLoggingOptions)); + AuthenticationService.instance = instance; + AuthenticationService._initialization = instance.initialize() + .then(() => instance.initializeMsalHandler()) + .catch(error => { + AuthenticationService._initialization = undefined; + throw error; + }); + } + return AuthenticationService._initialization; + } + +=== head 153f8ef684a760e30b43609e54a9d22027dc6b62 src/Components/WebAssembly/Authentication.Msal/src/Interop/AuthenticationService.ts:220-262 === + async signIn(context: AuthenticationContext) { + this.trace('signIn', context); + try { + // Before we start any sign-in flow, clear out any previous state so that it doesn't pile up. + this.purgeState(); + + const { state, interactiveRequest } = context; + + if (interactiveRequest && interactiveRequest.interaction === 'GetToken') { + this.debug('Acquiring additional token.'); + const request: Msal.RedirectRequest = { + scopes: interactiveRequest.scopes || [], + state: this.saveState(context.state), + ...interactiveRequest.additionalRequestParameters + }; + this.trace('getInteractiveToken-Request', request); + await this._msalApplication.acquireTokenRedirect(request); + return this.success(state); + } else { + const request: Partial = { + redirectUri: this._settings.auth.redirectUri!, + state: this.saveState(context.state), + ...interactiveRequest?.additionalRequestParameters + }; + + request.scopes = request.scopes || this._settings.defaultAccessTokenScopes || []; + + const result = await this.signInCore(request); + this.trace('signIn-Response', result); + if (!result) { + return this.redirect(); + } else if (this.isMsalError(result)) { + return this.error(result.errorMessage); + } + + return this.success(state); + } + } catch (e) { + const message = (e as Error).message; + this.debug(`Sign in error '${message}'`); + return this.error(message); + } + } + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/head.source b/eng/skill-evals/review-pull-request/fixtures/case-04/head.source new file mode 100644 index 000000000000..bd4b34cdb118 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-04/head.source @@ -0,0 +1,104 @@ +=== head 153f8ef684a760e30b43609e54a9d22027dc6b62 src/Components/test/testassets/Components.TestServer/RemoteMsalAuthenticationStartup.cs:1-102 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Globalization; +using System.Reflection; +using Components.TestServer.RazorComponents; +using Microsoft.AspNetCore.Mvc; +using Microsoft.IdentityModel.JsonWebTokens; +using Microsoft.IdentityModel.Tokens; + +namespace TestServer; + +public class RemoteMsalAuthenticationStartup +{ + public void ConfigureServices(IServiceCollection services) + { + services.AddRazorComponents() + .AddInteractiveWebAssemblyComponents(); + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.Map("/subdir", app => + { + app.UseRouting(); + + app.UseAntiforgery(); + app.UseEndpoints(endpoints => + { + var contentRootStaticAssetsPath = Path.Combine(env.ContentRootPath, "Components.TestServer.staticwebassets.endpoints.json"); + if (File.Exists(contentRootStaticAssetsPath)) + { + endpoints.MapStaticAssets(contentRootStaticAssetsPath); + } + else + { + endpoints.MapStaticAssets(); + } + + endpoints.MapRazorComponents() + .AddAdditionalAssemblies(Assembly.Load("Components.WasmMsalRemoteAuthentication")) + .AddInteractiveWebAssemblyRenderMode(options => options.PathPrefix = "/WasmMsalRemoteAuthentication"); + + var oidcEndpoints = endpoints.MapGroup("oidc"); + + var issuer = ""; + oidcEndpoints.MapGet(".well-known/openid-configuration", (HttpRequest request, [FromHeader] string host) => + { + issuer = $"{(request.IsHttps ? "https" : "http")}://{host}"; + return Results.Json(new + { + issuer, + authorization_endpoint = $"{issuer}/subdir/oidc/authorize", + token_endpoint = $"{issuer}/subdir/oidc/token", + }); + }); + + var lastCode = ""; + var interactiveAuthorizationRequests = 0; + oidcEndpoints.MapGet("authorize", (string redirect_uri, string? state, string? prompt) => + { + if (prompt == "none") + { + return Results.Redirect($"{redirect_uri}?error=interaction_required&state={state}"); + } + + interactiveAuthorizationRequests++; + lastCode = Random.Shared.Next().ToString(CultureInfo.InvariantCulture); + return Results.Redirect($"{redirect_uri}?code={lastCode}&state={state}"); + }); + + oidcEndpoints.MapGet("interactive-authorization-requests", () => interactiveAuthorizationRequests); + + var jwtHandler = new JsonWebTokenHandler(); + oidcEndpoints.MapPost("token", ([FromForm] string code) => + { + if (string.IsNullOrEmpty(lastCode) && code != lastCode) + { + return Results.BadRequest("Bad code"); + } + + return Results.Json(new + { + token_type = "Bearer", + scope = "openid profile", + expires_in = 3600, + id_token = jwtHandler.CreateToken(new SecurityTokenDescriptor + { + Issuer = issuer, + Audience = "s6BhdRkqt3", + Claims = new Dictionary + { + ["sub"] = "248289761001", + ["name"] = "Jane Doe", + }, + }), + }); + }).DisableAntiforgery(); + }); + }); + } +} + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/mergeBase.source b/eng/skill-evals/review-pull-request/fixtures/case-04/mergeBase.source new file mode 100644 index 000000000000..3c3c0a87005c --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-04/mergeBase.source @@ -0,0 +1,109 @@ +=== mergeBase 66e2adb4e0297e445686cb7a70d6c9aa84dcf3af src/Components/test/testassets/Components.TestServer/RemoteAuthenticationStartup.cs:1-107 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Globalization; +using System.Reflection; +using Components.TestServer.RazorComponents; +using Microsoft.AspNetCore.Mvc; +using Microsoft.IdentityModel.JsonWebTokens; +using Microsoft.IdentityModel.Tokens; + +namespace TestServer; + +public class RemoteAuthenticationStartup +{ + public void ConfigureServices(IServiceCollection services) + { + services.AddRazorComponents() + .AddInteractiveWebAssemblyComponents(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.Map("/subdir", app => + { + app.UseRouting(); + + app.UseAntiforgery(); + app.UseEndpoints(endpoints => + { + var contentRootStaticAssetsPath = Path.Combine(env.ContentRootPath, "Components.TestServer.staticwebassets.endpoints.json"); + if (File.Exists(contentRootStaticAssetsPath)) + { + endpoints.MapStaticAssets(contentRootStaticAssetsPath); + } + else + { + endpoints.MapStaticAssets(); + } + + endpoints.MapRazorComponents() + .AddAdditionalAssemblies(Assembly.Load("Components.WasmRemoteAuthentication")) + .AddInteractiveWebAssemblyRenderMode(options => options.PathPrefix = "/WasmRemoteAuthentication"); + + var oidcEndpoints = endpoints.MapGroup("oidc"); + + // This is designed to test a single login at a time. + var issuer = ""; + oidcEndpoints.MapGet(".well-known/openid-configuration", (HttpRequest request, [FromHeader] string host) => + { + issuer = $"{(request.IsHttps ? "https" : "http")}://{host}"; + return Results.Json(new + { + issuer, + authorization_endpoint = $"{issuer}/subdir/oidc/authorize", + token_endpoint = $"{issuer}/subdir/oidc/token", + }); + }); + + var lastCode = ""; + oidcEndpoints.MapGet("authorize", (string redirect_uri, string? state, string? prompt, bool? preservedExtraQueryParams) => + { + // Require interaction so silent sign-in does not skip RedirectToLogin.razor. + if (prompt == "none") + { + return Results.Redirect($"{redirect_uri}?error=interaction_required&state={state}"); + } + + // Verify that the extra query parameters added by RedirectToLogin.razor are preserved. + if (preservedExtraQueryParams != true) + { + return Results.Redirect($"{redirect_uri}?error=invalid_request&error_description=extraQueryParams%20not%20preserved&state={state}"); + } + + lastCode = Random.Shared.Next().ToString(CultureInfo.InvariantCulture); + return Results.Redirect($"{redirect_uri}?code={lastCode}&state={state}"); + }); + + var jwtHandler = new JsonWebTokenHandler(); + oidcEndpoints.MapPost("token", ([FromForm] string code) => + { + if (string.IsNullOrEmpty(lastCode) && code != lastCode) + { + return Results.BadRequest("Bad code"); + } + + return Results.Json(new + { + token_type = "Bearer", + scope = "openid profile", + expires_in = 3600, + id_token = jwtHandler.CreateToken(new SecurityTokenDescriptor + { + Issuer = issuer, + Audience = "s6BhdRkqt3", + Claims = new Dictionary + { + ["sub"] = "248289761001", + ["name"] = "Jane Doe", + }, + }), + }); + }).DisableAntiforgery(); + }); + }); + } +} + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/provenance.json b/eng/skill-evals/review-pull-request/fixtures/case-04/provenance.json new file mode 100644 index 000000000000..285509429ad1 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-04/provenance.json @@ -0,0 +1,131 @@ +{ + "repository": "dotnet/aspnetcore", + "pullRequest": 69721, + "sourceRoles": { + "mergeBase": "66e2adb4e0297e445686cb7a70d6c9aa84dcf3af", + "head": "153f8ef684a760e30b43609e54a9d22027dc6b62", + "baseTip": "66e2adb4e0297e445686cb7a70d6c9aa84dcf3af" + }, + "files": [ + { + "file": "mergeBase.source", + "sha256": "bf3e50473d2061531eb249607c88b04e66e2fffd45233f89ebe2f0f3dc77a851", + "sources": [ + { + "role": "mergeBase", + "commit": "66e2adb4e0297e445686cb7a70d6c9aa84dcf3af", + "path": "src/Components/test/testassets/Components.TestServer/RemoteAuthenticationStartup.cs", + "blob": "e0ea4303ef8ed4915e575f8a1a28d4bd8d3cae31", + "ranges": [ + [ + 1, + 107 + ] + ] + } + ] + }, + { + "file": "head.source", + "sha256": "3035f16602cd1b9dded50443993ad5665076a44190f19edce62ef4da5adf716b", + "sources": [ + { + "role": "head", + "commit": "153f8ef684a760e30b43609e54a9d22027dc6b62", + "path": "src/Components/test/testassets/Components.TestServer/RemoteMsalAuthenticationStartup.cs", + "blob": "6e4e181c18555c54edc082c8f247636957a2adc6", + "ranges": [ + [ + 1, + 102 + ] + ] + } + ] + }, + { + "file": "baseTip.source", + "sha256": "ecaafa0098b41c0079385e460596f80f6825379340fc44d27d636c3d88633f56", + "sources": [ + { + "role": "baseTip", + "commit": "66e2adb4e0297e445686cb7a70d6c9aa84dcf3af", + "path": "src/Components/WebAssembly/Authentication.Msal/src/Interop/AuthenticationService.ts", + "blob": "9f921f557fff57c06052bf35ce550d2788ce451c", + "ranges": [ + [ + 1, + 515 + ] + ] + } + ] + }, + { + "file": "context.source", + "sha256": "aec831d5ab8146c1d8a2f67b1d62c0a70f7359b94161f225b929a0a0e1a01ffa", + "sources": [ + { + "role": "head", + "commit": "153f8ef684a760e30b43609e54a9d22027dc6b62", + "path": "src/Components/test/E2ETest/Tests/RemoteMsalAuthenticationTest.cs", + "blob": "cac01175d2486ef842a4c5093f9160ee8fa633a0", + "ranges": [ + [ + 1, + 37 + ] + ] + }, + { + "role": "head", + "commit": "153f8ef684a760e30b43609e54a9d22027dc6b62", + "path": "src/Components/test/testassets/Components.TestServer/RazorComponents/RemoteMsalAuthenticationApp.razor", + "blob": "d9ec11afcc97013f3f3b59c56d4172e72f55a426", + "ranges": [ + [ + 1, + 30 + ] + ] + }, + { + "role": "head", + "commit": "153f8ef684a760e30b43609e54a9d22027dc6b62", + "path": "src/Components/test/testassets/Components.WasmMsalRemoteAuthentication/Program.cs", + "blob": "6962660265d363fcac65712941520f375e9b9b4a", + "ranges": [ + [ + 1, + 31 + ] + ] + }, + { + "role": "head", + "commit": "153f8ef684a760e30b43609e54a9d22027dc6b62", + "path": "src/Components/WebAssembly/Authentication.Msal/src/Interop/AuthenticationService.ts", + "blob": "61da3cba0ebbb29922c1549c7567594a46daee67", + "ranges": [ + [ + 472, + 484 + ], + [ + 220, + 262 + ] + ] + } + ] + }, + { + "file": "change.diff", + "sha256": "07956bec2265b888b034c331638e353a762f9f6bd7001f60d773498d3d8b89cf" + }, + { + "file": "case.source", + "sha256": "43116be262a937b2c1d227222b1cb45d1023c3f23c3ce29b73947f512794a2da" + } + ] +} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/baseTip.source b/eng/skill-evals/review-pull-request/fixtures/case-05/baseTip.source new file mode 100644 index 000000000000..cb0e32dbee4f --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-05/baseTip.source @@ -0,0 +1,160 @@ +=== baseTip 2a731a48bdbe8747100ce19282d8b96bb93b876e src/Components/Web.JS/src/Services/NavigationUtils.ts:1-158 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { WebRendererId } from '../Rendering/WebRendererId'; + +let interactiveRouterRendererId: WebRendererId | undefined = undefined; +let programmaticEnhancedNavigationHandler: typeof performProgrammaticEnhancedNavigation | undefined; +let enhancedNavigationListener: typeof notifyEnhancedNavigationListeners | undefined; + +/** + * Checks if a click event corresponds to an tag referencing a URL within the base href, and that interception + * isn't bypassed (e.g., by a 'download' attribute or the user holding a meta key while clicking). + * @param event The event that occurred + * @param callbackIfIntercepted A callback that will be invoked if the event corresponds to a click on an that can be intercepted. + */ +export function handleClickForNavigationInterception(event: MouseEvent, callbackIfIntercepted: (absoluteInternalHref: string) => void): void { + if (event.button !== 0 || eventHasSpecialKey(event)) { + // Don't stop ctrl/meta-click (etc) from opening links in new tabs/windows + return; + } + + if (event.defaultPrevented) { + return; + } + + // Intercept clicks on all elements where the href is within the URI space + // We must explicitly check if it has an 'href' attribute, because if it doesn't, the result might be null or an empty string depending on the browser + const anchorTarget = findAnchorTarget(event); + + if (anchorTarget && canProcessAnchor(anchorTarget)) { + const anchorHref = anchorTarget.getAttribute('href')!; + + const absoluteHref = toAbsoluteUri(anchorHref); + + if (isWithinBaseUriSpace(absoluteHref)) { + event.preventDefault(); + callbackIfIntercepted(absoluteHref); + } + } +} + +export function isWithinBaseUriSpace(href: string) { + const baseUriWithoutTrailingSlash = toBaseUriWithoutTrailingSlash(document.baseURI!); + const nextChar = href.charAt(baseUriWithoutTrailingSlash.length); + + return href.startsWith(baseUriWithoutTrailingSlash) + && (nextChar === '' || nextChar === '/' || nextChar === '?' || nextChar === '#'); +} + +export function isSamePageWithHash(oldUrl: string, newUrl: string): boolean { + const a = new URL(oldUrl); + const b = new URL(newUrl); + return a.origin === b.origin && a.pathname === b.pathname + && a.search === b.search && b.hash !== ''; +} + +export function isForSamePath(url1: string, url2: string) { + // We are going to use the scheme, host, port and path to determine if the two URLs are compatible. + // We do not account for the query string as we want to allow for the query string to change. + // (Blazor doesn't use the query string for routing purposes). + const parsedUrl1 = new URL(url1); + const parsedUrl2 = new URL(url2); + return parsedUrl1.protocol === parsedUrl2.protocol + && parsedUrl1.host === parsedUrl2.host + && parsedUrl1.port === parsedUrl2.port + && parsedUrl1.pathname === parsedUrl2.pathname; +} + +export function performScrollToElementOnTheSamePage(absoluteHref : string): void { + const hashIndex = absoluteHref.indexOf('#'); + if (hashIndex === absoluteHref.length - 1) { + return; + } + + const identifier = absoluteHref.substring(hashIndex + 1); + scrollToElement(identifier); +} + +export function scrollToElement(identifier: string): void { + document.getElementById(identifier)?.scrollIntoView(); +} + +export function attachEnhancedNavigationListener(listener: typeof enhancedNavigationListener) { + enhancedNavigationListener = listener; +} + +export function notifyEnhancedNavigationListeners(internalDestinationHref: string, interceptedLink: boolean) { + enhancedNavigationListener?.(internalDestinationHref, interceptedLink); +} + +export function hasProgrammaticEnhancedNavigationHandler(): boolean { + return programmaticEnhancedNavigationHandler !== undefined; +} + +export function attachProgrammaticEnhancedNavigationHandler(handler: typeof programmaticEnhancedNavigationHandler) { + programmaticEnhancedNavigationHandler = handler; +} + +export function performProgrammaticEnhancedNavigation(absoluteInternalHref: string, replace: boolean): void { + if (!programmaticEnhancedNavigationHandler) { + throw new Error('No enhanced programmatic navigation handler has been attached'); + } + + programmaticEnhancedNavigationHandler(absoluteInternalHref, replace); +} + +function toBaseUriWithoutTrailingSlash(baseUri: string) { + return baseUri.substring(0, baseUri.lastIndexOf('/')); +} + +let testAnchor: HTMLAnchorElement; +export function toAbsoluteUri(relativeUri: string): string { + testAnchor = testAnchor || document.createElement('a'); + testAnchor.href = relativeUri; + return testAnchor.href; +} + +function eventHasSpecialKey(event: MouseEvent) { + return event.ctrlKey || event.shiftKey || event.altKey || event.metaKey; +} + +function canProcessAnchor(anchorTarget: HTMLAnchorElement | SVGAElement) { + const targetAttributeValue = anchorTarget.getAttribute('target'); + const opensInSameFrame = !targetAttributeValue || targetAttributeValue === '_self'; + return opensInSameFrame && anchorTarget.hasAttribute('href') && !anchorTarget.hasAttribute('download'); +} + +function findAnchorTarget(event: MouseEvent): HTMLAnchorElement | SVGAElement | null { + const path = event.composedPath && event.composedPath(); + if (path) { + // This logic works with events that target elements within a shadow root, + // as long as the shadow mode is 'open'. For closed shadows, we can't possibly + // know what internal element was clicked. + for (let i = 0; i < path.length; i++) { + const candidate = path[i]; + if (candidate instanceof HTMLAnchorElement || candidate instanceof SVGAElement) { + return candidate; + } + } + } + return null; +} + +export function hasInteractiveRouter(): boolean { + return interactiveRouterRendererId !== undefined; +} + +export function getInteractiveRouterRendererId() : WebRendererId | undefined { + return interactiveRouterRendererId; +} + +export function setHasInteractiveRouter(rendererId: WebRendererId) { + if (interactiveRouterRendererId !== undefined && interactiveRouterRendererId !== rendererId) { + throw new Error('Only one interactive runtime may enable navigation interception at a time.'); + } + + interactiveRouterRendererId = rendererId; +} + diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/case.source b/eng/skill-evals/review-pull-request/fixtures/case-05/case.source new file mode 100644 index 000000000000..39049a02c31d --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-05/case.source @@ -0,0 +1,8 @@ +Repository: dotnet/aspnetcore +Pull request: https://github.com/dotnet/aspnetcore/pull/70299 +Head: 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 +Merge base: 2a731a48bdbe8747100ce19282d8b96bb93b876e +Base tip: 2a731a48bdbe8747100ce19282d8b96bb93b876e +The source files are excerpts, not a complete ready version-2 review bundle. +provenance.json maps every excerpt to its original source path and lines. +C1: After listener reordering, an unprevented anchor whose @onclick calls NavigationManager.NavigateTo can land on its href in Interactive WebAssembly but on the programmatic destination in Interactive Server. Is the different final navigation intended? diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/change.diff b/eng/skill-evals/review-pull-request/fixtures/case-05/change.diff new file mode 100644 index 000000000000..f62044083cb4 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-05/change.diff @@ -0,0 +1,83 @@ +diff --git a/src/Components/Web.JS/src/Services/NavigationEnhancement.ts b/src/Components/Web.JS/src/Services/NavigationEnhancement.ts +index 7bd29bee95..dd06e2cf5b 100644 +--- a/src/Components/Web.JS/src/Services/NavigationEnhancement.ts ++++ b/src/Components/Web.JS/src/Services/NavigationEnhancement.ts +@@ -4,6 +4,7 @@ + import { synchronizeDomContent } from '../Rendering/DomMerging/DomSync'; + import { attachProgrammaticEnhancedNavigationHandler, handleClickForNavigationInterception, hasInteractiveRouter, isForSamePath, notifyEnhancedNavigationListeners, performScrollToElementOnTheSamePage, isSamePageWithHash } from './NavigationUtils'; + import { scheduleScrollReset, ScrollResetSchedule } from '../Rendering/Renderer'; ++import { isDispatchingClick, setClickListenerRegisteredCallback } from '../Rendering/Events/EventDelegatorListeners'; + + /* + In effect, we have two separate client-side navigation mechanisms: +@@ -37,6 +38,8 @@ const acceptHeader = 'text/html; blazor-enhanced-nav=on'; + let currentEnhancedNavigationAbortController: AbortController | null; + let navigationEnhancementCallbacks: NavigationEnhancementCallbacks; + let performingEnhancedPageLoad: boolean; ++let clickListenerReorderPending = false; ++const capturedClickEvents = new Set(); + + // This gets initialized to the current URL when we load. + // After that, it gets updated every time we successfully complete a navigation. +@@ -59,6 +62,8 @@ export function hasNeverStartedAnyEnhancedPageLoad() { + + export function attachProgressivelyEnhancedNavigationListener(callbacks: NavigationEnhancementCallbacks) { + navigationEnhancementCallbacks = callbacks; ++ setClickListenerRegisteredCallback(onClickListenerRegistered); ++ window.addEventListener('click', onClickCapture, true); + document.addEventListener('click', onDocumentClick); + document.addEventListener('submit', onDocumentSubmit); + window.addEventListener('popstate', onPopState); +@@ -67,6 +72,10 @@ export function attachProgressivelyEnhancedNavigationListener(callbacks: Navigat + } + + export function detachProgressivelyEnhancedNavigationListener() { ++ setClickListenerRegisteredCallback(undefined); ++ clickListenerReorderPending = false; ++ window.removeEventListener('click', onClickCapture, true); ++ capturedClickEvents.clear(); + document.removeEventListener('click', onDocumentClick); + document.removeEventListener('submit', onDocumentSubmit); + window.removeEventListener('popstate', onPopState); +@@ -88,7 +97,41 @@ function performProgrammaticEnhancedNavigation(absoluteInternalHref: string, rep + performEnhancedPageLoad(absoluteInternalHref, /* interceptedLink */ false); + } + ++function onClickCapture(event: MouseEvent) { ++ // Window capture observes even native document listeners registered before Blazor starts. ++ capturedClickEvents.add(event); ++ // Microtasks can run between browser-invoked listeners, so release the event after the dispatch task. ++ setTimeout(() => capturedClickEvents.delete(event), 0); ++} ++ ++function isDispatchingBrowserClick(except?: MouseEvent): boolean { ++ for (const event of capturedClickEvents) { ++ if (event !== except && event.eventPhase !== Event.NONE) { ++ return true; ++ } ++ } ++ ++ return false; ++} ++ ++function onClickListenerRegistered(isDispatchingClick: boolean, currentClick?: MouseEvent) { ++ // Removing a listener during dispatch skips it for that click. Let it run before reordering. ++ if (isDispatchingClick || isDispatchingBrowserClick(currentClick)) { ++ clickListenerReorderPending = true; ++ return; ++ } ++ ++ clickListenerReorderPending = false; ++ document.removeEventListener('click', onDocumentClick); ++ document.addEventListener('click', onDocumentClick); ++} ++ + function onDocumentClick(event: MouseEvent) { ++ // A nested click must not remove this listener from an outer click's dispatch. ++ if (clickListenerReorderPending && !isDispatchingClick()) { ++ onClickListenerRegistered(false, event); ++ } ++ + if (hasInteractiveRouter()) { + return; + } diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/context.source b/eng/skill-evals/review-pull-request/fixtures/case-05/context.source new file mode 100644 index 000000000000..06958e3203c0 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-05/context.source @@ -0,0 +1,87 @@ +=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/test/testassets/TestContentPackage/InteractiveNavigationComponent.razor:1-41 === +@inject NavigationManager Navigation + + +Navigate with an unprevented link +Navigate with a prevented link + +
+ +
+ +
+ +
+ + +@code { + private void NavigateToAnotherPage() + { + Navigation.NavigateTo("nav"); + } + + private void RefreshWithNavigateTo() + { + Navigation.NavigateTo(Navigation.Uri, replace: true); + } + + private void ReloadWithNavigateTo() + { + Navigation.NavigateTo(Navigation.Uri, forceLoad: true, replace: true); + } + + private void RefreshWithRefresh() + { + Navigation.Refresh(); + } + + private void ReloadWithRefresh() + { + Navigation.Refresh(forceReload: true); + } +} + +=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Rendering/Events/EventDelegatorListeners.ts:1-33 === +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +let clickListenerRegisteredCallback: ((isDispatchingClick: boolean) => void) | undefined; +let clickDispatchDepth = 0; + +export function setClickListenerRegisteredCallback(callback: typeof clickListenerRegisteredCallback): void { + clickListenerRegisteredCallback = callback; +} + +export function isDispatchingClick(): boolean { + return clickDispatchDepth > 0; +} + +export function notifyGlobalListenerAdded(eventName: string): void { + if (eventName === 'click') { + clickListenerRegisteredCallback?.(clickDispatchDepth > 0); + } +} + +export function dispatchGlobalEvent(event: Event, listener: EventListener): void { + if (event.type !== 'click') { + listener(event); + return; + } + + clickDispatchDepth++; + try { + listener(event); + } finally { + clickDispatchDepth--; + } +} + + +=== Existing feedback discussion_r4487936812 at commit 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 === +**[P2] [QUESTION] Confirm whether `` with `@onclick` calling `NavigateTo` (without `@onclick:preventDefault`) should differ between Interactive WebAssembly and Interactive Server** + +Because `onDocumentClick` is now moved after the renderer's click delegate, consider a link such as `` (without `@onclick:preventDefault`) on a page where enhanced navigation is active: +- **Before this PR:** `onDocumentClick` ran first (`/other`), and then the `@onclick` handler's `Nav.NavigateTo("/counter")` ran second and won in both Interactive WebAssembly and Interactive Server (landing on `/counter`). +- **With this PR:** In Interactive WebAssembly, `@onclick` runs synchronously during the click event and starts programmatic enhanced navigation to `/counter`, and then `onDocumentClick` runs second on the un-prevented ``, aborting `/counter` (`NavigationEnhancement.ts:226`) and landing on `/other` (matching native browser order where an un-prevented link's default action runs after click handlers). However, in Interactive Server, `@onclick` runs asynchronously over SignalR after `onDocumentClick`, so `/counter` still wins. + +Is this Interactive WebAssembly (`/other`) vs. Interactive Server (`/counter`) difference intended when `@onclick` calls `NavigateTo` without `@onclick:preventDefault` (for example under `InteractiveAuto`), or should programmatic enhanced navigation initiated during the click take precedence? diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/head.source b/eng/skill-evals/review-pull-request/fixtures/case-05/head.source new file mode 100644 index 000000000000..8dc71d74ba59 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-05/head.source @@ -0,0 +1,122 @@ +=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:63-72 === +export function attachProgressivelyEnhancedNavigationListener(callbacks: NavigationEnhancementCallbacks) { + navigationEnhancementCallbacks = callbacks; + setClickListenerRegisteredCallback(onClickListenerRegistered); + window.addEventListener('click', onClickCapture, true); + document.addEventListener('click', onDocumentClick); + document.addEventListener('submit', onDocumentSubmit); + window.addEventListener('popstate', onPopState); + + attachProgrammaticEnhancedNavigationHandler(performProgrammaticEnhancedNavigation); +} + +=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:84-98 === +function performProgrammaticEnhancedNavigation(absoluteInternalHref: string, replace: boolean) : void { + const originalLocation = location.href; + + if (replace) { + history.replaceState(null, /* ignored title */ '', absoluteInternalHref); + } else { + history.pushState(null, /* ignored title */ '', absoluteInternalHref); + } + + if (!isForSamePath(absoluteInternalHref, originalLocation)) { + scheduleScrollReset(ScrollResetSchedule.AfterDocumentUpdate); + } + + performEnhancedPageLoad(absoluteInternalHref, /* interceptedLink */ false); +} + +=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:129-159 === +function onDocumentClick(event: MouseEvent) { + // A nested click must not remove this listener from an outer click's dispatch. + if (clickListenerReorderPending && !isDispatchingClick()) { + onClickListenerRegistered(false, event); + } + + if (hasInteractiveRouter()) { + return; + } + + if (event.target instanceof Element && !enhancedNavigationIsEnabledForElement(event.target)) { + return; + } + + handleClickForNavigationInterception(event, absoluteInternalHref => { + const originalLocation = location.href; + + const shouldScrollToHash = isSamePageWithHash(originalLocation, absoluteInternalHref); + history.pushState(null, /* ignored title */ '', absoluteInternalHref); + + if (shouldScrollToHash) { + performScrollToElementOnTheSamePage(absoluteInternalHref); + } else { + const isSelfNavigation = isForSamePath(absoluteInternalHref, originalLocation); + performEnhancedPageLoad(absoluteInternalHref, /* interceptedLink */ true); + if (!isSelfNavigation) { + scheduleScrollReset(ScrollResetSchedule.AfterDocumentUpdate); + } + } + }); +} + +=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:100-105 === +function onClickCapture(event: MouseEvent) { + // Window capture observes even native document listeners registered before Blazor starts. + capturedClickEvents.add(event); + // Microtasks can run between browser-invoked listeners, so release the event after the dispatch task. + setTimeout(() => capturedClickEvents.delete(event), 0); +} + +=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:107-115 === +function isDispatchingBrowserClick(except?: MouseEvent): boolean { + for (const event of capturedClickEvents) { + if (event !== except && event.eventPhase !== Event.NONE) { + return true; + } + } + + return false; +} + +=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:117-127 === +function onClickListenerRegistered(isDispatchingClick: boolean, currentClick?: MouseEvent) { + // Removing a listener during dispatch skips it for that click. Let it run before reordering. + if (isDispatchingClick || isDispatchingBrowserClick(currentClick)) { + clickListenerReorderPending = true; + return; + } + + clickListenerReorderPending = false; + document.removeEventListener('click', onDocumentClick); + document.addEventListener('click', onDocumentClick); +} + +=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:243-269 === +export async function performEnhancedPageLoad(internalDestinationHref: string, interceptedLink: boolean, fetchOptions?: RequestInit, treatAsRedirectionFromMethod?: 'get' | 'post', changeUrl = true) { + performingEnhancedPageLoad = true; + + // First, stop any preceding enhanced page load + currentEnhancedNavigationAbortController?.abort(); + + // Notify any interactive runtimes that an enhanced navigation is starting + notifyEnhancedNavigationListeners(internalDestinationHref, interceptedLink); + + // Notify handlers that enhanced navigation is starting + navigationEnhancementCallbacks.enhancedNavigationStarted(); + + // Now request the new page via fetch, and a special header that tells the server we want it to inject + // framing boundaries to distinguish the initial document and each subsequent streaming SSR update. + currentEnhancedNavigationAbortController = new AbortController(); + const abortSignal = currentEnhancedNavigationAbortController.signal; + const responsePromise = fetch(internalDestinationHref, Object.assign({ + signal: abortSignal, + mode: 'no-cors', // If there's a redirection to an external origin, even if it enables CORS, we don't want to receive its content and patch it into our DOM on this origin + headers: { + // Because of no-cors, we can only send CORS-safelisted headers, so communicate the info about + // enhanced nav as a MIME type parameter + 'accept': acceptHeader, + }, + }, fetchOptions)); + let isNonRedirectedPostToADifferentUrlMessage: string | null = null; + await getResponsePartsWithFraming( diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/mergeBase.source b/eng/skill-evals/review-pull-request/fixtures/case-05/mergeBase.source new file mode 100644 index 000000000000..26e2c9001c9e --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-05/mergeBase.source @@ -0,0 +1,83 @@ +=== mergeBase 2a731a48bdbe8747100ce19282d8b96bb93b876e src/Components/Web.JS/src/Services/NavigationEnhancement.ts:60-67 === +export function attachProgressivelyEnhancedNavigationListener(callbacks: NavigationEnhancementCallbacks) { + navigationEnhancementCallbacks = callbacks; + document.addEventListener('click', onDocumentClick); + document.addEventListener('submit', onDocumentSubmit); + window.addEventListener('popstate', onPopState); + + attachProgrammaticEnhancedNavigationHandler(performProgrammaticEnhancedNavigation); +} + +=== mergeBase 2a731a48bdbe8747100ce19282d8b96bb93b876e src/Components/Web.JS/src/Services/NavigationEnhancement.ts:75-89 === +function performProgrammaticEnhancedNavigation(absoluteInternalHref: string, replace: boolean) : void { + const originalLocation = location.href; + + if (replace) { + history.replaceState(null, /* ignored title */ '', absoluteInternalHref); + } else { + history.pushState(null, /* ignored title */ '', absoluteInternalHref); + } + + if (!isForSamePath(absoluteInternalHref, originalLocation)) { + scheduleScrollReset(ScrollResetSchedule.AfterDocumentUpdate); + } + + performEnhancedPageLoad(absoluteInternalHref, /* interceptedLink */ false); +} + +=== mergeBase 2a731a48bdbe8747100ce19282d8b96bb93b876e src/Components/Web.JS/src/Services/NavigationEnhancement.ts:91-116 === +function onDocumentClick(event: MouseEvent) { + if (hasInteractiveRouter()) { + return; + } + + if (event.target instanceof Element && !enhancedNavigationIsEnabledForElement(event.target)) { + return; + } + + handleClickForNavigationInterception(event, absoluteInternalHref => { + const originalLocation = location.href; + + const shouldScrollToHash = isSamePageWithHash(originalLocation, absoluteInternalHref); + history.pushState(null, /* ignored title */ '', absoluteInternalHref); + + if (shouldScrollToHash) { + performScrollToElementOnTheSamePage(absoluteInternalHref); + } else { + const isSelfNavigation = isForSamePath(absoluteInternalHref, originalLocation); + performEnhancedPageLoad(absoluteInternalHref, /* interceptedLink */ true); + if (!isSelfNavigation) { + scheduleScrollReset(ScrollResetSchedule.AfterDocumentUpdate); + } + } + }); +} + +=== mergeBase 2a731a48bdbe8747100ce19282d8b96bb93b876e src/Components/Web.JS/src/Services/NavigationEnhancement.ts:200-226 === +export async function performEnhancedPageLoad(internalDestinationHref: string, interceptedLink: boolean, fetchOptions?: RequestInit, treatAsRedirectionFromMethod?: 'get' | 'post', changeUrl = true) { + performingEnhancedPageLoad = true; + + // First, stop any preceding enhanced page load + currentEnhancedNavigationAbortController?.abort(); + + // Notify any interactive runtimes that an enhanced navigation is starting + notifyEnhancedNavigationListeners(internalDestinationHref, interceptedLink); + + // Notify handlers that enhanced navigation is starting + navigationEnhancementCallbacks.enhancedNavigationStarted(); + + // Now request the new page via fetch, and a special header that tells the server we want it to inject + // framing boundaries to distinguish the initial document and each subsequent streaming SSR update. + currentEnhancedNavigationAbortController = new AbortController(); + const abortSignal = currentEnhancedNavigationAbortController.signal; + const responsePromise = fetch(internalDestinationHref, Object.assign({ + signal: abortSignal, + mode: 'no-cors', // If there's a redirection to an external origin, even if it enables CORS, we don't want to receive its content and patch it into our DOM on this origin + headers: { + // Because of no-cors, we can only send CORS-safelisted headers, so communicate the info about + // enhanced nav as a MIME type parameter + 'accept': acceptHeader, + }, + }, fetchOptions)); + let isNonRedirectedPostToADifferentUrlMessage: string | null = null; + await getResponsePartsWithFraming( diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/provenance.json b/eng/skill-evals/review-pull-request/fixtures/case-05/provenance.json new file mode 100644 index 000000000000..32289e60edb5 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-05/provenance.json @@ -0,0 +1,145 @@ +{ + "repository": "dotnet/aspnetcore", + "pullRequest": 70299, + "sourceRoles": { + "mergeBase": "2a731a48bdbe8747100ce19282d8b96bb93b876e", + "head": "0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6", + "baseTip": "2a731a48bdbe8747100ce19282d8b96bb93b876e" + }, + "files": [ + { + "file": "mergeBase.source", + "sha256": "19d83bf27940b4b66a5957ce363efd9c17c1d4757788b77891aa708cc5c01574", + "sources": [ + { + "role": "mergeBase", + "commit": "2a731a48bdbe8747100ce19282d8b96bb93b876e", + "path": "src/Components/Web.JS/src/Services/NavigationEnhancement.ts", + "blob": "7bd29bee95bb154787994017aceb0d29960ebebb", + "ranges": [ + [ + 60, + 67 + ], + [ + 75, + 89 + ], + [ + 91, + 116 + ], + [ + 200, + 226 + ] + ] + } + ] + }, + { + "file": "head.source", + "sha256": "2d34778b27f6c9fab6ae76e225d9bc1bd335b5422d54a6f94f0bb2c0ee4e25d0", + "sources": [ + { + "role": "head", + "commit": "0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6", + "path": "src/Components/Web.JS/src/Services/NavigationEnhancement.ts", + "blob": "dd06e2cf5beb414f8760fabfe97424414a032220", + "ranges": [ + [ + 63, + 72 + ], + [ + 84, + 98 + ], + [ + 129, + 159 + ], + [ + 100, + 105 + ], + [ + 107, + 115 + ], + [ + 117, + 127 + ], + [ + 243, + 269 + ] + ] + } + ] + }, + { + "file": "baseTip.source", + "sha256": "5eac5e1629c5d668ca00cd19a8e9ee49f11393e210323de6f78d97e274ac4d3a", + "sources": [ + { + "role": "baseTip", + "commit": "2a731a48bdbe8747100ce19282d8b96bb93b876e", + "path": "src/Components/Web.JS/src/Services/NavigationUtils.ts", + "blob": "9976eafc898cdc52039a75029da0c8dcfcdb6fb0", + "ranges": [ + [ + 1, + 158 + ] + ] + } + ] + }, + { + "file": "context.source", + "sha256": "f8f95a6e4bf3d5556b291e3294f880939669309ed03a29bc8dd0c6261bc58aaa", + "sources": [ + { + "role": "head", + "commit": "0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6", + "path": "src/Components/test/testassets/TestContentPackage/InteractiveNavigationComponent.razor", + "blob": "71217ca2ee717f7a6e9abd1adb7df6369413f2c1", + "ranges": [ + [ + 1, + 41 + ] + ] + }, + { + "role": "head", + "commit": "0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6", + "path": "src/Components/Web.JS/src/Rendering/Events/EventDelegatorListeners.ts", + "blob": "6b3737d7c0fecb9b8ae6805fe9744cb149e4c04e", + "ranges": [ + [ + 1, + 33 + ] + ] + } + ], + "feedback": { + "url": "https://github.com/dotnet/aspnetcore/pull/70299#discussion_r4487936812", + "commit": "0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6", + "updatedAt": "2026-11-06T01:08:38Z", + "role": "frozen existing feedback, not a target contract or runtime trace" + } + }, + { + "file": "change.diff", + "sha256": "eb4815b07d61137eead6c4526cafa73e5c352547fe00acb53297b9c4b419e5e9" + }, + { + "file": "case.source", + "sha256": "7e72e1a5ecbfcc32c1be9ac2bbdd3bc2a66291542ab2baef7dca26efa02f122a" + } + ] +} diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/Dependencies.cs.source b/eng/skill-evals/review-pull-request/fixtures/case-06/baseTip.source similarity index 100% rename from eng/skill-evals/review-pull-request/fixtures/catch-policy/Dependencies.cs.source rename to eng/skill-evals/review-pull-request/fixtures/case-06/baseTip.source diff --git a/eng/skill-evals/review-pull-request/fixtures/case-06/case.source b/eng/skill-evals/review-pull-request/fixtures/case-06/case.source new file mode 100644 index 000000000000..bf9bd1ffa2c6 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-06/case.source @@ -0,0 +1 @@ +C1: The added inner catch prevents a diagnostic sink failure from reaching the caller of SendMessageAsync. Remove the inner catch so the sink exception propagates. diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/ConversationEngine.diff b/eng/skill-evals/review-pull-request/fixtures/case-06/change.diff similarity index 100% rename from eng/skill-evals/review-pull-request/fixtures/catch-policy/ConversationEngine.diff rename to eng/skill-evals/review-pull-request/fixtures/case-06/change.diff diff --git a/eng/skill-evals/review-pull-request/fixtures/case-06/context.source b/eng/skill-evals/review-pull-request/fixtures/case-06/context.source new file mode 100644 index 000000000000..8418afe3187b --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-06/context.source @@ -0,0 +1,40 @@ +Selected scenario +Construct ConversationEngine with FailingClient and ThrowingDiagnosticSink. +Register StatusObserver.OnStatusChanged, then await SendMessageAsync. +These are the only implementations in scope for this bounded scenario. + +Originating issue +Report conversation-processing failures through the configured diagnostic sink. + +Target-base contract +Processing failures are exposed in Error and the Error status; notify status observers. + +PR rationale and test +The author says the nested catch preserves successful task completion. +A new test awaits SendMessageAsync and asserts that Error is the client's Failure. +Its complete implementation follows below. + +Existing feedback +None. + +using System.Threading.Tasks; +using Xunit; + +public class ConversationEngineTests +{ + [Fact] + public async Task ProcessingFailureIsExposed() + { + var client = new FailingClient(); + var sink = new ThrowingDiagnosticSink(); + var observer = new StatusObserver(); + var engine = new ConversationEngine(client, sink); + engine.StatusChanged += observer.OnStatusChanged; + + await engine.SendMessageAsync(); + + Assert.Same(client.Failure, engine.Error); + Assert.Equal("Error", engine.Status); + Assert.Equal(1, observer.NotificationCount); + } +} diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/head/ConversationEngine.cs.source b/eng/skill-evals/review-pull-request/fixtures/case-06/head.source similarity index 100% rename from eng/skill-evals/review-pull-request/fixtures/catch-policy/head/ConversationEngine.cs.source rename to eng/skill-evals/review-pull-request/fixtures/case-06/head.source diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/old/ConversationEngine.cs.source b/eng/skill-evals/review-pull-request/fixtures/case-06/mergeBase.source similarity index 100% rename from eng/skill-evals/review-pull-request/fixtures/catch-policy/old/ConversationEngine.cs.source rename to eng/skill-evals/review-pull-request/fixtures/case-06/mergeBase.source diff --git a/eng/skill-evals/review-pull-request/fixtures/case-06/provenance.json b/eng/skill-evals/review-pull-request/fixtures/case-06/provenance.json new file mode 100644 index 000000000000..2fddc4ea662d --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/case-06/provenance.json @@ -0,0 +1,36 @@ +{ + "repository": "dotnet/aspnetcore", + "pullRequest": 70312, + "fixtureKind": "synthetic public catch-policy example, not framework production source", + "revision": "4bb1a49fbbf7c217286f289cf975019491c83f16", + "transformations": [ + "Remove explicit suppression-policy absence hints.", + "Combine scenario and head test as context." + ], + "files": [ + { + "file": "mergeBase.source", + "sha256": "a41b5ee85d9f19c0b1002d988efe4adf5c479acba95e000f453dba7bcc715bb3" + }, + { + "file": "head.source", + "sha256": "c049fc9b1c04f4c87282649fa3837f07432782c83977d8baca29f0471b26504e" + }, + { + "file": "baseTip.source", + "sha256": "e1621fa56245d23a6d234585cfc2da3f54dd148ee9a7ec2c7689000373b0046c" + }, + { + "file": "context.source", + "sha256": "3ad5fafd5ac86b76d82480d12cf889a520631431276567fb1bb45f069944b90b" + }, + { + "file": "change.diff", + "sha256": "e1765f241bf72190a0fe40b839a62b29b3b78dc1e1f89e293bc712dcecfbce44" + }, + { + "file": "case.source", + "sha256": "71d7ca9d0dae95d9bba4e689d8979e1784db68c85a5bfcb65d82403e8f9d7ddd" + } + ] +} diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/ConversationEngineTests.cs.source b/eng/skill-evals/review-pull-request/fixtures/catch-policy/ConversationEngineTests.cs.source deleted file mode 100644 index 43fb5be02639..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/catch-policy/ConversationEngineTests.cs.source +++ /dev/null @@ -1,21 +0,0 @@ -using System.Threading.Tasks; -using Xunit; - -public class ConversationEngineTests -{ - [Fact] - public async Task ProcessingFailureIsExposed() - { - var client = new FailingClient(); - var sink = new ThrowingDiagnosticSink(); - var observer = new StatusObserver(); - var engine = new ConversationEngine(client, sink); - engine.StatusChanged += observer.OnStatusChanged; - - await engine.SendMessageAsync(); - - Assert.Same(client.Failure, engine.Error); - Assert.Equal("Error", engine.Status); - Assert.Equal(1, observer.NotificationCount); - } -} diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/best-effort.txt b/eng/skill-evals/review-pull-request/fixtures/catch-policy/best-effort.txt deleted file mode 100644 index 9810331939f3..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/catch-policy/best-effort.txt +++ /dev/null @@ -1,20 +0,0 @@ -Selected scenario -Construct ConversationEngine with FailingClient and ThrowingDiagnosticSink. -Register StatusObserver.OnStatusChanged, then await SendMessageAsync. -These are the only implementations in scope for this bounded scenario. - -Originating issue -Report conversation-processing failures through the configured diagnostic sink. - -Target-base contract -Processing failures are exposed in Error and the Error status. -Error reporting is best-effort: suppress diagnostic sink failures, preserve the -processing failure in Error, notify status observers, and complete the task normally. - -PR rationale and test -The author says the nested catch preserves successful task completion. -A new test awaits SendMessageAsync and asserts that Error is the client's Failure. -Its complete implementation is in ConversationEngineTests.cs.source. - -Existing feedback -None. diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/existing-question.txt b/eng/skill-evals/review-pull-request/fixtures/catch-policy/existing-question.txt deleted file mode 100644 index 180eb7f7dd74..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/catch-policy/existing-question.txt +++ /dev/null @@ -1,22 +0,0 @@ -Selected scenario -Construct ConversationEngine with FailingClient and ThrowingDiagnosticSink. -Register StatusObserver.OnStatusChanged, then await SendMessageAsync. -These are the only implementations in scope for this bounded scenario. - -Originating issue -Report conversation-processing failures through the configured diagnostic sink. - -Target-base contract -Processing failures are exposed in Error and the Error status; notify status observers. -No target-base policy specifies whether diagnostic sink failures must propagate or -be suppressed. No additional primary contract evidence is available. - -PR rationale and test -The author says the nested catch preserves successful task completion. -A new test awaits SendMessageAsync and asserts that Error is the client's Failure. -Its complete implementation is in ConversationEngineTests.cs.source. - -Existing feedback -Thread feedback-17, on the newly added inner catch in ConversationEngine.cs: -"We should avoid using an empty handler. Why is it needed?" -No reply or resolution is available. diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/nonthrowing.txt b/eng/skill-evals/review-pull-request/fixtures/catch-policy/nonthrowing.txt deleted file mode 100644 index ef162676fe48..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/catch-policy/nonthrowing.txt +++ /dev/null @@ -1,24 +0,0 @@ -Selected scenario -Construct ConversationEngine with FailingClient and RecordingDiagnosticSink. -Register StatusObserver.OnStatusChanged, then await SendMessageAsync. -These are the only implementations in scope for this bounded scenario. -ThrowingDiagnosticSink is not registered, selected, or called in this scenario. - -Originating issue -Report conversation-processing failures through the configured diagnostic sink. - -Target-base contract -Processing failures are exposed in Error and the Error status. -If the configured diagnostic sink fails during error reporting, the returned task -must fault with that sink failure. This applies to newly introduced reporting call -sites as well as existing ones. - -PR rationale and test -The author says the nested catch preserves successful task completion. -A new test awaits SendMessageAsync and asserts that Error is the client's Failure. -Its complete implementation is in ConversationEngineTests.cs.source. That separate -test configures ThrowingDiagnosticSink, not the RecordingDiagnosticSink selected -above. It is not evidence that the throwing sink is selected in this scenario. - -Existing feedback -None. diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/propagation.txt b/eng/skill-evals/review-pull-request/fixtures/catch-policy/propagation.txt deleted file mode 100644 index ea905f90c5a1..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/catch-policy/propagation.txt +++ /dev/null @@ -1,21 +0,0 @@ -Selected scenario -Construct ConversationEngine with FailingClient and ThrowingDiagnosticSink. -Register StatusObserver.OnStatusChanged, then await SendMessageAsync. -These are the only implementations in scope for this bounded scenario. - -Originating issue -Report conversation-processing failures through the configured diagnostic sink. - -Target-base contract -Processing failures are exposed in Error and the Error status. -If the configured diagnostic sink fails during error reporting, the returned task -must fault with that sink failure. This applies to newly introduced reporting call -sites as well as existing ones. - -PR rationale and test -The author says the nested catch preserves successful task completion. -A new test awaits SendMessageAsync and asserts that Error is the client's Failure. -Its complete implementation is in ConversationEngineTests.cs.source. - -Existing feedback -None. diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/unspecified.txt b/eng/skill-evals/review-pull-request/fixtures/catch-policy/unspecified.txt deleted file mode 100644 index 253934caaa5f..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/catch-policy/unspecified.txt +++ /dev/null @@ -1,20 +0,0 @@ -Selected scenario -Construct ConversationEngine with FailingClient and ThrowingDiagnosticSink. -Register StatusObserver.OnStatusChanged, then await SendMessageAsync. -These are the only implementations in scope for this bounded scenario. - -Originating issue -Report conversation-processing failures through the configured diagnostic sink. - -Target-base contract -Processing failures are exposed in Error and the Error status; notify status observers. -No target-base policy specifies whether diagnostic sink failures must propagate or -be suppressed. No additional primary contract evidence is available. - -PR rationale and test -The author says the nested catch preserves successful task completion. -A new test awaits SendMessageAsync and asserts that Error is the client's Failure. -Its complete implementation is in ConversationEngineTests.cs.source. - -Existing feedback -None. diff --git a/eng/skill-evals/review-smoke.experiment.yaml b/eng/skill-evals/review-smoke.experiment.yaml new file mode 100644 index 000000000000..045edaf91133 --- /dev/null +++ b/eng/skill-evals/review-smoke.experiment.yaml @@ -0,0 +1,25 @@ +name: review-smoke +evals: + - review-pull-request/eval.vally.yaml + +overrides: + runs: 1 + +vary: + - /environment/skills + - /environment/files + +baseline: baseline +variants: + baseline: + environment: + skills: [] + skilled: + environment: + skills: + - ../../.github/skills/review-pull-request + files: + - { src: ../../docs/CrossCuttingGuidance.md, dest: docs/CrossCuttingGuidance.md } + - { src: ../../docs/BlazorComponentsGuidance.md, dest: docs/BlazorComponentsGuidance.md } + - { src: ../../.github/agents/review-candidate-verifier.agent.md, dest: .github/agents/review-candidate-verifier.agent.md } + - { src: ../../.github/agents/review-guide-worker.agent.md, dest: .github/agents/review-guide-worker.agent.md } diff --git a/eng/skill-evals/review-vs-baseline.experiment.yaml b/eng/skill-evals/review-vs-baseline.experiment.yaml new file mode 100644 index 000000000000..9e880d3afb26 --- /dev/null +++ b/eng/skill-evals/review-vs-baseline.experiment.yaml @@ -0,0 +1,23 @@ +name: review-vs-baseline +evals: + - review-pull-request/eval.vally.yaml + +# The reviewer treatment includes its skill and the profiles referenced by it. +vary: + - /environment/skills + - /environment/files + +baseline: baseline +variants: + baseline: + environment: + skills: [] + skilled: + environment: + skills: + - ../../.github/skills/review-pull-request + files: + - { src: ../../docs/CrossCuttingGuidance.md, dest: docs/CrossCuttingGuidance.md } + - { src: ../../docs/BlazorComponentsGuidance.md, dest: docs/BlazorComponentsGuidance.md } + - { src: ../../.github/agents/review-candidate-verifier.agent.md, dest: .github/agents/review-candidate-verifier.agent.md } + - { src: ../../.github/agents/review-guide-worker.agent.md, dest: .github/agents/review-guide-worker.agent.md } diff --git a/eng/skill-evals/run.ps1 b/eng/skill-evals/run.ps1 index aa35048a393e..9ca709f96e19 100644 --- a/eng/skill-evals/run.ps1 +++ b/eng/skill-evals/run.ps1 @@ -6,6 +6,8 @@ param( [string]$Eval, + [string]$Suite, + [string]$Experiment, [string]$OutputDirectory, @@ -54,6 +56,18 @@ $repoRoot = if ($Root) { (Resolve-Path (Join-Path $PSScriptRoot '../..')).Path } $evalRoot = Join-Path $repoRoot 'eng/skill-evals' +if ($Suite) { + if ($Suite -notmatch '^[A-Za-z0-9][A-Za-z0-9._-]*$' -or $Suite.Contains('..')) { + throw "Invalid suite name '$Suite'." + } + if ($Eval) { + throw 'Specify either -Suite or -Eval, not both.' + } + $Eval = Join-Path $evalRoot "$Suite/eval.vally.yaml" + if (-not (Test-Path $Eval -PathType Leaf)) { + throw "Missing suite specification at '$Eval'." + } +} $runtimeRoot = Join-Path $repoRoot '.github/skills' $standardExperiment = Join-Path $evalRoot 'skills-vs-baseline.experiment.yaml' $smokeExperiment = Join-Path $evalRoot 'skills-smoke.experiment.yaml' @@ -69,6 +83,8 @@ $selectedExperiment = if ($hasExplicitExperiment) { $standardExperiment } $script:vallyInitialized = $false +$reviewExperiment = Join-Path $evalRoot 'review-vs-baseline.experiment.yaml' +$reviewSmokeExperiment = Join-Path $evalRoot 'review-smoke.experiment.yaml' function Resolve-Eval { if (-not $Eval) { @@ -94,6 +110,14 @@ function Get-EvalSpecs { ) } +if ($Eval -and -not $Suite) { + $resolvedSelection = Resolve-Eval + $relativeSelection = [IO.Path]::GetRelativePath($evalRoot, $resolvedSelection).Replace('\', '/') + if ($relativeSelection -match '^[^/]+/eval\.vally\.yaml$') { + $Suite = Split-Path (Split-Path $resolvedSelection -Parent) -Leaf + } +} + function Invoke-Vally { param([string[]]$VallyArguments) @@ -162,13 +186,17 @@ function Invoke-VallyIsolated { function Invoke-VallyExperimentDryRun { param([string]$ExperimentPath) - Invoke-VallyIsolated @( + $vallyArguments = @( 'experiment', 'run', $ExperimentPath, '--compare', '--dry-run', '--output-dir', 'plan-results' ) + if ($Suite) { + $vallyArguments += @('--eval-filter', "$Suite/eval.vally.yaml") + } + Invoke-VallyIsolated $vallyArguments } function Get-TrackedFiles { @@ -199,10 +227,15 @@ function Get-LayoutErrors { $errors.Add("Missing smoke experiment: $smokeExperiment") } + $layoutEvalRoot = if ($Suite) { Join-Path $evalRoot $Suite } else { $evalRoot } $standardSpecs = @( - Get-ChildItem $evalRoot -Directory -ErrorAction SilentlyContinue | - ForEach-Object { Join-Path $_.FullName 'eval.vally.yaml' } | - Where-Object { Test-Path $_ -PathType Leaf } + if ($Suite) { + $Eval + } else { + Get-ChildItem $evalRoot -Directory -ErrorAction SilentlyContinue | + ForEach-Object { Join-Path $_.FullName 'eval.vally.yaml' } | + Where-Object { Test-Path $_ -PathType Leaf } + } ) if ($standardSpecs.Count -eq 0) { $errors.Add("No standard */eval.vally.yaml specs were found under '$evalRoot'.") @@ -210,7 +243,8 @@ function Get-LayoutErrors { foreach ($spec in $standardSpecs) { $skillName = Split-Path (Split-Path $spec -Parent) -Leaf $skillFile = Join-Path $runtimeRoot "$skillName/SKILL.md" - if (-not (Test-Path $skillFile -PathType Leaf)) { + if ($skillName -ne 'review-candidate-verifier' -and + -not (Test-Path $skillFile -PathType Leaf)) { $errors.Add("$spec has no matching runtime skill at '$skillFile'.") } } @@ -227,14 +261,14 @@ function Get-LayoutErrors { } $tracked = Get-TrackedFiles - foreach ($spec in Get-ChildItem $evalRoot -Recurse -File -Filter '*.vally.yaml') { + foreach ($spec in Get-ChildItem $layoutEvalRoot -Recurse -File -Filter '*.vally.yaml') { $relative = [IO.Path]::GetRelativePath($repoRoot, $spec.FullName).Replace('\', '/') if (-not $tracked.Contains($relative)) { $errors.Add("$relative is not tracked by git and will not exist in CI.") } } - foreach ($fixtures in Get-ChildItem $evalRoot -Recurse -Directory | + foreach ($fixtures in Get-ChildItem $layoutEvalRoot -Recurse -Directory | Where-Object Name -eq 'fixtures') { $items = @(Get-ChildItem $fixtures.FullName -Recurse -Force) $fixtureFiles = @($items | Where-Object { -not $_.PSIsContainer }) @@ -272,11 +306,20 @@ switch ($Action) { 'Validate' { Invoke-LayoutValidation Invoke-VallyLint - if ($hasExplicitExperiment) { + if ($Suite -eq 'review-candidate-verifier') { + # Component specs have no skill treatment. Lint validates their schema. + } elseif ($hasExplicitExperiment) { Invoke-VallyExperimentDryRun $selectedExperiment + } elseif ($Suite -eq 'review-pull-request' -and (Test-Path $reviewExperiment)) { + Invoke-VallyExperimentDryRun $reviewExperiment + Invoke-VallyExperimentDryRun $reviewSmokeExperiment } else { Invoke-VallyExperimentDryRun $standardExperiment Invoke-VallyExperimentDryRun $smokeExperiment + if (Test-Path $reviewExperiment) { + Invoke-VallyExperimentDryRun $reviewExperiment + Invoke-VallyExperimentDryRun $reviewSmokeExperiment + } } } 'Test' { @@ -285,6 +328,15 @@ switch ($Action) { & (Join-Path $PSScriptRoot 'test_assert_results.ps1') & (Join-Path $PSScriptRoot 'test_stage_run.ps1') & (Join-Path $PSScriptRoot 'test_workflow.ps1') + if (-not $Suite -or $Suite -eq 'review-pull-request') { + & (Join-Path $PSScriptRoot 'tests/test_review_fixtures.ps1') + } + if (Test-Path (Join-Path $PSScriptRoot 'test_disposition.mjs')) { + & node --test (Join-Path $PSScriptRoot 'test_disposition.mjs') + if ($LASTEXITCODE -ne 0) { + throw 'Disposition grader self-test failed.' + } + } } 'Lint' { Invoke-VallyLint @@ -301,7 +353,39 @@ switch ($Action) { Join-Path $repoRoot 'artifacts/skill-evals' } - if (-not $resolvedEval -or (Split-Path $resolvedEval -Leaf) -eq 'eval.vally.yaml') { + if (-not $resolvedEval -and -not $hasExplicitExperiment) { + foreach ($directory in Get-ChildItem $evalRoot -Directory) { + if (Test-Path (Join-Path $directory.FullName 'eval.vally.yaml')) { + & $PSCommandPath Run -Root $repoRoot -Suite $directory.Name ` + -OutputDirectory (Join-Path $output $directory.Name) ` + -Vally $Vally -VallyPrefix $VallyPrefix @Arguments + if (-not $? -or $LASTEXITCODE -ne 0) { + throw "The '$($directory.Name)' suite run failed." + } + } + } + break + } + $selectedSuite = if ($resolvedEval) { + Split-Path (Split-Path $resolvedEval -Parent) -Leaf + } + if ($selectedSuite -eq 'review-pull-request' -and (Test-Path $reviewExperiment)) { + $selectedExperiment = if ($selectedExperiment -eq $smokeExperiment) { + $reviewSmokeExperiment + } elseif (-not $hasExplicitExperiment) { + $reviewExperiment + } else { + $selectedExperiment + } + } + if ($selectedSuite -eq 'review-candidate-verifier') { + $runs = if ($selectedExperiment -in @($smokeExperiment, $reviewSmokeExperiment)) { 1 } else { 5 } + $vallyArguments = @( + 'eval', '--eval-spec', $resolvedEval, + '--runs', $runs.ToString(), + '--output-dir', $output + ) + } elseif (-not $resolvedEval -or (Split-Path $resolvedEval -Leaf) -eq 'eval.vally.yaml') { $vallyArguments = @( 'experiment', 'run', $selectedExperiment, @@ -324,6 +408,28 @@ switch ($Action) { } $vallyArguments += $Arguments - Invoke-VallyIsolated $vallyArguments + $invocationCompleted = $false + try { + Invoke-VallyIsolated $vallyArguments + $invocationCompleted = $true + } finally { + if ($selectedSuite -eq 'review-candidate-verifier') { + $runDirectories = @(Get-ChildItem $output -Directory -ErrorAction SilentlyContinue) + if ($runDirectories.Count -eq 1 -and + (Test-Path (Join-Path $runDirectories[0].FullName 'results.jsonl'))) { + @{ + evals = @(@{ + variant = 'current' + plannedStimulusNames = @('a', 'b', 'c') + plannedStimulusCount = 3 + runs = $runs + threshold = 0.8 + }) + } | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $runDirectories[0].FullName 'plan-snapshot.json') + } elseif ($invocationCompleted) { + throw 'Expected one completed component output directory with results.jsonl.' + } + } + } } } diff --git a/eng/skill-evals/skills-smoke.experiment.yaml b/eng/skill-evals/skills-smoke.experiment.yaml index 5c3e5495a947..adf1e71986ba 100644 --- a/eng/skill-evals/skills-smoke.experiment.yaml +++ b/eng/skill-evals/skills-smoke.experiment.yaml @@ -3,7 +3,7 @@ name: skills-smoke # Infrastructure smoke test only. One trial per stimulus is not enough to draw a # quality conclusion; use skills-vs-baseline.experiment.yaml for full runs. evals: - - "*/eval.vally.yaml" + - "!(review-pull-request|review-candidate-verifier)/eval.vally.yaml" overrides: runs: 1 diff --git a/eng/skill-evals/skills-vs-baseline.experiment.yaml b/eng/skill-evals/skills-vs-baseline.experiment.yaml index f7dfbed8a6fa..5d77c82e06fd 100644 --- a/eng/skill-evals/skills-vs-baseline.experiment.yaml +++ b/eng/skill-evals/skills-vs-baseline.experiment.yaml @@ -1,8 +1,9 @@ name: skills-vs-baseline -# Controlled A/B for every skill that ships a Vally eval: the same stimuli run with +# Controlled A/B for skills without additional reviewer treatment files: the same stimuli run with # no skill (baseline) and with that skill loaded (skilled). Only /environment/skills -# varies. Each eng/skill-evals//eval.vally.yaml is picked up automatically, and +# varies. The reviewer has its own experiment. Verifier components are not skills. +# Each other eng/skill-evals//eval.vally.yaml is picked up automatically, and # the skilled variant loads .github/skills/ (via ${eval.parent}). # # NOTE: `vally experiment run` executes the agent in the current working directory, and @@ -13,7 +14,7 @@ name: skills-vs-baseline # vally experiment run /eng/skill-evals/skills-vs-baseline.experiment.yaml --output-dir . # Run a single skill with: --variant skilled and a glob that matches one eval, or filter by tag. evals: - - "*/eval.vally.yaml" + - "!(review-pull-request|review-candidate-verifier)/eval.vally.yaml" vary: - /environment/skills diff --git a/eng/skill-evals/stage_run.ps1 b/eng/skill-evals/stage_run.ps1 index fbb15582debd..a1b5f9807785 100644 --- a/eng/skill-evals/stage_run.ps1 +++ b/eng/skill-evals/stage_run.ps1 @@ -203,15 +203,27 @@ $trustedFiles = @( 'eng/skill-evals/skills-vs-baseline.experiment.yaml' 'eng/skill-evals/skills-smoke.experiment.yaml' ) +if ($EvalName -in @('review-pull-request', 'review-candidate-verifier')) { + $trustedFiles += 'eng/skill-evals/grade_disposition.mjs' + if ($EvalName -eq 'review-pull-request') { + $trustedFiles += @( + 'eng/skill-evals/review-vs-baseline.experiment.yaml' + 'eng/skill-evals/review-smoke.experiment.yaml' + ) + } +} $candidateSkill = Join-Path $candidateRootPath ".github/skills/$EvalName" $candidateEvalRoot = Join-Path $candidateRootPath "eng/skill-evals/$EvalName" $candidateEval = Join-Path $candidateEvalRoot 'eval.vally.yaml' $candidateFixtures = Join-Path $candidateEvalRoot 'fixtures' -if (-not (Test-Path $candidateSkill -PathType Container)) { +if ($EvalName -ne 'review-candidate-verifier' -and + -not (Test-Path $candidateSkill -PathType Container)) { throw "Missing candidate skill directory at '$candidateSkill'." } -Assert-TreeIsSafe $candidateSkill $candidateRootPath "Candidate skill '$EvalName'" +if ($EvalName -ne 'review-candidate-verifier') { + Assert-TreeIsSafe $candidateSkill $candidateRootPath "Candidate skill '$EvalName'" +} if (-not (Test-Path $candidateEval -PathType Leaf)) { throw "Missing candidate eval specification at '$candidateEval'." } @@ -241,10 +253,12 @@ try { Copy-Item (Join-Path $trustedRootPath $relativePath) $target } - $skillTarget = Join-Path $destinationPath ".github/skills/$EvalName" - New-Item -ItemType Directory -Path (Split-Path $skillTarget -Parent) -Force | - Out-Null - Copy-Item $candidateSkill $skillTarget -Recurse -Force + if ($EvalName -ne 'review-candidate-verifier') { + $skillTarget = Join-Path $destinationPath ".github/skills/$EvalName" + New-Item -ItemType Directory -Path (Split-Path $skillTarget -Parent) -Force | + Out-Null + Copy-Item $candidateSkill $skillTarget -Recurse -Force + } $evalTargetRoot = Join-Path $destinationPath "eng/skill-evals/$EvalName" New-Item -ItemType Directory -Path $evalTargetRoot -Force | Out-Null @@ -259,6 +273,30 @@ try { } } + if ($EvalName -in @('review-pull-request', 'review-candidate-verifier')) { + $reviewSupportFiles = @( + '.github/agents/review-candidate-verifier.agent.md' + ) + if ($EvalName -eq 'review-pull-request') { + $reviewSupportFiles += @( + '.github/agents/review-guide-worker.agent.md' + 'docs/CrossCuttingGuidance.md' + 'docs/BlazorComponentsGuidance.md' + ) + } + foreach ($relativePath in $reviewSupportFiles) { + $sourcePath = Join-Path $candidateRootPath $relativePath + if (-not (Test-Path $sourcePath -PathType Leaf)) { + throw "Missing candidate support file '$relativePath'." + } + Assert-TreeIsSafe $sourcePath $candidateRootPath "Candidate support file '$relativePath'" + $targetPath = Join-Path $destinationPath $relativePath + New-Item -ItemType Directory -Path (Split-Path $targetPath -Parent) -Force | + Out-Null + Copy-Item $sourcePath $targetPath -Force + } + } + Assert-TreeIsSafe $destinationPath $destinationPath 'Staged evaluation tree' } catch { Remove-Item $destinationPath -Recurse -Force -ErrorAction SilentlyContinue diff --git a/eng/skill-evals/test_assert_results.ps1 b/eng/skill-evals/test_assert_results.ps1 index 3a619ca91507..74155c044603 100644 --- a/eng/skill-evals/test_assert_results.ps1 +++ b/eng/skill-evals/test_assert_results.ps1 @@ -19,7 +19,9 @@ function Write-Results { [string]$Status = 'success', - [switch]$OmitScore + [switch]$OmitScore, + + [object[]]$Details ) $variantDirectory = Join-Path $run $Variant @@ -27,13 +29,17 @@ function Write-Results { $result = [ordered]@{ type = 'trial-result' variant = $Variant + stimulus = 'case-01' status = $Status } if (-not $OmitScore) { $result.gradeResult = @{ score = $Score } + if ($PSBoundParameters.ContainsKey('Details')) { + $result.gradeResult.details = $Details + } } $result | - ConvertTo-Json -Compress | + ConvertTo-Json -Depth 10 -Compress | Set-Content (Join-Path $variantDirectory 'results.jsonl') } @@ -71,12 +77,14 @@ try { @{ variant = 'baseline' plannedStimulusCount = 1 + plannedStimulusNames = @('case-01') runs = 1 threshold = 0.6 }, @{ variant = 'skilled' plannedStimulusCount = 1 + plannedStimulusNames = @('case-01') runs = 1 threshold = 0.6 } @@ -114,7 +122,7 @@ try { Write-Results -Variant skilled -Score 0.5 Assert-Throws { & $assertResults -OutputDirectory $output - } "'skilled' score 0.5 is below" 'A below-threshold skilled result was accepted.' + } "'skilled' stimulus 'case-01' score 0.5 is below" 'A below-threshold skilled result was accepted.' Reset-Results Write-Results -Variant baseline -Score 0.1 @@ -129,6 +137,231 @@ try { & $assertResults -OutputDirectory $output } 'Missing Vally results' 'Missing skilled results were accepted.' + Reset-Results + function Write-ComponentResults { + param( + [scriptblock]$Mutation = {}, + [scriptblock]$CompletionMutation = {} + ) + + @{ + evals = @(@{ + variant = 'current' + plannedStimulusNames = @('a', 'b', 'c') + plannedStimulusCount = 3 + runs = 5 + threshold = 0.8 + }) + } | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $run 'plan-snapshot.json') + $rows = [Collections.Generic.List[object]]::new() + foreach ($name in 'a', 'b', 'c') { + foreach ($trial in 0..4) { + $rows.Add(@{ + type = 'trial-result' + runId = 'component-run' + stimulus = $name + trialIndex = $trial + status = 'success' + gradeResult = @{ + score = $(if ($trial -eq 4) { 0 } else { 1 }) + details = @( + @{ + configuredName = "evidence-reads-$name" + passed = $true + score = 1 + }, + @{ + configuredName = "disposition-$name" + passed = $trial -ne 4 + score = $(if ($trial -eq 4) { 0 } else { 1 }) + } + ) + } + }) + } + } + & $Mutation $rows + $completion = @{ + type = 'run-summary' + runId = 'component-run' + hadExecutionErrors = $false + } + & $CompletionMutation $completion + $rows.Add($completion) + $rows | ForEach-Object { $_ | ConvertTo-Json -Depth 10 -Compress } | + Set-Content (Join-Path $run 'results.jsonl') + } + + Write-ComponentResults + & $assertResults -OutputDirectory $output + $controls = @( + @{ Name = 'AverageCannotMaskOneWeakCase'; Expected = "stimulus 'a' score 0.6"; Mutation = { + param($rows) + $rows[3].gradeResult.score = 0 + $rows[3].gradeResult.details[1].score = 0 + foreach ($row in $rows | Where-Object stimulus -ne 'a') { + $row.gradeResult.score = 1 + $row.gradeResult.details[1].score = 1 + } + } } + @{ Name = 'DuplicateTrial'; Expected = 'duplicate trial identity'; Mutation = { + param($rows) + $rows[1].trialIndex = 0 + } } + @{ Name = 'MissingTrial'; Expected = 'Expected 15'; Mutation = { + param($rows) + $rows.RemoveAt(0) + } } + @{ Name = 'SubstitutedStimulus'; Expected = 'unplanned or missing stimulus'; Mutation = { + param($rows) + $rows[0].stimulus = 'other' + } } + @{ Name = 'OutOfRangeTrial'; Expected = 'invalid or duplicate trial identity'; Mutation = { + param($rows) + $rows[0].trialIndex = 5 + } } + @{ Name = 'FailedTrial'; Expected = 'incomplete or failed'; Mutation = { + param($rows) + $rows[0].status = 'error' + } } + @{ Name = 'StringScore'; Expected = 'invalid grader score'; Mutation = { + param($rows) + $rows[0].gradeResult.score = '1' + } } + @{ Name = 'NonbinaryComponentScore'; Expected = 'must be binary'; Mutation = { + param($rows) + $rows[0].gradeResult.score = 0.9 + } } + @{ Name = 'MissingReadIntegrity'; Expected = 'lacks read-integrity'; Mutation = { + param($rows) + $rows[0].gradeResult.Remove('details') + } } + @{ Name = 'FailedReadIntegrity'; Expected = 'failed read integrity'; Mutation = { + param($rows) + $rows[0].gradeResult.details[0].passed = $false + } } + @{ Name = 'MissingReceipt'; Expected = 'failed read integrity'; Mutation = { + param($rows) + $rows[0].gradeResult.details = @($rows[0].gradeResult.details[1]) + } } + @{ Name = 'DuplicateReceipt'; Expected = 'failed read integrity'; Mutation = { + param($rows) + $rows[0].gradeResult.details += $rows[0].gradeResult.details[0] + } } + @{ Name = 'DispositionGraderError'; Expected = 'valid primary disposition'; Mutation = { + param($rows) + $rows[0].gradeResult.details[1].status = 'error' + } } + @{ Name = 'SummaryIsNotATrial'; Expected = 'completion summary'; Mutation = { + param($rows) + $rows[0].type = 'run-summary' + } } + ) + foreach ($control in $controls) { + Write-ComponentResults $control.Mutation + Assert-Throws { & $assertResults -OutputDirectory $output } $control.Expected $control.Name + } + Write-ComponentResults -CompletionMutation { + param($completion) + $completion.hadExecutionErrors = $true + } + Assert-Throws { & $assertResults -OutputDirectory $output } 'completion summary' ( + 'A component run with execution errors was accepted.' + ) + Write-ComponentResults -CompletionMutation { + param($completion) + $completion.runId = 'other-run' + } + Assert-Throws { & $assertResults -OutputDirectory $output } 'unplanned or missing stimulus' ( + 'Component trials from another run were accepted.' + ) + Write-ComponentResults + $componentLines = @(Get-Content (Join-Path $run 'results.jsonl')) + $componentLines[0..13] + $componentLines[-1] | + Set-Content (Join-Path $run 'results.jsonl') + Assert-Throws { & $assertResults -OutputDirectory $output } "15 'current' trial results; found 14" ( + 'The terminal summary replaced a missing component trial.' + ) + $componentLines[0..14] | Set-Content (Join-Path $run 'results.jsonl') + Assert-Throws { & $assertResults -OutputDirectory $output } 'completion summary' ( + 'A component run without a terminal summary was accepted.' + ) + @($componentLines[-1]) + $componentLines[0..14] | + Set-Content (Join-Path $run 'results.jsonl') + Assert-Throws { & $assertResults -OutputDirectory $output } 'completion summary' ( + 'A nonterminal component summary was accepted.' + ) + + function Write-ReviewResults { + param([scriptblock]$Mutation = {}) + + @{ + evals = @( + foreach ($variant in 'baseline', 'skilled') { + @{ + evalName = 'review-pull-request' + variant = $variant + plannedStimulusNames = @('case-01') + plannedStimulusCount = 1 + runs = 1 + threshold = 1 + } + } + ) + } | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $run 'plan-snapshot.json') + foreach ($variant in 'baseline', 'skilled') { + $receipts = @( + foreach ($name in 'evidence-reads', 'guidance-reads', 'treatment-reads') { + @{ + configuredName = "$name-case-01" + passed = $name -ne 'treatment-reads' -or $variant -eq 'skilled' + score = $(if ($name -eq 'treatment-reads' -and $variant -eq 'baseline') { 0 } else { 1 }) + } + } + @{ + configuredName = 'disposition-case-01' + passed = $true + score = 1 + } + ) + & $Mutation $variant $receipts + Write-Results -Variant $variant -Score 1 -Details $receipts + } + } + + Write-ReviewResults + & $assertResults -OutputDirectory $output + foreach ($variantToFail in 'baseline', 'skilled') { + foreach ($receiptToFail in 'evidence-reads', 'guidance-reads') { + Write-ReviewResults { + param($variant, $receipts) + if ($variant -eq $variantToFail) { + ($receipts | Where-Object configuredName -eq "$receiptToFail-case-01").passed = $false + } + } + Assert-Throws { & $assertResults -OutputDirectory $output } 'failed read integrity' ( + "$variantToFail accepted missing $receiptToFail integrity." + ) + } + } + Write-ReviewResults { + param($variant, $receipts) + if ($variant -eq 'skilled') { + ($receipts | Where-Object configuredName -eq 'treatment-reads-case-01').passed = $false + } + } + Assert-Throws { & $assertResults -OutputDirectory $output } 'treatment-reads-case-01' ( + 'Skilled accepted missing treatment integrity.' + ) + + Write-ReviewResults + $combinedOutput = Join-Path $testRoot 'combined' + New-Item -ItemType Directory -Path $combinedOutput | Out-Null + Copy-Item $output (Join-Path $combinedOutput 'review-pull-request') -Recurse + Write-ComponentResults + Copy-Item $output (Join-Path $combinedOutput 'review-candidate-verifier') -Recurse + & $assertResults -OutputDirectory $combinedOutput + Write-Host 'Skill-eval result assertion self-test passed.' } finally { Remove-Item -Recurse -Force $testRoot diff --git a/eng/skill-evals/test_disposition.mjs b/eng/skill-evals/test_disposition.mjs new file mode 100644 index 000000000000..ab07ef22910c --- /dev/null +++ b/eng/skill-evals/test_disposition.mjs @@ -0,0 +1,112 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { grade } from './grade_disposition.mjs'; + +const score = (name, output, mode = 'review') => grade({ + trajectory: { output }, + stimulus: { name }, + config: { env: { DISPOSITION_MODE: mode } }, +}).score; + +const review = (section, confidence, inline = true) => `STATUS: ${inline ? 'FINDINGS' : 'NO_FINDINGS'} +NEW_FINDINGS +${inline ? `C1 confidence: ${confidence} [${confidence.toUpperCase()}] Why ${confidence}: source reason.` : 'None.'} +EXISTING_FEEDBACK_COVERAGE +None. +UNRESOLVED +${section === 'UNRESOLVED' ? 'C1 missing target-base contract.' : 'None.'} +DISCARDED +${section === 'DISCARDED' ? 'C1 old and head match.' : 'None.'}`; + +test('ReviewDispositionAcceptsExpectedSections', () => +{ + for (const [name, section, confidence] of [ + ['case-01', 'DISCARDED', 'discarded'], + ['case-02', 'NEW_FINDINGS', 'verified'], + ['case-03', 'DISCARDED', 'discarded'], + ['case-04', 'UNRESOLVED', 'unresolved'], + ['case-06', 'UNRESOLVED', 'unresolved'], + ]) + { + assert.equal(score(name, review(section, confidence)), 1, name); + } + for (const name of ['case-01', 'case-03']) + { + assert.equal(score(name, review('DISCARDED', 'discarded', false)), 0, name); + } +}); + +test('ReviewDispositionRejectsWrongStatusSectionConfidenceAndOmission', () => +{ + const good = review('UNRESOLVED', 'unresolved'); + for (const [name, output] of [ + ['wrong-status', good.replace('STATUS: FINDINGS', 'STATUS: BLOCKED')], + ['wrong-section', review('DISCARDED', 'discarded')], + ['wrong-confidence', good.replace('confidence: unresolved', 'confidence: question')], + ['missing-candidate', good.replaceAll('C1', 'candidate')], + ['missing-inline', review('UNRESOLVED', 'unresolved', false)], + ['missing-section', good.replace('DISCARDED', 'OTHER')], + ['duplicate-section', good + '\nUNRESOLVED\nC1'], + ['duplicate-inline', good.replace('EXISTING_FEEDBACK_COVERAGE', 'C1 confidence: verified\nEXISTING_FEEDBACK_COVERAGE')], + ['contradictory-placement', good.replace('DISCARDED\nNone.', 'DISCARDED\nC1 contradicted.')], + ['extra-candidate', good.replace('DISCARDED\nNone.', 'DISCARDED\nC2 another concern.')], + ['prompt-echo', 'Return NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED.'], + ]) + { + assert.equal(score('case-06', output), 0, name); + } +}); + +test('ExistingFeedbackRequiresThreadAndRejectsDuplicateInline', () => +{ + const good = `STATUS: NO_FINDINGS +NEW_FINDINGS +None. +EXISTING_FEEDBACK_COVERAGE +C1 discussion_r4487936812 already covers this concern. +UNRESOLVED +C1 discussion_r4487936812 browser mode remains unestablished. +DISCARDED +None.`; + assert.equal(score('case-05', good), 1); + assert.equal(score('case-05', good.replace('discussion_r4487936812', 'other-thread')), 0); + assert.equal(score('case-05', good.replace('NEW_FINDINGS\nNone.', 'NEW_FINDINGS\nC1')), 0); + assert.equal(score('case-05', good.replace('UNRESOLVED\nC1 discussion_r4487936812 browser mode remains unestablished.', 'UNRESOLVED\nNone.')), 0); + assert.equal(score('case-05', good.replace('UNRESOLVED\nC1 discussion_r4487936812', 'UNRESOLVED\nC1')), 0); +}); + +test('ComponentDispositionNormalizesOnlyApplicableFields', () => +{ + for (const name of ['a']) + { + const result = { decision: ' drop ', dropBasis: 'Unestablished', contradictedLink: 'NONE' }; + assert.equal(score(name, JSON.stringify(result), 'component'), 1); + assert.equal(score(name, '```json\n' + JSON.stringify({ results: [result] }) + '\n```', 'component'), 1); + for (const changed of [ + { ...result, decision: 'KEEP' }, + { ...result, dropBasis: 'contradicted' }, + { ...result, contradictedLink: 'contract' }, + { ...result, downgradeKind: 'intent' }, + { decision: 'DROP' }, + ]) + { + assert.equal(score(name, JSON.stringify(changed), 'component'), 0); + } + } + for (const name of ['b', 'c']) + { + assert.equal(score(name, '{"decision":"KEEP","extra":"format diagnostic"}', 'component'), 1); + assert.equal(score(name, '{"decision":"KEEP","dropBasis":"unestablished"}', 'component'), 0); + assert.equal(score(name, '{"decision":"DOWNGRADE","downgradeKind":"intent"}', 'component'), 0); + } + assert.equal(score('a', '{"results":[]}', 'component'), 0); + assert.equal(score('a', '{"results":[{},{}]}', 'component'), 0); + assert.equal(score('a', 'Not JSON.', 'component'), 0); + for (const output of ['null', 'true', '42', '[]', '{"results":[null]}']) + { + assert.equal(score('a', output, 'component'), 0, output); + } +}); diff --git a/eng/skill-evals/test_run.ps1 b/eng/skill-evals/test_run.ps1 index 0fb7cf242347..09608820a591 100644 --- a/eng/skill-evals/test_run.ps1 +++ b/eng/skill-evals/test_run.ps1 @@ -60,6 +60,15 @@ if ($args -contains '--version') { if ($env:SKILL_EVAL_FAKE_FAILURE) { throw 'fake Vally failure' } +if ($args[0] -eq 'eval' -and ($args -join ' ') -like '*review-candidate-verifier*') { + $output = $args[([array]::IndexOf($args, '--output-dir') + 1)] + $run = Join-Path $output '2026-01-01T00-00-00' + New-Item -ItemType Directory -Path $run -Force | Out-Null + Set-Content (Join-Path $run 'results.jsonl') '' + if ($env:SKILL_EVAL_FAKE_EXIT) { + exit 1 + } +} [ordered]@{ WorkingDirectory = (Get-Location).Path Arguments = [string[]]$args @@ -82,8 +91,8 @@ if ($env:SKILL_EVAL_FAKE_FAILURE) { Read-Invocations | Where-Object { $_.Arguments[0] -eq 'experiment' } ) - Assert-True ($validateInvocations.Count -eq 2) ( - 'Default validation did not resolve both experiments.' + Assert-True ($validateInvocations.Count -eq 4) ( + 'Default validation did not resolve generic and reviewer experiments.' ) foreach ($invocation in $validateInvocations) { Assert-True ($invocation.Arguments[1] -eq 'run') ( @@ -102,6 +111,12 @@ if ($env:SKILL_EVAL_FAKE_FAILURE) { Assert-True ($validateInvocations.Arguments -contains ( Join-Path $repoRoot 'eng/skill-evals/skills-smoke.experiment.yaml' )) 'Default validation did not resolve the smoke experiment.' + Assert-True ($validateInvocations.Arguments -contains ( + Join-Path $repoRoot 'eng/skill-evals/review-vs-baseline.experiment.yaml' + )) 'Default validation did not resolve the reviewer experiment.' + Assert-True ($validateInvocations.Arguments -contains ( + Join-Path $repoRoot 'eng/skill-evals/review-smoke.experiment.yaml' + )) 'Default validation did not resolve the reviewer smoke experiment.' Remove-Item $record & $runner Validate ` @@ -162,6 +177,114 @@ if ($env:SKILL_EVAL_FAKE_FAILURE) { Assert-True ($specializedInvocation[0] -eq 'eval') 'Specialized run did not use Vally eval.' Assert-True ($specializedInvocation -contains '--eval-spec') 'Specialized run omitted --eval-spec.' + Remove-Item $record + & $runner Validate ` + -Suite review-pull-request ` + -Vally $fakeVally ` + -VallyPrefix @() + $suiteInvocations = @(Read-Invocations) + $suiteLint = @($suiteInvocations | Where-Object { $_.Arguments[0] -eq 'lint' }) + Assert-True ($suiteLint.Count -eq 1) 'Suite validation linted unrelated specifications.' + Assert-True ($suiteLint[0].Arguments -contains ( + Join-Path $repoRoot 'eng/skill-evals/review-pull-request/eval.vally.yaml' + )) 'Suite validation did not lint the selected specification.' + $suitePlans = @($suiteInvocations | Where-Object { $_.Arguments[0] -eq 'experiment' }) + Assert-True ($suitePlans.Count -eq 2) 'Suite validation did not resolve both experiments.' + foreach ($invocation in $suitePlans) { + Assert-True ($invocation.Arguments -contains '--dry-run') 'Suite validation could invoke models.' + Assert-True ($invocation.Arguments -contains '--eval-filter') 'Suite validation omitted its filter.' + Assert-True ($invocation.Arguments -contains 'review-pull-request/eval.vally.yaml') 'Suite validation selected the wrong eval.' + } + + & $runner Run ` + -Suite review-pull-request ` + -Vally $fakeVally ` + -VallyPrefix @() ` + -OutputDirectory $output + $suiteRun = Read-Invocation + Assert-True ($suiteRun[0] -eq 'experiment') 'Suite run bypassed experiment skill ownership.' + Assert-True ($suiteRun -contains 'review-pull-request/eval.vally.yaml') 'Suite run selected the wrong eval.' + Assert-True ($suiteRun -contains (Join-Path $repoRoot 'eng/skill-evals/review-vs-baseline.experiment.yaml')) ( + 'Reviewer run used the generic treatment.' + ) + & $runner Run -Suite review-pull-request ` + -Experiment eng/skill-evals/skills-smoke.experiment.yaml ` + -Vally $fakeVally -VallyPrefix @() -OutputDirectory $output + Assert-True ((Read-Invocation) -contains (Join-Path $repoRoot 'eng/skill-evals/review-smoke.experiment.yaml')) ( + 'Reviewer smoke run used the generic treatment.' + ) + + foreach ($smoke in @($false, $true)) { + $componentOutput = Join-Path $testRoot "component-$smoke" + $options = @{ Suite = 'review-candidate-verifier'; Vally = $fakeVally; VallyPrefix = @(); OutputDirectory = $componentOutput } + if ($smoke) { + $options.Experiment = 'eng/skill-evals/skills-smoke.experiment.yaml' + } + & $runner Run @options + $componentRun = Read-Invocation + Assert-True ($componentRun[0] -eq 'eval') 'Component run used a skill comparison experiment.' + $plan = Get-Content (Join-Path $componentOutput '2026-01-01T00-00-00/plan-snapshot.json') -Raw | ConvertFrom-Json + $runs = if ($smoke) { 1 } else { 5 } + Assert-True ($plan.evals[0].runs -eq $runs) 'Component plan has the wrong repeat count.' + Assert-True ($componentRun[([array]::IndexOf($componentRun, '--runs') + 1)] -eq "$runs") 'Component invocation has the wrong repeat count.' + Assert-True ($plan.evals[0].threshold -eq 0.8 -and $plan.evals[0].plannedStimulusCount -eq 3) ( + 'Component plan lost its per-case 4/5 disposition gate.' + ) + } + $componentOutput = Join-Path $testRoot 'component-review-smoke' + & $runner Run -Suite review-candidate-verifier ` + -Experiment eng/skill-evals/review-smoke.experiment.yaml ` + -Vally $fakeVally -VallyPrefix @() -OutputDirectory $componentOutput + $componentRun = Read-Invocation + Assert-True ($componentRun[([array]::IndexOf($componentRun, '--runs') + 1)] -eq '1') ( + 'Reviewer smoke selection unexpectedly ran the full component suite.' + ) + + $env:SKILL_EVAL_FAKE_EXIT = 'true' + $failedOutput = Join-Path $testRoot 'component-exit-one' + & $runner Run -Suite review-candidate-verifier -Vally $fakeVally -VallyPrefix @() -OutputDirectory $failedOutput + Assert-True ($LASTEXITCODE -eq 1) 'Component Vally exit code was not propagated.' + Assert-True (Test-Path (Join-Path $failedOutput '2026-01-01T00-00-00/plan-snapshot.json')) ( + 'A failed component run lost its plan snapshot.' + ) + Remove-Item Env:SKILL_EVAL_FAKE_EXIT + + Remove-Item $record + & $runner Validate -Eval eng/skill-evals/review-candidate-verifier/eval.vally.yaml ` + -Vally $fakeVally -VallyPrefix @() + $componentValidation = @(Read-Invocations) + Assert-True ($componentValidation.Count -eq 1 -and $componentValidation[0].Arguments[0] -eq 'lint') ( + 'Component -Eval validation planned unrelated comparison experiments.' + ) + + Remove-Item $record + & $runner Run -Vally $fakeVally -VallyPrefix @() -OutputDirectory (Join-Path $testRoot 'all-results') + $allRuns = @(Read-Invocations | Where-Object { $_.Arguments[0] -in @('experiment', 'eval') }) + $suiteCount = @(Get-ChildItem (Join-Path $repoRoot 'eng/skill-evals') -Directory | + Where-Object { Test-Path (Join-Path $_.FullName 'eval.vally.yaml') }).Count + Assert-True ($allRuns.Count -eq $suiteCount) 'Default run omitted a standard suite.' + Assert-True (($allRuns.Arguments -join ' ') -like '*review-candidate-verifier*') 'Default run omitted the component suite.' + Assert-True ($allRuns.Arguments -contains (Join-Path $repoRoot 'eng/skill-evals/review-vs-baseline.experiment.yaml')) ( + 'Default run omitted the reviewer comparison.' + ) + + foreach ($invalidSuite in @('../outside', '..', 'missing-suite')) { + $rejected = $false + try { + & $runner Lint -Suite $invalidSuite -Vally $fakeVally -VallyPrefix @() + } catch { + $rejected = $_.Exception.Message -match 'Invalid suite name|Missing suite specification' + } + Assert-True $rejected "Invalid or missing suite '$invalidSuite' was not rejected." + } + $ambiguousSelectionRejected = $false + try { + & $runner Lint -Suite review-pull-request -Eval $specialized -Vally $fakeVally -VallyPrefix @() + } catch { + $ambiguousSelectionRejected = $_.Exception.Message -like '*Specify either -Suite or -Eval*' + } + Assert-True $ambiguousSelectionRejected 'Conflicting suite and eval selectors were not rejected.' + $env:SKILL_EVAL_FAKE_FAILURE = 'true' $failurePropagated = $false try { @@ -175,6 +298,7 @@ if ($env:SKILL_EVAL_FAKE_FAILURE) { } finally { Remove-Item Env:SKILL_EVAL_RUNNER_RECORD -ErrorAction SilentlyContinue Remove-Item Env:SKILL_EVAL_FAKE_FAILURE -ErrorAction SilentlyContinue + Remove-Item Env:SKILL_EVAL_FAKE_EXIT -ErrorAction SilentlyContinue if ($hadPreviousVally) { $env:SKILL_EVAL_VALLY = $previousVally } else { diff --git a/eng/skill-evals/test_stage_run.ps1 b/eng/skill-evals/test_stage_run.ps1 index b6d065da8444..b918a52bd3ae 100644 --- a/eng/skill-evals/test_stage_run.ps1 +++ b/eng/skill-evals/test_stage_run.ps1 @@ -290,6 +290,100 @@ stimuli: -EvalName allowed-prompt-text ` -Destination (Join-Path $testRoot 'allowed-prompt-text') + New-RestrictedCandidate 'review-pull-request' @' +stimuli: + - name: review-case + prompt: Review the staged case. +'@ + $agentsDir = Join-Path $candidateRoot '.github/agents' + $docsDir = Join-Path $candidateRoot 'docs' + New-Item -ItemType Directory -Path $agentsDir, $docsDir -Force | Out-Null + Set-Content (Join-Path $agentsDir 'review-guide-worker.agent.md') $candidateDataMarker + Set-Content (Join-Path $agentsDir 'review-candidate-verifier.agent.md') $candidateDataMarker + Set-Content (Join-Path $agentsDir 'unrelated.agent.md') 'UNRELATED_AGENT' + Set-Content (Join-Path $docsDir 'CrossCuttingGuidance.md') $candidateDataMarker + Set-Content (Join-Path $docsDir 'BlazorComponentsGuidance.md') $candidateDataMarker + Set-Content (Join-Path $docsDir 'UnrelatedDoc.md') 'UNRELATED_DOC' + foreach ($controlFile in @( + 'grade_disposition.mjs', + 'review-vs-baseline.experiment.yaml', + 'review-smoke.experiment.yaml' + )) { + Set-Content (Join-Path $trustedRoot "eng/skill-evals/$controlFile") $trustedMarker + } + + $reviewDestination = Join-Path $testRoot 'staged-review-pull-request' + & $stageRun ` + -TrustedRoot $trustedRoot ` + -CandidateRoot $candidateRoot ` + -EvalName review-pull-request ` + -Destination $reviewDestination + + $stagedReviewFiles = @( + Get-ChildItem $reviewDestination -Recurse -File -Force | + ForEach-Object { + [IO.Path]::GetRelativePath($reviewDestination, $_.FullName).Replace('\', '/') + } | + Sort-Object + ) + $expectedReviewFiles = @( + '.github/agents/review-candidate-verifier.agent.md' + '.github/agents/review-guide-worker.agent.md' + '.github/skills/review-pull-request/SKILL.md' + 'docs/BlazorComponentsGuidance.md' + 'docs/CrossCuttingGuidance.md' + 'eng/skill-evals/assert_results.ps1' + 'eng/skill-evals/grade_disposition.mjs' + 'eng/skill-evals/review-vs-baseline.experiment.yaml' + 'eng/skill-evals/review-smoke.experiment.yaml' + 'eng/skill-evals/review-pull-request/eval.vally.yaml' + 'eng/skill-evals/run.ps1' + 'eng/skill-evals/skills-smoke.experiment.yaml' + 'eng/skill-evals/skills-vs-baseline.experiment.yaml' + ) | Sort-Object + Assert-True ( + @(Compare-Object $expectedReviewFiles $stagedReviewFiles).Count -eq 0 + ) "Unexpected staged review-pull-request files: $($stagedReviewFiles -join ', ')." + + foreach ($relativePath in @( + '.github/agents/review-candidate-verifier.agent.md' + '.github/agents/review-guide-worker.agent.md' + 'docs/CrossCuttingGuidance.md' + 'docs/BlazorComponentsGuidance.md' + )) { + $sourcePath = Join-Path $candidateRoot $relativePath + $missingDestination = Join-Path $testRoot ([guid]::NewGuid().ToString('N')) + Remove-Item $sourcePath + try { + Assert-Throws { + & $stageRun ` + -TrustedRoot $trustedRoot ` + -CandidateRoot $candidateRoot ` + -EvalName review-pull-request ` + -Destination $missingDestination + } "Missing candidate support file '$relativePath'" + Assert-True (-not (Test-Path $missingDestination)) 'Failed staging left a partial tree.' + } finally { + Set-Content $sourcePath $candidateDataMarker + } + } + + $componentEval = Join-Path $candidateRoot 'eng/skill-evals/review-candidate-verifier' + New-Item -ItemType Directory -Path $componentEval -Force | Out-Null + Set-Content (Join-Path $componentEval 'eval.vally.yaml') $candidateDataMarker + $componentDestination = Join-Path $testRoot 'staged-verifier' + & $stageRun -TrustedRoot $trustedRoot -CandidateRoot $candidateRoot ` + -EvalName review-candidate-verifier -Destination $componentDestination + Assert-True ( + -not (Test-Path (Join-Path $componentDestination '.github/skills/review-candidate-verifier')) + ) 'A component suite must not invent a runtime skill.' + Assert-True ( + (Get-Content (Join-Path $componentDestination 'eng/skill-evals/grade_disposition.mjs') -Raw).Trim() -eq $trustedMarker + ) 'The component grader does not come from the trusted control plane.' + Assert-True ( + Test-Path (Join-Path $componentDestination '.github/agents/review-candidate-verifier.agent.md') + ) 'The component verifier profile is missing.' + Write-Host 'Trusted skill-eval staging self-test passed.' } finally { Remove-Item $testRoot -Recurse -Force diff --git a/eng/skill-evals/tests/test_review_fixtures.ps1 b/eng/skill-evals/tests/test_review_fixtures.ps1 new file mode 100644 index 000000000000..2f9ab4ee325f --- /dev/null +++ b/eng/skill-evals/tests/test_review_fixtures.ps1 @@ -0,0 +1,203 @@ +#requires -Version 7.0 + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version 3 + +$suiteRoot = (Resolve-Path (Join-Path $PSScriptRoot '../review-pull-request')).Path +$specPath = Join-Path $suiteRoot 'eval.vally.yaml' +$json = Get-Content $specPath -Raw | & npx ` + --yes ` + --registry=https://packagefeedproxy.microsoft.io/npm/ ` + 'yaml@2.9.1' --json --single --strict +if ($LASTEXITCODE -ne 0) { + throw 'Could not parse the review fixture specification.' +} +$spec = $json | ConvertFrom-Json -AsHashtable -Depth 100 +$script:checks = 0 + +function Assert-True { + param([bool]$Condition, [string]$Message) + + $script:checks++ + if (-not $Condition) { + throw $Message + } +} + +function Test-FileHash { + param([string]$Path, [string]$Hash) + + return (Get-FileHash $Path -Algorithm SHA256).Hash -eq $Hash +} + +Assert-True ($spec.stimuli.Count -eq 6) 'The suite must retain five PR cases and one catch-policy case.' +Assert-True (-not (Test-Path (Join-Path $suiteRoot 'catch-policy.vally.yaml'))) ( + 'The superseded standalone catch-policy specification remains.' +) +Assert-True (-not (Test-Path (Join-Path $suiteRoot 'fixtures/catch-policy'))) ( + 'The superseded standalone catch-policy fixtures remain.' +) +Assert-True ( + @(Get-ChildItem (Join-Path $suiteRoot 'fixtures') -Recurse -File -Filter '*.txt').Count -eq 0 +) 'The synthetic text fixtures remain.' + +$supportFiles = @($spec.agent_environment.files) +Assert-True ( + @($supportFiles | Where-Object { $_.src -match 'SKILL\.md$|\.agent\.md$' }).Count -eq 0 +) 'The standard suite stages treatment instructions into its baseline.' +Assert-True ($spec.scoring.weights.program -eq 1) 'Disposition is not the primary deterministic gate.' +foreach ($key in 'skill-invocation', 'tool-calls', 'prompt') { + Assert-True ($spec.scoring.weights[$key] -eq 0) "The $key grader confounds disposition quality." +} + +foreach ($stimulus in $spec.stimuli) { + $caseRoot = Join-Path $suiteRoot "fixtures/$($stimulus.name)" + $provenance = Get-Content (Join-Path $caseRoot 'provenance.json') -Raw | + ConvertFrom-Json -AsHashtable -Depth 100 + Assert-True ($stimulus.name -match '^case-\d\d$') 'A stimulus name reveals its source or answer.' + Assert-True ($provenance.repository -eq 'dotnet/aspnetcore') 'A fixture comes from another repository.' + if ($stimulus.name -ne 'case-06') { + Assert-True ( + @($provenance.sourceRoles.Keys | Sort-Object) -join ',' -eq 'baseTip,head,mergeBase' + ) 'A frozen source role is missing.' + } else { + Assert-True ($provenance.fixtureKind -like 'synthetic public*') 'The catch example is misrepresented as production source.' + $context = Get-Content (Join-Path $caseRoot 'context.source') -Raw + Assert-True ($context -notmatch 'No target-base policy|No additional primary contract|unspecified\.txt') ( + 'The catch case includes an answer hint.' + ) + } + + foreach ($file in $provenance.files) { + $path = Join-Path $caseRoot $file.file + Assert-True (Test-FileHash $path $file.sha256) "Frozen fixture hash mismatch: $path." + if ($file.ContainsKey('sources')) { + foreach ($source in $file.sources) { + Assert-True ( + $source.commit -eq $provenance.sourceRoles[$source.role] + ) "Source role mismatch: $path." + Assert-True ( + $source.blob -match '^[0-9a-f]{40}$' -and $source.ranges.Count -gt 0 + ) "Source blob or ranges are missing: $path." + } + } + } + + $trialFiles = @($supportFiles) + @($stimulus.agent_environment.files) + $requiredReads = @( + $stimulus.graders | + Where-Object { $_.type -eq 'tool-calls' } | + ForEach-Object { $_.config.required } + ) + foreach ($file in $trialFiles) { + $path = Join-Path $suiteRoot $file.src + $content = Get-Content $path -Raw + $matchingReads = @($requiredReads | Where-Object { + $file.dest -match $_.pattern -and $content -match $_.result + }) + Assert-True ($matchingReads.Count -gt 0) "No actual-byte read guard covers $($stimulus.name)/$($file.dest)." + } + Assert-True ( + @($requiredReads | Where-Object { + $_.pattern -eq 'review-pull-request' -and $_.result -eq 'Return result; never publish' + }).Count -eq 1 + ) 'The skill acquisition needs one real-content receipt, not two conjunctive tool choices.' +} + +$sampleRoot = Join-Path $suiteRoot 'fixtures/case-01' +$sample = Get-Content (Join-Path $sampleRoot 'provenance.json') -Raw | + ConvertFrom-Json -AsHashtable -Depth 100 +$file = $sample.files[0] +Assert-True ( + -not (Test-FileHash (Join-Path $sampleRoot $file.file) ('0' * 64)) +) 'A wrong snapshot hash passes the integrity check.' + +$repoRoot = (Resolve-Path (Join-Path $suiteRoot '../../..')).Path +$evalRoot = Split-Path $suiteRoot -Parent +foreach ($experimentName in 'review-vs-baseline', 'review-smoke') { + $experimentText = Get-Content (Join-Path $evalRoot "$experimentName.experiment.yaml") -Raw | + & npx --yes --registry=https://packagefeedproxy.microsoft.io/npm/ 'yaml@2.9.1' --json --single --strict + if ($LASTEXITCODE -ne 0) { + throw "Could not parse $experimentName." + } + $experiment = $experimentText | ConvertFrom-Json -AsHashtable -Depth 100 + $baseline = $experiment.variants.baseline.environment + $skilled = $experiment.variants.skilled.environment + Assert-True ($baseline.skills.Count -eq 0 -and -not $baseline.ContainsKey('files')) ( + 'Baseline receives additional treatment files.' + ) + Assert-True ($skilled.skills.Count -eq 1) 'The skilled variant lacks its skill.' + Assert-True (@($skilled.files | Where-Object dest -like '*.agent.md').Count -eq 2) ( + 'Only the skilled variant must receive both reviewer profiles.' + ) +} + +$componentRoot = Join-Path $evalRoot 'review-candidate-verifier' +$componentText = Get-Content (Join-Path $componentRoot 'eval.vally.yaml') -Raw | + & npx --yes --registry=https://packagefeedproxy.microsoft.io/npm/ 'yaml@2.9.1' --json --single --strict +if ($LASTEXITCODE -ne 0) { + throw 'Could not parse verifier component specification.' +} +$component = $componentText | ConvertFrom-Json -AsHashtable -Depth 100 +Assert-True (($component.stimuli.name -join ',') -eq 'a,b,c') 'Verifier component cases must be exactly a, b, and c.' +Assert-True ($component.defaults.runs -eq 5 -and $component.scoring.threshold -eq 0.8) 'The component gate must require 4/5.' +$componentProvenance = Get-Content (Join-Path $componentRoot 'provenance.json') -Raw | + ConvertFrom-Json -AsHashtable -Depth 100 +Assert-True ($componentProvenance.sourceRevisions.head -eq 'c0f86a6d725473f7a6f4c56d816ef941591053d2') ( + 'The component source does not use the pinned head.' +) +foreach ($file in $componentProvenance.files) { + Assert-True (Test-FileHash (Join-Path $componentRoot "fixtures/$($file.file)") $file.sha256) ( + "Component fixture hash mismatch: $($file.file)." + ) +} +foreach ($stimulus in $component.stimuli) { + foreach ($file in @($component.agent_environment.files) + @($stimulus.agent_environment.files)) { + Assert-True (Test-Path (Join-Path $componentRoot $file.src)) "Missing component input: $($file.src)." + } +} +$checkoutRoot = Join-Path ([IO.Path]::GetTempPath()) ( + 'aspnetcore-review-fixture-checkout-' + [guid]::NewGuid().ToString('N') +) +New-Item -ItemType Directory -Path $checkoutRoot | Out-Null +try { + $fixturePaths = @( + Get-ChildItem (Join-Path $suiteRoot 'fixtures') -Recurse -File -Force | + ForEach-Object { [IO.Path]::GetRelativePath($repoRoot, $_.FullName).Replace('\', '/') } + ) + & git -C $repoRoot -c core.autocrlf=true checkout-index ` + "--prefix=$checkoutRoot$([IO.Path]::DirectorySeparatorChar)" -- @fixturePaths + if ($LASTEXITCODE -ne 0) { + throw 'Could not materialize the tracked fixture files through Git.' + } + foreach ($stimulus in $spec.stimuli) { + $relativeRoot = "eng/skill-evals/review-pull-request/fixtures/$($stimulus.name)" + $checkedOutRoot = Join-Path $checkoutRoot $relativeRoot + $provenance = Get-Content (Join-Path $checkedOutRoot 'provenance.json') -Raw | + ConvertFrom-Json -AsHashtable -Depth 100 + foreach ($file in $provenance.files) { + Assert-True ( + Test-FileHash (Join-Path $checkedOutRoot $file.file) $file.sha256 + ) "Git checkout changed the frozen bytes of $relativeRoot/$($file.file)." + } + } + $componentRelative = 'eng/skill-evals/review-candidate-verifier/fixtures' + $componentPaths = @( + Get-ChildItem (Join-Path $componentRoot 'fixtures') -Recurse -File -Force | + ForEach-Object { [IO.Path]::GetRelativePath($repoRoot, $_.FullName).Replace('\', '/') } + ) + & git -C $repoRoot -c core.autocrlf=true checkout-index ` + "--prefix=$checkoutRoot$([IO.Path]::DirectorySeparatorChar)" -- @componentPaths + if ($LASTEXITCODE -ne 0) { + throw 'Could not materialize component fixtures through Git.' + } + foreach ($file in $componentProvenance.files) { + Assert-True ( + Test-FileHash (Join-Path $checkoutRoot "$componentRelative/$($file.file)") $file.sha256 + ) "Git checkout changed component fixture bytes: $($file.file)." + } +} finally { + Remove-Item -LiteralPath $checkoutRoot -Recurse -Force +} + +Write-Host "Review fixture self-test: $script:checks ran, $script:checks passed, 0 failed." diff --git a/eng/skill-evals/tests/test_stage_run.ps1 b/eng/skill-evals/tests/test_stage_run.ps1 new file mode 100644 index 000000000000..e567f52f1965 --- /dev/null +++ b/eng/skill-evals/tests/test_stage_run.ps1 @@ -0,0 +1,4 @@ +#requires -Version 7.0 + +$ErrorActionPreference = 'Stop' +& (Join-Path $PSScriptRoot '../test_stage_run.ps1') @args From ac01ad003965f32a558077e4128f6ddc8bf8ecfb Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Tue, 10 Nov 2026 16:41:49 -0600 Subject: [PATCH 02/23] Tighten secondary-failure contract rule in review-candidate-verifier and harden Vally evidence-reads regexes Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../agents/review-candidate-verifier.agent.md | 30 ++++++++++------- .../workflows/pull-request-review.lock.yml | 4 +-- .github/workflows/pull-request-review.md | 30 ++++++++++------- .../review-candidate-verifier/eval.vally.yaml | 24 +++++++------- .../review-pull-request/eval.vally.yaml | 32 +++++++++---------- 5 files changed, 66 insertions(+), 54 deletions(-) diff --git a/.github/agents/review-candidate-verifier.agent.md b/.github/agents/review-candidate-verifier.agent.md index 6408ccffb15a..15c8773ae189 100644 --- a/.github/agents/review-candidate-verifier.agent.md +++ b/.github/agents/review-candidate-verifier.agent.md @@ -56,19 +56,25 @@ applicable: prescribed assertion fails on revert and passes at `head`. Apply the `trigger` BCL contract and external-evidence rules to that reverted path as well. - `contract`: the applicable assigned base-tip or primary-repository contract (including - repository guidance), or `n/a` when no contract applies. Check whether a base-tip or + repository guidance), or `n/a` when no contract is required. Check whether a base-tip or primary-repository contract requires the head operation or forbids the candidate's - proposed alternative even when the candidate does not cite a contract. Head - production code is the change under review and is never a contract. A head - declaration may serve only when `oldVsNew` is `n/a` and the claim is not an - incomplete-fix, new-feature omission, or secondary-failure suppression claim. For an - incomplete-fix or new-feature omission claim, a binding assigned issue, API, or - base-tip/primary-repository contract is mandatory - (`contract` cannot be `n/a` or a head declaration/test; use `null` and return `DROP` - with `dropBasis: "unestablished"` when missing). A secondary-failure suppression - claim requires that binding contract only when it concerns suppression policy alone, - without independently proven consumer-visible harm caused by that suppression - (such as data loss, a wrong return value, or a resource leak). + proposed alternative even when the candidate does not cite a contract. General + exception-handling or coding-style guidance (such as catching only exceptions that can be + handled or enriched) does not by itself require a secondary failure to propagate or forbid + its suppression unless the contract explicitly specifies the propagation or suppression + behavior for that secondary operation or failure mode. Head production code is the change + under review and is never a contract. A head declaration may serve only when `oldVsNew` is + `n/a` and the claim is not an incomplete-fix, new-feature omission, or secondary-failure + suppression claim. For an incomplete-fix or new-feature omission claim, a binding assigned + issue, API, or base-tip/primary-repository contract is mandatory (`contract` cannot be + `n/a` or a head declaration/test; use `null` and return `DROP` with + `dropBasis: "unestablished"` when missing). A secondary-failure suppression claim likewise + requires that mandatory binding contract (`contract` cannot be `n/a` or a head + declaration/test; use `null` and return `DROP` with `dropBasis: "unestablished"` when + missing) unless the suppression causes independently proven consumer-visible harm beyond + non-propagation of the secondary exception or normal completion after the primary outcome + is recorded (such as corrupted or stale state, a skipped state transition or notification, + data loss, a wrong return value, or a resource leak). - `intent`: a PR-added or PR-changed head test that exercises the claimed exact input and asserts the claimed consumer-visible effect, or `n/a`. A head test that covers a different input, layer, or sibling case is not intent evidence and does not diff --git a/.github/workflows/pull-request-review.lock.yml b/.github/workflows/pull-request-review.lock.yml index d3c555a9837b..e09eea05032e 100644 --- a/.github/workflows/pull-request-review.lock.yml +++ b/.github/workflows/pull-request-review.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"a87f808e6c335fe17485e49a9a46a5854912cc59d2372b4851aa5e076dcb5b64","body_hash":"04b808f2cd0d4ae1f431a885e216c767ed6734c961973d9e2c2ae858199c2c8c","compiler_version":"v0.92.0","strict":true,"agent_id":"copilot","agent_model":"gpt-5.6-sol","engine_versions":{"copilot":"1.0.80"}} +# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"a87f808e6c335fe17485e49a9a46a5854912cc59d2372b4851aa5e076dcb5b64","body_hash":"ca4f5b0286994ac8a26f00d96523e8b1e5dd83b7403d6f9f47560bbeea4d60f4","compiler_version":"v0.92.0","strict":true,"agent_id":"copilot","agent_model":"gpt-5.6-sol","engine_versions":{"copilot":"1.0.80"}} # gh-aw-manifest: {"version":1,"secrets":["COPILOT_PAT_0","COPILOT_PAT_1","COPILOT_PAT_2","COPILOT_PAT_3","COPILOT_PAT_4","COPILOT_PAT_5","COPILOT_PAT_6","COPILOT_PAT_7","COPILOT_PAT_8","COPILOT_PAT_9","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/download-artifact","sha":"9000827ccba6bdab643e8b6fd33ac0654aef8333","version":"v8.0.2"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-dotnet","sha":"a98b56852c35b8e3190ac28c8c2271da59106c68","version":"v6.0.0"},{"repo":"actions/setup-node","sha":"949feb2413d6458794dcd2491c4babbbce0c15c1","version":"v7.1.0"},{"repo":"actions/upload-artifact","sha":"cf430e030ddbb5b0abf93d22962f4752f3646cd9","version":"v7.0.2"},{"repo":"github/gh-aw-actions/setup","sha":"458b269006dcf88e3b5496b6fbecabe4b9a0f954","version":"v0.92.0"}],"skills":[".github/skills/review-pull-request"],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.28.57","digest":"sha256:a9861b2fad1d29c586bbbf98840a61056e30e2720d8d9ec2c0def9049566bd8a","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.28.57@sha256:a9861b2fad1d29c586bbbf98840a61056e30e2720d8d9ec2c0def9049566bd8a"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.28.57","digest":"sha256:f2925ff32dc972a5d8b90a7785b6ca68052efd2575fe896556ac457e22e86dcc","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.28.57@sha256:f2925ff32dc972a5d8b90a7785b6ca68052efd2575fe896556ac457e22e86dcc"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.28.57","digest":"sha256:be808c16b535ebabd070eebe086fe6bffd5bb86b2e5fe8e5cdad30068eb9c0ac","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.28.57@sha256:be808c16b535ebabd070eebe086fe6bffd5bb86b2e5fe8e5cdad30068eb9c0ac"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.4.31","digest":"sha256:dbec0f2ddef6adf83b7764019323096e3e5cc0f3886255f6320555b7fe2a7caf","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.4.31@sha256:dbec0f2ddef6adf83b7764019323096e3e5cc0f3886255f6320555b7fe2a7caf"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:0daa8971fa4732b647150cb6524a6b0804b68d5d24f6f58b5dd1af23bd63fb23","pinned_image":"ghcr.io/github/gh-aw-node@sha256:0daa8971fa4732b647150cb6524a6b0804b68d5d24f6f58b5dd1af23bd63fb23"}],"mcp_servers":[{"name":"safeoutputs","tools":["add_comment","create_pull_request_review_comment","missing_data","missing_tool","noop","report_incomplete","submit_pull_request_review"]}],"threat_detection":{"mode":"enabled"}} # This file was automatically generated by gh-aw (v0.92.0). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md # @@ -587,7 +587,7 @@ jobs: GH_AW_SKILL_DIR: ".github/skills" run: bash "${RUNNER_TEMP}/gh-aw/actions/restore_inline_skills.sh" - name: Set up .NET SDK - uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 + uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 with: dotnet-version: 11.0.100-rc.1.26420.103 - env: diff --git a/.github/workflows/pull-request-review.md b/.github/workflows/pull-request-review.md index 4eb62b870809..9ea9bc631930 100644 --- a/.github/workflows/pull-request-review.md +++ b/.github/workflows/pull-request-review.md @@ -1049,19 +1049,25 @@ applicable: prescribed assertion fails on revert and passes at `head`. Apply the `trigger` BCL contract and external-evidence rules to that reverted path as well. - `contract`: the applicable assigned base-tip or primary-repository contract (including - repository guidance), or `n/a` when no contract applies. Check whether a base-tip or + repository guidance), or `n/a` when no contract is required. Check whether a base-tip or primary-repository contract requires the head operation or forbids the candidate's - proposed alternative even when the candidate does not cite a contract. Head - production code is the change under review and is never a contract. A head - declaration may serve only when `oldVsNew` is `n/a` and the claim is not an - incomplete-fix, new-feature omission, or secondary-failure suppression claim. For an - incomplete-fix or new-feature omission claim, a binding assigned issue, API, or - base-tip/primary-repository contract is mandatory - (`contract` cannot be `n/a` or a head declaration/test; use `null` and return `DROP` - with `dropBasis: "unestablished"` when missing). A secondary-failure suppression - claim requires that binding contract only when it concerns suppression policy alone, - without independently proven consumer-visible harm caused by that suppression - (such as data loss, a wrong return value, or a resource leak). + proposed alternative even when the candidate does not cite a contract. General + exception-handling or coding-style guidance (such as catching only exceptions that can be + handled or enriched) does not by itself require a secondary failure to propagate or forbid + its suppression unless the contract explicitly specifies the propagation or suppression + behavior for that secondary operation or failure mode. Head production code is the change + under review and is never a contract. A head declaration may serve only when `oldVsNew` is + `n/a` and the claim is not an incomplete-fix, new-feature omission, or secondary-failure + suppression claim. For an incomplete-fix or new-feature omission claim, a binding assigned + issue, API, or base-tip/primary-repository contract is mandatory (`contract` cannot be + `n/a` or a head declaration/test; use `null` and return `DROP` with + `dropBasis: "unestablished"` when missing). A secondary-failure suppression claim likewise + requires that mandatory binding contract (`contract` cannot be `n/a` or a head + declaration/test; use `null` and return `DROP` with `dropBasis: "unestablished"` when + missing) unless the suppression causes independently proven consumer-visible harm beyond + non-propagation of the secondary exception or normal completion after the primary outcome + is recorded (such as corrupted or stale state, a skipped state transition or notification, + data loss, a wrong return value, or a resource leak). - `intent`: a PR-added or PR-changed head test that exercises the claimed exact input and asserts the claimed consumer-visible effect, or `n/a`. A head test that covers a different input, layer, or sibling case is not intent evidence and does not diff --git a/eng/skill-evals/review-candidate-verifier/eval.vally.yaml b/eng/skill-evals/review-candidate-verifier/eval.vally.yaml index e65919234466..321dd1552b50 100644 --- a/eng/skill-evals/review-candidate-verifier/eval.vally.yaml +++ b/eng/skill-evals/review-candidate-verifier/eval.vally.yaml @@ -69,11 +69,11 @@ stimuli: pattern: changes\.diff result: "@@" - name: .* - pattern: source[/\\]head[/\\] - result: class AgentContext + pattern: source[/\\]+head[/\\]+.*AgentContext\.cs + result: LogProcessingError - name: .* - pattern: source[/\\]mergeBase[/\\] - result: class AgentContext + pattern: source[/\\]+mergeBase[/\\]+.*AgentContext\.cs + result: ConversationStatus\.Error - name: .* pattern: CrossCuttingGuidance\.md result: catch @@ -129,11 +129,11 @@ stimuli: pattern: changes\.diff result: "@@" - name: .* - pattern: source[/\\]head[/\\] - result: class AgentContext + pattern: source[/\\]+head[/\\]+.*AgentContext\.cs + result: LogProcessingError - name: .* - pattern: source[/\\]mergeBase[/\\] - result: class AgentContext + pattern: source[/\\]+mergeBase[/\\]+.*AgentContext\.cs + result: ConversationStatus\.Error - name: .* pattern: CrossCuttingGuidance\.md result: catch @@ -192,11 +192,11 @@ stimuli: pattern: changes\.diff result: "@@" - name: .* - pattern: source[/\\]head[/\\] - result: class Conversation + pattern: source[/\\]+head[/\\]+.*Conversation\.mjs + result: this\.status - name: .* - pattern: source[/\\]mergeBase[/\\] - result: class Conversation + pattern: source[/\\]+mergeBase[/\\]+.*Conversation\.mjs + result: this\.status - name: .* pattern: CrossCuttingGuidance\.md result: catch diff --git a/eng/skill-evals/review-pull-request/eval.vally.yaml b/eng/skill-evals/review-pull-request/eval.vally.yaml index f63991d52be8..fc674a29b19d 100644 --- a/eng/skill-evals/review-pull-request/eval.vally.yaml +++ b/eng/skill-evals/review-pull-request/eval.vally.yaml @@ -92,11 +92,11 @@ stimuli: result: Return result; never publish - &a2 name: .* - pattern: "[/\\\\]review-candidate-verifier\\.agent\\.md" + pattern: "[/\\\\]+review-candidate-verifier\\.agent\\.md" result: validationEvidence - &a3 name: .* - pattern: "[/\\\\]review-guide-worker\\.agent\\.md" + pattern: "[/\\\\]+review-guide-worker\\.agent\\.md" result: further agent delegation are unavailable disallowed: &a4 - name: ^(task|write_agent|create|edit|apply_patch)$ @@ -134,10 +134,10 @@ stimuli: config: required: - name: .* - pattern: docs[/\\]CrossCuttingGuidance\.md + pattern: docs[/\\]+CrossCuttingGuidance\.md result: Test infrastructure should use shared helpers - name: .* - pattern: docs[/\\]BlazorComponentsGuidance\.md + pattern: docs[/\\]+BlazorComponentsGuidance\.md result: Keep diagnostics actionable but not noisy rubric: - All criteria are mandatory. BLOCKED, fabricated evidence, silent omission, or an unqualified no-findings @@ -257,10 +257,10 @@ stimuli: config: required: - name: .* - pattern: docs[/\\]CrossCuttingGuidance\.md + pattern: docs[/\\]+CrossCuttingGuidance\.md result: Test infrastructure should use shared helpers - name: .* - pattern: docs[/\\]BlazorComponentsGuidance\.md + pattern: docs[/\\]+BlazorComponentsGuidance\.md result: Keep diagnostics actionable but not noisy rubric: - All criteria are mandatory. Adjudicate C1's required constructor parameter, not the unrelated dictionary-key @@ -379,10 +379,10 @@ stimuli: config: required: - name: .* - pattern: docs[/\\]CrossCuttingGuidance\.md + pattern: docs[/\\]+CrossCuttingGuidance\.md result: Test infrastructure should use shared helpers - name: .* - pattern: docs[/\\]BlazorComponentsGuidance\.md + pattern: docs[/\\]+BlazorComponentsGuidance\.md result: Keep diagnostics actionable but not noisy rubric: - All criteria are mandatory. C1 concerns a callback after renderer disposal, not removing a component while its @@ -500,10 +500,10 @@ stimuli: config: required: - name: .* - pattern: docs[/\\]CrossCuttingGuidance\.md + pattern: docs[/\\]+CrossCuttingGuidance\.md result: Test infrastructure should use shared helpers - name: .* - pattern: docs[/\\]BlazorComponentsGuidance\.md + pattern: docs[/\\]+BlazorComponentsGuidance\.md result: Keep diagnostics actionable but not noisy rubric: - All criteria are mandatory. C1 asserts that the new test server token endpoint changes the browser regression's @@ -623,10 +623,10 @@ stimuli: config: required: - name: .* - pattern: docs[/\\]CrossCuttingGuidance\.md + pattern: docs[/\\]+CrossCuttingGuidance\.md result: Test infrastructure should use shared helpers - name: .* - pattern: docs[/\\]BlazorComponentsGuidance\.md + pattern: docs[/\\]+BlazorComponentsGuidance\.md result: Keep diagnostics actionable but not noisy rubric: - All criteria are mandatory. The frozen feedback covers exactly C1's NavigateTo plus unprevented href concern, @@ -712,10 +712,10 @@ stimuli: pattern: review-pull-request result: Return result; never publish - name: .* - pattern: "[/\\\\]review-candidate-verifier\\.agent\\.md" + pattern: "[/\\\\]+review-candidate-verifier\\.agent\\.md" result: validationEvidence - name: .* - pattern: "[/\\\\]review-guide-worker\\.agent\\.md" + pattern: "[/\\\\]+review-guide-worker\\.agent\\.md" result: further agent delegation are unavailable disallowed: - name: ^(task|write_agent|create|edit|apply_patch)$ @@ -753,10 +753,10 @@ stimuli: config: required: - name: .* - pattern: docs[/\\]CrossCuttingGuidance\.md + pattern: docs[/\\]+CrossCuttingGuidance\.md result: Test infrastructure should use shared helpers - name: .* - pattern: docs[/\\]BlazorComponentsGuidance\.md + pattern: docs[/\\]+BlazorComponentsGuidance\.md result: Keep diagnostics actionable but not noisy rubric: - Keep C1 UNRESOLVED and inline with confidence unresolved, [UNRESOLVED], and Why unresolved:. Do not invent a From f50382cfd36d70bea87395330d272571ec443652 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Wed, 11 Nov 2026 12:57:56 -0600 Subject: [PATCH 03/23] Update skill-evals README for 15/15 L2 rerun and keep actions/setup-dotnet at v6.1.0 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/pull-request-review.lock.yml | 8 ++++---- .github/workflows/pull-request-review.md | 2 +- eng/skill-evals/README.md | 13 +++++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pull-request-review.lock.yml b/.github/workflows/pull-request-review.lock.yml index e09eea05032e..c089c18b7a92 100644 --- a/.github/workflows/pull-request-review.lock.yml +++ b/.github/workflows/pull-request-review.lock.yml @@ -1,5 +1,5 @@ -# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"a87f808e6c335fe17485e49a9a46a5854912cc59d2372b4851aa5e076dcb5b64","body_hash":"ca4f5b0286994ac8a26f00d96523e8b1e5dd83b7403d6f9f47560bbeea4d60f4","compiler_version":"v0.92.0","strict":true,"agent_id":"copilot","agent_model":"gpt-5.6-sol","engine_versions":{"copilot":"1.0.80"}} -# gh-aw-manifest: {"version":1,"secrets":["COPILOT_PAT_0","COPILOT_PAT_1","COPILOT_PAT_2","COPILOT_PAT_3","COPILOT_PAT_4","COPILOT_PAT_5","COPILOT_PAT_6","COPILOT_PAT_7","COPILOT_PAT_8","COPILOT_PAT_9","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/download-artifact","sha":"9000827ccba6bdab643e8b6fd33ac0654aef8333","version":"v8.0.2"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-dotnet","sha":"a98b56852c35b8e3190ac28c8c2271da59106c68","version":"v6.0.0"},{"repo":"actions/setup-node","sha":"949feb2413d6458794dcd2491c4babbbce0c15c1","version":"v7.1.0"},{"repo":"actions/upload-artifact","sha":"cf430e030ddbb5b0abf93d22962f4752f3646cd9","version":"v7.0.2"},{"repo":"github/gh-aw-actions/setup","sha":"458b269006dcf88e3b5496b6fbecabe4b9a0f954","version":"v0.92.0"}],"skills":[".github/skills/review-pull-request"],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.28.57","digest":"sha256:a9861b2fad1d29c586bbbf98840a61056e30e2720d8d9ec2c0def9049566bd8a","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.28.57@sha256:a9861b2fad1d29c586bbbf98840a61056e30e2720d8d9ec2c0def9049566bd8a"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.28.57","digest":"sha256:f2925ff32dc972a5d8b90a7785b6ca68052efd2575fe896556ac457e22e86dcc","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.28.57@sha256:f2925ff32dc972a5d8b90a7785b6ca68052efd2575fe896556ac457e22e86dcc"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.28.57","digest":"sha256:be808c16b535ebabd070eebe086fe6bffd5bb86b2e5fe8e5cdad30068eb9c0ac","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.28.57@sha256:be808c16b535ebabd070eebe086fe6bffd5bb86b2e5fe8e5cdad30068eb9c0ac"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.4.31","digest":"sha256:dbec0f2ddef6adf83b7764019323096e3e5cc0f3886255f6320555b7fe2a7caf","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.4.31@sha256:dbec0f2ddef6adf83b7764019323096e3e5cc0f3886255f6320555b7fe2a7caf"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:0daa8971fa4732b647150cb6524a6b0804b68d5d24f6f58b5dd1af23bd63fb23","pinned_image":"ghcr.io/github/gh-aw-node@sha256:0daa8971fa4732b647150cb6524a6b0804b68d5d24f6f58b5dd1af23bd63fb23"}],"mcp_servers":[{"name":"safeoutputs","tools":["add_comment","create_pull_request_review_comment","missing_data","missing_tool","noop","report_incomplete","submit_pull_request_review"]}],"threat_detection":{"mode":"enabled"}} +# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"43d9b3ddaeeda73e1f5ab5f2d1925e68a75ad81fef421eef2c5a756da9881325","body_hash":"ca4f5b0286994ac8a26f00d96523e8b1e5dd83b7403d6f9f47560bbeea4d60f4","compiler_version":"v0.92.0","strict":true,"agent_id":"copilot","agent_model":"gpt-5.6-sol","engine_versions":{"copilot":"1.0.80"}} +# gh-aw-manifest: {"version":1,"secrets":["COPILOT_PAT_0","COPILOT_PAT_1","COPILOT_PAT_2","COPILOT_PAT_3","COPILOT_PAT_4","COPILOT_PAT_5","COPILOT_PAT_6","COPILOT_PAT_7","COPILOT_PAT_8","COPILOT_PAT_9","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/download-artifact","sha":"9000827ccba6bdab643e8b6fd33ac0654aef8333","version":"v8.0.2"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-dotnet","sha":"0f4a354dd5547a28c70b7853dbd95d5b67886e73","version":"v6.1.0"},{"repo":"actions/setup-node","sha":"949feb2413d6458794dcd2491c4babbbce0c15c1","version":"v7.1.0"},{"repo":"actions/upload-artifact","sha":"cf430e030ddbb5b0abf93d22962f4752f3646cd9","version":"v7.0.2"},{"repo":"github/gh-aw-actions/setup","sha":"458b269006dcf88e3b5496b6fbecabe4b9a0f954","version":"v0.92.0"}],"skills":[".github/skills/review-pull-request"],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.28.57","digest":"sha256:a9861b2fad1d29c586bbbf98840a61056e30e2720d8d9ec2c0def9049566bd8a","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.28.57@sha256:a9861b2fad1d29c586bbbf98840a61056e30e2720d8d9ec2c0def9049566bd8a"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.28.57","digest":"sha256:f2925ff32dc972a5d8b90a7785b6ca68052efd2575fe896556ac457e22e86dcc","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.28.57@sha256:f2925ff32dc972a5d8b90a7785b6ca68052efd2575fe896556ac457e22e86dcc"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.28.57","digest":"sha256:be808c16b535ebabd070eebe086fe6bffd5bb86b2e5fe8e5cdad30068eb9c0ac","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.28.57@sha256:be808c16b535ebabd070eebe086fe6bffd5bb86b2e5fe8e5cdad30068eb9c0ac"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.4.31","digest":"sha256:dbec0f2ddef6adf83b7764019323096e3e5cc0f3886255f6320555b7fe2a7caf","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.4.31@sha256:dbec0f2ddef6adf83b7764019323096e3e5cc0f3886255f6320555b7fe2a7caf"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:0daa8971fa4732b647150cb6524a6b0804b68d5d24f6f58b5dd1af23bd63fb23","pinned_image":"ghcr.io/github/gh-aw-node@sha256:0daa8971fa4732b647150cb6524a6b0804b68d5d24f6f58b5dd1af23bd63fb23"}],"mcp_servers":[{"name":"safeoutputs","tools":["add_comment","create_pull_request_review_comment","missing_data","missing_tool","noop","report_incomplete","submit_pull_request_review"]}],"threat_detection":{"mode":"enabled"}} # This file was automatically generated by gh-aw (v0.92.0). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md # # ___ _ _ @@ -54,7 +54,7 @@ # - actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # - actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 # - actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 -# - actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 +# - actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 # - actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 # - actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 # - github/gh-aw-actions/setup@458b269006dcf88e3b5496b6fbecabe4b9a0f954 # v0.92.0 @@ -587,7 +587,7 @@ jobs: GH_AW_SKILL_DIR: ".github/skills" run: bash "${RUNNER_TEMP}/gh-aw/actions/restore_inline_skills.sh" - name: Set up .NET SDK - uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0 + uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0 with: dotnet-version: 11.0.100-rc.1.26420.103 - env: diff --git a/.github/workflows/pull-request-review.md b/.github/workflows/pull-request-review.md index 9ea9bc631930..02dad0e16a80 100644 --- a/.github/workflows/pull-request-review.md +++ b/.github/workflows/pull-request-review.md @@ -810,7 +810,7 @@ jobs: pre-agent-steps: - name: Set up .NET SDK - uses: actions/setup-dotnet@v6.0.0 + uses: actions/setup-dotnet@v6.1.0 with: dotnet-version: 11.0.100-rc.1.26420.103 - name: Prepare trusted frozen review bundle diff --git a/eng/skill-evals/README.md b/eng/skill-evals/README.md index 9084f2886ee1..a4a09297a981 100644 --- a/eng/skill-evals/README.md +++ b/eng/skill-evals/README.md @@ -70,10 +70,15 @@ contract, not an actual public API guarantee. Case c uses a synthetic JavaScript component and an immutable observation artifact. Component attributes preserve the exact supplied bytes, including existing line endings. Provenance records hashes and case kinds. -Cases a, b, and c were measured at 4/5, 5/5, and 5/5 on the predecessor verifier -text. They have not yet been re-run against the merged guard clauses. -Case d uses a scenario close to the one @maraf reported at 3/10 DROP and 7/10 -DOWNGRADE(intent). It has not been measured, so it is not gated. +Cases a, b, and c scored 5/5, 5/5, and 5/5 (15/15 disposition and 15/15 +`evidence-reads`) on the verifier text in this PR, including the merged #70319 +guard clauses and the tightened secondary-failure `contract` rule. A fourth +policy-only head-test scenario (close to @maraf's 3/10 `DROP(unestablished)` / +7/10 `DOWNGRADE(intent)` synthetic fixture) was omitted from the component gate; +`SKILL.md` retains the coordinator backstop mapping `DOWNGRADE(intent)` with +`contract: "n/a"` to `UNRESOLVED`, which has not been measured end to end, and +the 30-trial-per-arm L1 `review-pull-request` model suite was not rerun on the +final patch. Model-free validation checks layout, schema, source hashes, read-guard coverage, and experiment selection. It does not establish adjudication quality. A From 9b908d612c9485252d35e37f92b34f7c8488ce37 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Wed, 11 Nov 2026 13:14:34 -0600 Subject: [PATCH 04/23] Trim review-candidate-verifier AI source fixtures to 9-file slice per root Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../AI/src/Attributes/ToolBlockAttribute.cs | 32 - .../src/Attributes/ToolParameterAttribute.cs | 16 - .../AI/src/Attributes/ToolResultAttribute.cs | 16 - .../AI/src/Blocks/ActivityContentBlock.cs | 22 - .../AI/src/Blocks/ApprovalStatus.cs | 25 - .../AI/src/Blocks/BlockLifecycleState.cs | 25 - .../Blocks/ContentBlockChangedSubscription.cs | 28 - .../AI/src/Blocks/FunctionApprovalBlock.cs | 123 ---- .../Blocks/FunctionInvocationContentBlock.cs | 63 -- .../AI/src/Blocks/RichContentBlock.cs | 45 -- .../AI/src/Blocks/RichText/BlockQuoteNode.cs | 9 - .../AI/src/Blocks/RichText/CodeBlockNode.cs | 39 -- .../AI/src/Blocks/RichText/DefinitionNode.cs | 25 - .../AI/src/Blocks/RichText/EmphasisNode.cs | 9 - .../Blocks/RichText/FootnoteDefinitionNode.cs | 19 - .../AI/src/Blocks/RichText/FootnoteNode.cs | 14 - .../Blocks/RichText/FootnoteReferenceNode.cs | 19 - .../AI/src/Blocks/RichText/HeadingNode.cs | 31 - .../AI/src/Blocks/RichText/HtmlNode.cs | 32 - .../AI/src/Blocks/RichText/ImageNode.cs | 46 -- .../src/Blocks/RichText/ImageReferenceNode.cs | 25 - .../AI/src/Blocks/RichText/InlineCodeNode.cs | 32 - .../AI/src/Blocks/RichText/LineBreakNode.cs | 14 - .../AI/src/Blocks/RichText/LinkNode.cs | 39 -- .../src/Blocks/RichText/LinkReferenceNode.cs | 20 - .../AI/src/Blocks/RichText/ListItemNode.cs | 15 - .../AI/src/Blocks/RichText/ListNode.cs | 38 -- .../AI/src/Blocks/RichText/ParagraphNode.cs | 9 - .../AI/src/Blocks/RichText/ReferenceKind.cs | 25 - .../AI/src/Blocks/RichText/RichTextContent.cs | 45 -- .../AI/src/Blocks/RichText/RichTextNode.cs | 36 -- .../src/Blocks/RichText/StrikethroughNode.cs | 9 - .../AI/src/Blocks/RichText/StrongNode.cs | 9 - .../AI/src/Blocks/RichText/TableCellNode.cs | 9 - .../Blocks/RichText/TableColumnAlignment.cs | 30 - .../AI/src/Blocks/RichText/TableNode.cs | 16 - .../AI/src/Blocks/RichText/TableRowNode.cs | 9 - .../AI/src/Blocks/RichText/TextNode.cs | 32 - .../src/Blocks/RichText/ThematicBreakNode.cs | 9 - .../Components/AI/src/Blocks/UIActionBlock.cs | 101 ---- .../AI/src/Components/AgentBoundary.cs | 78 --- .../AI/src/Components/BlockContainer.cs | 30 - .../AI/src/Components/BlockRenderer.cs | 94 --- .../Components/BlockRendererRegistration.cs | 13 - .../Components/AI/src/Components/ChatPage.cs | 128 ---- .../Components/ConversationTurnRenderer.cs | 74 --- .../AI/src/Components/MessageList.cs | 204 ------- .../AI/src/Components/MessageListContext.cs | 451 -------------- .../Components/AI/src/Engine/AgentState.cs | 120 ---- .../AI/src/Engine/IConversationThread.cs | 53 -- .../Components/AI/src/Engine/UIAgentOfT.cs | 122 ---- .../Microsoft.AspNetCore.Components.AI.csproj | 45 -- .../AI/src/Pipeline/ActivityHandler.cs | 72 --- .../AI/src/Pipeline/BlockMappingContext.cs | 171 ------ .../src/Pipeline/BlockMappingPipelineLog.cs | 27 - .../AI/src/Pipeline/BlockMappingResult.cs | 57 -- .../AI/src/Pipeline/ContentBlockHandler.cs | 30 - .../src/Pipeline/FunctionApprovalHandler.cs | 60 -- .../src/Pipeline/FunctionInvocationHandler.cs | 54 -- .../AI/src/Pipeline/HandleResult.cs | 22 - .../AI/src/Pipeline/HandlerEntry.cs | 61 -- .../AI/src/Pipeline/IActiveEntry.cs | 11 - .../AI/src/Pipeline/IHandlerEntry.cs | 9 - .../AI/src/Pipeline/RichTextContentHandler.cs | 54 -- .../AI/src/Pipeline/StateMapperContext.cs | 131 ---- .../AI/src/Pipeline/TextBlockHandler.cs | 91 --- .../AI/src/Pipeline/UIActionHandler.cs | 48 -- .../AI/src/Pipeline/UIAgentOptions.cs | 104 ---- .../Components/AI/src/PublicAPI.Shipped.txt | 1 - .../Components/AI/src/PublicAPI.Unshipped.txt | 360 ----------- .../src/Components/AI/src/wwwroot/ai-chat.css | 457 -------------- .../AI/src/Attributes/ToolBlockAttribute.cs | 32 - .../src/Attributes/ToolParameterAttribute.cs | 16 - .../AI/src/Attributes/ToolResultAttribute.cs | 16 - .../AI/src/Blocks/ActivityContentBlock.cs | 22 - .../AI/src/Blocks/ApprovalStatus.cs | 25 - .../AI/src/Blocks/BlockLifecycleState.cs | 25 - .../Blocks/ContentBlockChangedSubscription.cs | 28 - .../AI/src/Blocks/FunctionApprovalBlock.cs | 123 ---- .../Blocks/FunctionInvocationContentBlock.cs | 63 -- .../AI/src/Blocks/RichContentBlock.cs | 45 -- .../AI/src/Blocks/RichText/BlockQuoteNode.cs | 9 - .../AI/src/Blocks/RichText/CodeBlockNode.cs | 39 -- .../AI/src/Blocks/RichText/DefinitionNode.cs | 25 - .../AI/src/Blocks/RichText/EmphasisNode.cs | 9 - .../Blocks/RichText/FootnoteDefinitionNode.cs | 19 - .../AI/src/Blocks/RichText/FootnoteNode.cs | 14 - .../Blocks/RichText/FootnoteReferenceNode.cs | 19 - .../AI/src/Blocks/RichText/HeadingNode.cs | 31 - .../AI/src/Blocks/RichText/HtmlNode.cs | 32 - .../AI/src/Blocks/RichText/ImageNode.cs | 46 -- .../src/Blocks/RichText/ImageReferenceNode.cs | 25 - .../AI/src/Blocks/RichText/InlineCodeNode.cs | 32 - .../AI/src/Blocks/RichText/LineBreakNode.cs | 14 - .../AI/src/Blocks/RichText/LinkNode.cs | 39 -- .../src/Blocks/RichText/LinkReferenceNode.cs | 20 - .../AI/src/Blocks/RichText/ListItemNode.cs | 15 - .../AI/src/Blocks/RichText/ListNode.cs | 38 -- .../AI/src/Blocks/RichText/ParagraphNode.cs | 9 - .../AI/src/Blocks/RichText/ReferenceKind.cs | 25 - .../AI/src/Blocks/RichText/RichTextContent.cs | 45 -- .../AI/src/Blocks/RichText/RichTextNode.cs | 36 -- .../src/Blocks/RichText/StrikethroughNode.cs | 9 - .../AI/src/Blocks/RichText/StrongNode.cs | 9 - .../AI/src/Blocks/RichText/TableCellNode.cs | 9 - .../Blocks/RichText/TableColumnAlignment.cs | 30 - .../AI/src/Blocks/RichText/TableNode.cs | 16 - .../AI/src/Blocks/RichText/TableRowNode.cs | 9 - .../AI/src/Blocks/RichText/TextNode.cs | 32 - .../src/Blocks/RichText/ThematicBreakNode.cs | 9 - .../Components/AI/src/Blocks/UIActionBlock.cs | 101 ---- .../AI/src/Components/AgentBoundary.cs | 78 --- .../AI/src/Components/BlockContainer.cs | 30 - .../AI/src/Components/BlockRenderer.cs | 94 --- .../Components/BlockRendererRegistration.cs | 13 - .../Components/AI/src/Components/ChatPage.cs | 128 ---- .../Components/ConversationTurnRenderer.cs | 74 --- .../AI/src/Components/MessageList.cs | 204 ------- .../AI/src/Components/MessageListContext.cs | 451 -------------- .../Components/AI/src/Engine/AgentState.cs | 120 ---- .../AI/src/Engine/IConversationThread.cs | 53 -- .../Components/AI/src/Engine/UIAgentOfT.cs | 122 ---- .../Microsoft.AspNetCore.Components.AI.csproj | 45 -- .../AI/src/Pipeline/ActivityHandler.cs | 72 --- .../AI/src/Pipeline/BlockMappingContext.cs | 171 ------ .../src/Pipeline/BlockMappingPipelineLog.cs | 27 - .../AI/src/Pipeline/BlockMappingResult.cs | 57 -- .../AI/src/Pipeline/ContentBlockHandler.cs | 30 - .../src/Pipeline/FunctionApprovalHandler.cs | 60 -- .../src/Pipeline/FunctionInvocationHandler.cs | 54 -- .../AI/src/Pipeline/HandleResult.cs | 22 - .../AI/src/Pipeline/HandlerEntry.cs | 61 -- .../AI/src/Pipeline/IActiveEntry.cs | 11 - .../AI/src/Pipeline/IHandlerEntry.cs | 9 - .../AI/src/Pipeline/RichTextContentHandler.cs | 54 -- .../AI/src/Pipeline/StateMapperContext.cs | 131 ---- .../AI/src/Pipeline/TextBlockHandler.cs | 91 --- .../AI/src/Pipeline/UIActionHandler.cs | 48 -- .../AI/src/Pipeline/UIAgentOptions.cs | 104 ---- .../Components/AI/src/PublicAPI.Shipped.txt | 1 - .../Components/AI/src/PublicAPI.Unshipped.txt | 360 ----------- .../src/Components/AI/src/wwwroot/ai-chat.css | 457 -------------- .../review-candidate-verifier/provenance.json | 568 ------------------ 143 files changed, 9352 deletions(-) delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolBlockAttribute.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolParameterAttribute.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolResultAttribute.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ActivityContentBlock.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ApprovalStatus.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/BlockLifecycleState.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichContentBlock.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HeadingNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HtmlNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListItemNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextContent.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrongNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableCellNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableRowNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TextNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/UIActionBlock.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/AgentBoundary.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockContainer.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRenderer.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRendererRegistration.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ChatPage.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ConversationTurnRenderer.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageList.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageListContext.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentState.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/IConversationThread.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentOfT.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ActivityHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingContext.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingResult.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ContentBlockHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandleResult.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandlerEntry.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IActiveEntry.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IHandlerEntry.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/RichTextContentHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/StateMapperContext.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/TextBlockHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIActionHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIAgentOptions.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Shipped.txt delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Unshipped.txt delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/wwwroot/ai-chat.css delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolBlockAttribute.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolParameterAttribute.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolResultAttribute.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ActivityContentBlock.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ApprovalStatus.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/BlockLifecycleState.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichContentBlock.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HeadingNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HtmlNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListItemNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextContent.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrongNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableCellNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableRowNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TextNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/UIActionBlock.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/AgentBoundary.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockContainer.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRenderer.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRendererRegistration.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ChatPage.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ConversationTurnRenderer.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageList.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageListContext.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentState.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/IConversationThread.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentOfT.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ActivityHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingContext.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingResult.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ContentBlockHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandleResult.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandlerEntry.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IActiveEntry.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IHandlerEntry.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/RichTextContentHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/StateMapperContext.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/TextBlockHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIActionHandler.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIAgentOptions.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Shipped.txt delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Unshipped.txt delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/wwwroot/ai-chat.css diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolBlockAttribute.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolBlockAttribute.cs deleted file mode 100644 index aace44de33cc..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolBlockAttribute.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Associates a typed with a tool name. -/// -/// -/// -/// [ToolBlock("get_weather")] -/// public partial class WeatherBlock : FunctionInvocationContentBlock; -/// -/// -[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] -public sealed class ToolBlockAttribute : Attribute -{ - /// - /// Initializes a new instance of . - /// - /// The function name emitted by the model. - public ToolBlockAttribute(string toolName) - { - ArgumentException.ThrowIfNullOrEmpty(toolName); - ToolName = toolName; - } - - /// - /// Gets the function name associated with the block. - /// - public string ToolName { get; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolParameterAttribute.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolParameterAttribute.cs deleted file mode 100644 index 945f0da645b7..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolParameterAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Populates a typed block property from a function-call argument. -/// -[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] -public sealed class ToolParameterAttribute : Attribute -{ - /// - /// Gets or sets the function argument name. The property name is used when omitted. - /// - public string? Name { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolResultAttribute.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolResultAttribute.cs deleted file mode 100644 index 0a1534c83e20..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Attributes/ToolResultAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Populates a typed block property from a function result. -/// -[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] -public sealed class ToolResultAttribute : Attribute -{ - /// - /// Gets or sets the result property name. The block property name is used when omitted. - /// - public string? Name { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ActivityContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ActivityContentBlock.cs deleted file mode 100644 index eb271897f57f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ActivityContentBlock.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Text.Json; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents activity or progress content that can change while a response streams. -/// -public class ActivityContentBlock : ContentBlock -{ - /// - /// Gets or sets the application-defined activity type. - /// - public string ActivityType { get; set; } = string.Empty; - - /// - /// Gets or sets the current activity payload. - /// - public JsonElement Content { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ApprovalStatus.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ApprovalStatus.cs deleted file mode 100644 index 52fbc2227e09..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ApprovalStatus.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Describes the response to a function approval request. -/// -public enum ApprovalStatus -{ - /// - /// The function is waiting for a response. - /// - Pending, - - /// - /// The function was approved. - /// - Approved, - - /// - /// The function was rejected. - /// - Rejected, -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/BlockLifecycleState.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/BlockLifecycleState.cs deleted file mode 100644 index 5fed8b70873c..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/BlockLifecycleState.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Describes where a is in its streaming lifecycle. -/// -public enum BlockLifecycleState -{ - /// - /// The block has been created but has not been emitted to the conversation yet. - /// - Pending, - - /// - /// The block is part of the conversation and can still receive updates from the model stream. - /// - Active, - - /// - /// The block is complete and will not receive further updates. - /// - Inactive, -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs deleted file mode 100644 index 1404a6957887..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a subscription to . -/// Disposing the subscription removes the callback from the block. -/// -public readonly struct ContentBlockChangedSubscription : IDisposable -{ - private readonly ContentBlock _owner; - private readonly Action _callback; - - internal ContentBlockChangedSubscription(ContentBlock owner, Action callback) - { - _owner = owner; - _callback = callback; - } - - /// - /// Removes the callback from the block it was registered on. - /// - public void Dispose() - { - _owner?.RemoveCallback(_callback); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs deleted file mode 100644 index e057416e7f06..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs +++ /dev/null @@ -1,123 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a function invocation that requires approval before the conversation can continue. -/// -/// -/// -/// if (block.Status == ApprovalStatus.Pending) -/// { -/// block.Approve(); -/// } -/// -/// -public class FunctionApprovalBlock : ContentBlock, IInteractiveBlock -{ - private readonly TaskCompletionSource _resultSource = - new(TaskCreationOptions.RunContinuationsAsynchronously); - private readonly object _responseLock = new(); - - internal FunctionApprovalBlock( - ContentBlock innerBlock, - ToolApprovalRequestContent request) - { - ArgumentNullException.ThrowIfNull(innerBlock); - InnerBlock = innerBlock; - ApprovalRequest = request; - } - - /// - /// Gets the wrapped function invocation block. - /// - public ContentBlock InnerBlock { get; } - - /// - /// Gets the function call represented by this block. - /// - public FunctionCallContent? Call => InnerBlock switch - { - FunctionInvocationContentBlock invocation => invocation.Call, - UIActionBlock action => action.Call, - _ => null, - }; - - /// - /// Gets the function result represented by this block. - /// - public FunctionResultContent? Result => InnerBlock switch - { - FunctionInvocationContentBlock invocation => invocation.Result, - UIActionBlock action => action.Result, - _ => null, - }; - - /// - /// Gets the name of the invoked tool. - /// - public string? ToolName => Call?.Name; - - /// - /// Gets the arguments supplied to the tool. - /// - public IDictionary? Arguments => Call?.Arguments; - - /// - /// Gets a value indicating whether the server produced a result. - /// - public bool HasResult => Result is not null; - - /// - /// Gets the current approval status. - /// - public ApprovalStatus Status { get; private set; } - - /// - /// Gets the approval request received from the chat client. - /// - public ToolApprovalRequestContent ApprovalRequest { get; } - - /// - /// Approves the function invocation. Only the first response is applied. - /// - public void Approve() - { - Respond(ApprovalStatus.Approved, reason: null); - } - - /// - /// Rejects the function invocation. Only the first response is applied. - /// - /// An optional explanation for the rejection. - public void Reject(string? reason = null) - { - Respond(ApprovalStatus.Rejected, reason); - } - - /// - public Task GetResultAsync(CancellationToken cancellationToken = default) - => _resultSource.Task.WaitAsync(cancellationToken); - - private void Respond(ApprovalStatus status, string? reason) - { - lock (_responseLock) - { - if (Status != ApprovalStatus.Pending) - { - return; - } - - Status = status; - var response = ApprovalRequest.CreateResponse( - approved: status == ApprovalStatus.Approved, - reason); - _resultSource.SetResult(response); - } - - NotifyChanged(); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs deleted file mode 100644 index f37022dfff01..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a server-side function invocation and its eventual result. -/// -/// -/// Custom content blocks that represent function invocations should derive from this type -/// and populate . This keeps the call, tool name, and arguments available -/// when other features, such as function approval, wrap the custom block. -/// -/// -/// -/// public sealed class WeatherContentBlock : FunctionInvocationContentBlock -/// { -/// public string? Location { get; set; } -/// } -/// -/// -public class FunctionInvocationContentBlock : ContentBlock -{ - private FunctionCallContent? _call; - - /// - /// Gets or sets the function call represented by this block. - /// - public FunctionCallContent? Call - { - get => _call; - set - { - _call = value; - if (value is not null) - { - Id = value.CallId; - } - } - } - - /// - /// Gets or sets the function result paired with . - /// - public FunctionResultContent? Result { get; set; } - - /// - /// Gets the name of the invoked tool. - /// - public string? ToolName => Call?.Name; - - /// - /// Gets the arguments supplied to the tool. - /// - public IDictionary? Arguments => Call?.Arguments; - - /// - /// Gets a value indicating whether the server produced a result. - /// - public bool HasResult => Result is not null; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichContentBlock.cs deleted file mode 100644 index 59887909b337..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichContentBlock.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// A block of conversational text. Text arrives in fragments while the model streams, -/// so the block accumulates the fragments and exposes both the raw text and the -/// paragraphs derived from it. -/// -public class RichContentBlock : ContentBlock -{ - private readonly List _segments = new(); - private string? _cachedText; - - /// - /// Gets the concatenation of every text fragment received so far. - /// - public string RawText => _cachedText ??= string.Concat(_segments); - - /// - /// Gets the structured representation of . - /// - public IReadOnlyList Content { get; internal set; } = Array.Empty(); - - /// - /// Appends a text fragment to this block. - /// - /// The fragment to append. - public void AppendText(string text) - { - ArgumentNullException.ThrowIfNull(text); - - _segments.Add(text); - _cachedText = null; - } - - internal void ReplaceContent(string text, IReadOnlyList content) - { - _segments.Clear(); - _segments.Add(text); - _cachedText = text; - Content = content; - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs deleted file mode 100644 index d92dfc5066a8..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a block quotation. -/// -public class BlockQuoteNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs deleted file mode 100644 index 34f5f5a674ea..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a block of code. -/// -public class CodeBlockNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public CodeBlockNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The code. - /// The optional language identifier. - public CodeBlockNode(string code, string? language = null) - { - ArgumentNullException.ThrowIfNull(code); - Code = code; - Language = language; - } - - /// - /// Gets or sets the language identifier. - /// - public string? Language { get; set; } - - /// - /// Gets or sets the code. - /// - public string Code { get; set; } = string.Empty; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs deleted file mode 100644 index a3b9507608b6..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a link or image reference definition. -/// -public class DefinitionNode : RichTextNode -{ - /// - /// Gets or sets the reference label. - /// - public string Label { get; set; } = string.Empty; - - /// - /// Gets or sets the target URL. - /// - public string Url { get; set; } = string.Empty; - - /// - /// Gets or sets the optional title. - /// - public string? Title { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs deleted file mode 100644 index 300932d81b29..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents emphasized text. -/// -public class EmphasisNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs deleted file mode 100644 index 7f12bf111a4d..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a footnote definition. -/// -/// -/// A mapper can use this node for labeled footnote content, such as content represented by -/// a Markdig footnote container. The core library does not parse or resolve footnote syntax. -/// -public class FootnoteDefinitionNode : RichTextNode -{ - /// - /// Gets or sets the footnote label. - /// - public string Label { get; set; } = string.Empty; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs deleted file mode 100644 index 97d4926e368c..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents footnote content supplied by an application's rich-text mapper. -/// -/// -/// Parsers model footnotes differently. For example, Markdig exposes footnote containers, -/// links, and an end-of-document footnote group. A mapper can project those parser-specific -/// objects into the footnote presentation nodes without introducing a parser dependency. -/// -public class FootnoteNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs deleted file mode 100644 index 9c67171555fb..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a footnote reference. -/// -/// -/// A mapper can use this node for a reference such as a Markdig footnote link. The core -/// library does not parse the reference or resolve its label. -/// -public class FootnoteReferenceNode : RichTextNode -{ - /// - /// Gets or sets the footnote label. - /// - public string Label { get; set; } = string.Empty; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HeadingNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HeadingNode.cs deleted file mode 100644 index bc36c95d3968..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HeadingNode.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a heading. -/// -public class HeadingNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public HeadingNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The heading level. - public HeadingNode(int level) - { - Level = level; - } - - /// - /// Gets or sets the heading level. - /// - public int Level { get; set; } = 1; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HtmlNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HtmlNode.cs deleted file mode 100644 index 8358abe5f750..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/HtmlNode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents HTML source. The default renderer displays the source as text. -/// -public class HtmlNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public HtmlNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The HTML source. - public HtmlNode(string value) - { - ArgumentNullException.ThrowIfNull(value); - Value = value; - } - - /// - /// Gets or sets the HTML source. - /// - public string Value { get; set; } = string.Empty; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageNode.cs deleted file mode 100644 index e1838c7d1fca..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageNode.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents an image. -/// -public class ImageNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public ImageNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The image URL. - /// The alternative text. - /// The optional title. - public ImageNode(string url, string? alt = null, string? title = null) - { - ArgumentNullException.ThrowIfNull(url); - Url = url; - Alt = alt; - Title = title; - } - - /// - /// Gets or sets the image URL. - /// - public string Url { get; set; } = string.Empty; - - /// - /// Gets or sets the alternative text. - /// - public string? Alt { get; set; } - - /// - /// Gets or sets the optional title. - /// - public string? Title { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs deleted file mode 100644 index 75b3c2af11aa..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a reference-style image. -/// -public class ImageReferenceNode : RichTextNode -{ - /// - /// Gets or sets the reference label. - /// - public string Label { get; set; } = string.Empty; - - /// - /// Gets or sets the alternative text. - /// - public string? Alt { get; set; } - - /// - /// Gets or sets the reference syntax. - /// - public ReferenceKind ReferenceKind { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs deleted file mode 100644 index 4be230f1651d..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents inline code. -/// -public class InlineCodeNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public InlineCodeNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The code. - public InlineCodeNode(string code) - { - ArgumentNullException.ThrowIfNull(code); - Code = code; - } - - /// - /// Gets or sets the code. - /// - public string Code { get; set; } = string.Empty; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs deleted file mode 100644 index 3d62aabab60f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a forced visual line break. -/// -/// -/// This node does not encode a parser-specific soft or hard line-ending distinction. A -/// mapper from Markdig or any other parser decides whether a source line ending becomes -/// whitespace, text, or a . -/// -public class LineBreakNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkNode.cs deleted file mode 100644 index 8542750d2168..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkNode.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a hyperlink. -/// -public class LinkNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public LinkNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The link URL. - /// The optional title. - public LinkNode(string url, string? title = null) - { - ArgumentNullException.ThrowIfNull(url); - Url = url; - Title = title; - } - - /// - /// Gets or sets the link URL. - /// - public string Url { get; set; } = string.Empty; - - /// - /// Gets or sets the optional title. - /// - public string? Title { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs deleted file mode 100644 index 16a71493402f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a reference-style link. -/// -public class LinkReferenceNode : RichTextNode -{ - /// - /// Gets or sets the reference label. - /// - public string Label { get; set; } = string.Empty; - - /// - /// Gets or sets the reference syntax. - /// - public ReferenceKind ReferenceKind { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListItemNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListItemNode.cs deleted file mode 100644 index a85200b58442..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListItemNode.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a list item. -/// -public class ListItemNode : RichTextNode -{ - /// - /// Gets or sets the checked state when the item is a task. - /// - public bool? Checked { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListNode.cs deleted file mode 100644 index 6c7d263e6143..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ListNode.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents an ordered or unordered list. -/// -public class ListNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public ListNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// Whether the list is ordered. - /// The optional starting number. - public ListNode(bool ordered, int? start = null) - { - Ordered = ordered; - Start = start; - } - - /// - /// Gets or sets a value indicating whether the list is ordered. - /// - public bool Ordered { get; set; } - - /// - /// Gets or sets the starting number of an ordered list. - /// - public int? Start { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs deleted file mode 100644 index 7b105148c32d..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a paragraph. -/// -public class ParagraphNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs deleted file mode 100644 index 16486d946fa2..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Describes the syntax used by a reference. -/// -public enum ReferenceKind -{ - /// - /// A shortcut reference. - /// - Shortcut, - - /// - /// A collapsed reference. - /// - Collapsed, - - /// - /// A full reference. - /// - Full, -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextContent.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextContent.cs deleted file mode 100644 index ea65d1dd4748..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextContent.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a complete snapshot of structured text in a streaming chat response. -/// -/// -/// Providers can emit a new snapshot as text streams. The block mapping pipeline replaces -/// the previous snapshot without exposing a partially mutated tree to renderers. -/// The constructor copies the top-level node list, but the nodes themselves remain shared. -/// Callers must not mutate nodes after publishing the content. -/// -public class RichTextContent : AIContent -{ - /// - /// Initializes a new instance of . - /// - /// The plain-text representation of the content. - /// - /// The structured nodes that represent . The constructor copies this - /// list but does not clone the nodes. - /// - public RichTextContent(string text, IReadOnlyList nodes) - { - ArgumentNullException.ThrowIfNull(text); - ArgumentNullException.ThrowIfNull(nodes); - - Text = text; - Nodes = [.. nodes]; - } - - /// - /// Gets the plain-text representation of the content. - /// - public string Text { get; } - - /// - /// Gets the structured nodes that represent . - /// - public IReadOnlyList Nodes { get; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextNode.cs deleted file mode 100644 index 7c66c897d9fa..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/RichTextNode.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a node in structured conversational text. -/// -/// -/// This hierarchy describes presentation semantics and does not prescribe a source format -/// or parser. Applications can map output from Markdig or any other parser into these nodes. -/// The mapper is responsible for interpreting source syntax, resolving references, and -/// deciding which presentation node represents each source construct. -/// -public abstract class RichTextNode -{ - private List? _children; - - /// - /// Gets the child nodes. - /// - public IReadOnlyList Children => - _children ?? (IReadOnlyList)Array.Empty(); - - /// - /// Adds a child node. - /// - /// The child to add. - public void AddChild(RichTextNode child) - { - ArgumentNullException.ThrowIfNull(child); - - _children ??= new(); - _children.Add(child); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs deleted file mode 100644 index adac69763c9f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents struck-through text. -/// -public class StrikethroughNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrongNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrongNode.cs deleted file mode 100644 index b2c12926d787..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/StrongNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents strongly emphasized text. -/// -public class StrongNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableCellNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableCellNode.cs deleted file mode 100644 index 79e42f2743d5..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableCellNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a table cell. -/// -public class TableCellNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs deleted file mode 100644 index e5bcad07eff7..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Describes the alignment of a table column. -/// -public enum TableColumnAlignment -{ - /// - /// No alignment was specified. - /// - None, - - /// - /// Left-aligned. - /// - Left, - - /// - /// Center-aligned. - /// - Center, - - /// - /// Right-aligned. - /// - Right, -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableNode.cs deleted file mode 100644 index e819464fe62f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableNode.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a table. -/// -public class TableNode : RichTextNode -{ - /// - /// Gets or sets each column's alignment. - /// - public IReadOnlyList Alignment { get; set; } = - Array.Empty(); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableRowNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableRowNode.cs deleted file mode 100644 index e09ce01bb34f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TableRowNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a table row. -/// -public class TableRowNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TextNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TextNode.cs deleted file mode 100644 index 958be5d930d2..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/TextNode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents plain text. -/// -public class TextNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public TextNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The text. - public TextNode(string text) - { - ArgumentNullException.ThrowIfNull(text); - Text = text; - } - - /// - /// Gets or sets the text. - /// - public string Text { get; set; } = string.Empty; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs deleted file mode 100644 index e465c724a625..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a thematic break. -/// -public class ThematicBreakNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/UIActionBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/UIActionBlock.cs deleted file mode 100644 index 6389624516e7..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/UIActionBlock.cs +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a function call that must execute in the UI before the conversation can continue. -/// -/// -/// Register the corresponding function with -/// . Renderers can call -/// to execute it in the current UI circuit. -/// -/// -/// -/// <BlockRenderer TBlock="UIActionBlock" Context="action"> -/// <button @onclick="() => action.InvokeAsync()">Run</button> -/// </BlockRenderer> -/// -/// -public class UIActionBlock : ContentBlock, IInteractiveBlock -{ - private readonly AIFunction _function; - private readonly TaskCompletionSource _resultSource = - new(TaskCreationOptions.RunContinuationsAsynchronously); - private readonly object _invocationLock = new(); - private Task? _invocation; - - internal UIActionBlock(AIFunction function, FunctionCallContent call) - { - _function = function; - Call = call; - } - - /// - /// Gets the function call requested by the model. - /// - public FunctionCallContent Call { get; } - - /// - /// Gets the registered UI action name. - /// - public string ToolName => Call.Name; - - /// - /// Gets the function result after the action completes. - /// - public FunctionResultContent? Result { get; private set; } - - /// - /// Gets a value indicating whether the action completed successfully. - /// - public bool IsComplete => Result is not null; - - /// - /// Executes the registered function once using the arguments supplied by the model. - /// - /// - /// A token that cancels the action when this call starts it. Subsequent calls return the - /// existing invocation task and do not replace its cancellation token. - /// - /// A task that completes when the action has finished. - public Task InvokeAsync(CancellationToken cancellationToken = default) - { - lock (_invocationLock) - { - _invocation ??= InvokeCoreAsync(cancellationToken); - return _invocation; - } - } - - /// - public Task GetResultAsync(CancellationToken cancellationToken = default) - => _resultSource.Task.WaitAsync(cancellationToken); - - private async Task InvokeCoreAsync(CancellationToken cancellationToken) - { - try - { - var arguments = Call.Arguments is not null - ? new AIFunctionArguments(Call.Arguments) - : null; - var result = await _function.InvokeAsync(arguments, cancellationToken); - Result = new FunctionResultContent(Call.CallId ?? Id, result); - NotifyChanged(); - _resultSource.TrySetResult(Result); - } - catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) - { - _resultSource.TrySetCanceled(cancellationToken); - throw; - } - catch (Exception exception) - { - _resultSource.TrySetException(exception); - throw; - } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/AgentBoundary.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/AgentBoundary.cs deleted file mode 100644 index 11712b97b29f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/AgentBoundary.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Components.Rendering; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Creates the for a and cascades it to the -/// chat components underneath it. -/// -public class AgentBoundary : ComponentBase, IDisposable -{ - private AgentContext _context = default!; - private UIAgent _currentAgent = default!; - - /// - /// Gets or sets the agent that drives the conversation. - /// - [Parameter, EditorRequired] - public UIAgent Agent { get; set; } = default!; - - /// - /// Gets or sets the content rendered inside the boundary. - /// - [Parameter] - public RenderFragment? ChildContent { get; set; } - - /// - protected override void OnInitialized() - { - _currentAgent = Agent; - _context = new AgentContext(Agent); - } - - /// - protected override void OnParametersSet() - { - if (!ReferenceEquals(Agent, _currentAgent)) - { - // Agent changed — tear down the old context and create a new one. - // BuildRenderTree uses OpenRegion keyed on the context, so Blazor will - // also tear down and recreate all descendant components. - _context?.Dispose(); - _currentAgent = Agent; - _context = new AgentContext(Agent); - } - } - - /// - protected override void BuildRenderTree(RenderTreeBuilder builder) - { - // If Agent changes, the region key changes, causing Blazor to tear down - // and recreate all descendants. This is the same trick EditForm uses with - // EditContext. It lets us safely use IsFixed=true on the CascadingValue. - builder.OpenRegion(_context.GetHashCode()); - - builder.OpenComponent>(0); - builder.AddComponentParameter(1, "Value", _context); - builder.AddComponentParameter(2, "IsFixed", true); - builder.AddComponentParameter(3, "ChildContent", (RenderFragment)(inner => - { - inner.AddContent(10, ChildContent); - })); - builder.CloseComponent(); - - builder.CloseRegion(); - } - - /// - /// Disposes the owned by this boundary. - /// - public void Dispose() - { - _context?.Dispose(); - GC.SuppressFinalize(this); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockContainer.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockContainer.cs deleted file mode 100644 index f26a04e57ab0..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockContainer.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -// Renders a single block and re-renders the message list when the block changes. -internal class BlockContainer : IDisposable -{ - private readonly ContentBlock _block; - private readonly MessageListContext _listContext; - private readonly ContentBlockChangedSubscription _changedSub; - - internal BlockContainer(ContentBlock block, MessageListContext listContext, Action requestRender) - { - _block = block; - _listContext = listContext; - _changedSub = block.OnChanged(requestRender); - } - - internal void RenderTo(Rendering.RenderTreeBuilder builder, int seq) - { - var fragment = _listContext.RenderBlock(_block); - builder.AddContent(seq, fragment); - } - - public void Dispose() - { - _changedSub.Dispose(); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRenderer.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRenderer.cs deleted file mode 100644 index 7a3492a7255e..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRenderer.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Registers custom markup for a block type inside a . The most -/// recently registered renderer that matches a block wins. -/// -/// The block type this renderer handles. -/// -/// -/// <MessageList> -/// <BlockRenderer TBlock="RichContentBlock" Context="block"> -/// <p>@block.RawText</p> -/// </BlockRenderer> -/// </MessageList> -/// -/// -public class BlockRenderer : IComponent, IDisposable where TBlock : ContentBlock -{ - private RenderHandle _renderHandle; - private bool _initialized; - private BlockRendererRegistration? _registration; - - /// - /// Gets or sets the message list this renderer registers with. - /// - [CascadingParameter] - public MessageListContext ListContext { get; set; } = default!; - - /// - /// Gets or sets the markup rendered for a matching block. - /// - [Parameter] - public RenderFragment? ChildContent { get; set; } - - /// - /// Gets or sets a predicate that narrows which blocks this renderer handles. - /// - [Parameter] - public Func? When { get; set; } - - void IComponent.Attach(RenderHandle renderHandle) - { - _renderHandle = renderHandle; - } - - Task IComponent.SetParametersAsync(ParameterView parameters) - { - parameters.SetParameterProperties(this); - - if (ListContext is null) - { - throw new InvalidOperationException( - "BlockRenderer must be placed inside a MessageList."); - } - - if (ChildContent is null) - { - throw new InvalidOperationException("BlockRenderer requires child content."); - } - - if (!_initialized) - { - _initialized = true; - - _registration = new BlockRendererRegistration - { - BlockType = typeof(TBlock), - // Capture 'this' so the lambda reads the latest When/ChildContent at invocation time - When = block => block is TBlock typed && (When is null || When(typed)), - Render = block => ChildContent((TBlock)block) - }; - - ListContext.AddRegistration(_registration); - } - - return Task.CompletedTask; - } - - /// - /// Removes this renderer from the message list. - /// - public void Dispose() - { - if (_registration is not null) - { - ListContext?.RemoveRegistration(_registration); - } - - GC.SuppressFinalize(this); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRendererRegistration.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRendererRegistration.cs deleted file mode 100644 index b876c68cb91f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/BlockRendererRegistration.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -internal class BlockRendererRegistration -{ - public required Type BlockType { get; init; } - - public Func? When { get; init; } - - public required Func Render { get; init; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ChatPage.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ChatPage.cs deleted file mode 100644 index e40835a996e1..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ChatPage.cs +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Components.Rendering; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Full page chat shell: an around a scrollable -/// and a . -/// -/// -/// -/// <ChatPage Agent="agent" Placeholder="Ask me anything" /> -/// -/// -public sealed class ChatPage : ComponentBase -{ - /// - /// Gets or sets the agent that drives the conversation. - /// - [Parameter, EditorRequired] - public UIAgent Agent { get; set; } = default!; - - /// - /// Gets or sets the content rendered above the conversation. - /// - [Parameter] - public RenderFragment? Header { get; set; } - - /// - /// Gets or sets the content rendered when the conversation is empty. - /// - [Parameter] - public RenderFragment? WelcomeContent { get; set; } - - /// - /// Gets or sets the content rendered inside the message list, typically - /// registrations. - /// - [Parameter] - public RenderFragment? MessageListContent { get; set; } - - /// - /// Gets or sets the placeholder text of the message input. - /// - [Parameter] - public string? Placeholder { get; set; } - - /// - /// Gets or sets the content rendered before the message input text area. - /// - [Parameter] - public RenderFragment? InputLeadingActions { get; set; } - - /// - /// Gets or sets the content rendered after the message input text area. - /// - [Parameter] - public RenderFragment? InputTrailingActions { get; set; } - - /// - /// Gets or sets additional attributes applied to the root element. - /// - [Parameter(CaptureUnmatchedValues = true)] - public Dictionary? AdditionalAttributes { get; set; } - - /// - protected override void BuildRenderTree(RenderTreeBuilder builder) - { - builder.OpenElement(0, "div"); - builder.AddMultipleAttributes(1, AdditionalAttributes); - builder.AddAttribute(2, "class", CssClass()); - - if (Header is not null) - { - builder.OpenElement(10, "div"); - builder.AddAttribute(11, "class", "sc-ai-chat-page__header"); - builder.AddContent(12, Header); - builder.CloseElement(); - } - - builder.OpenComponent(20); - builder.AddComponentParameter(21, "Agent", Agent); - builder.AddComponentParameter(22, "ChildContent", (RenderFragment)(inner => - { - // Body (scrollable area) - inner.OpenElement(30, "div"); - inner.AddAttribute(31, "class", "sc-ai-chat-page__body"); - - inner.OpenComponent(32); - inner.AddComponentParameter(33, "ChildContent", MessageListContent); - inner.AddComponentParameter(34, "EmptyContent", WelcomeContent); - inner.CloseComponent(); // MessageList - - inner.CloseElement(); // body - - // Footer (input area) - inner.OpenElement(50, "div"); - inner.AddAttribute(51, "class", "sc-ai-chat-page__footer"); - inner.OpenElement(52, "div"); - inner.AddAttribute(53, "class", "sc-ai-chat-page__input-container"); - - inner.OpenComponent(54); - inner.AddComponentParameter(55, "Placeholder", Placeholder); - inner.AddComponentParameter(56, "LeadingActions", InputLeadingActions); - inner.AddComponentParameter(57, "TrailingActions", InputTrailingActions); - inner.CloseComponent(); // MessageInput - - inner.CloseElement(); // input-container - inner.CloseElement(); // footer - })); - builder.CloseComponent(); // AgentBoundary - - builder.CloseElement(); // root div - } - - private string CssClass() - { - var css = "sc-ai-root sc-ai-chat-page"; - if (AdditionalAttributes?.TryGetValue("class", out var existing) == true && existing is string s) - { - css = $"{css} {s}"; - } - - return css; - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ConversationTurnRenderer.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ConversationTurnRenderer.cs deleted file mode 100644 index a3666f9aef00..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/ConversationTurnRenderer.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Components.Rendering; - -namespace Microsoft.AspNetCore.Components.AI; - -// Renders one conversation turn: its request blocks followed by its response blocks. -internal class ConversationTurnRenderer : IDisposable -{ - private readonly ConversationTurn _turn; - private readonly MessageListContext _listContext; - private readonly Action _requestRender; - private readonly List _blockContainers = new(); - private readonly IDisposable? _blockAddedSub; - - internal ConversationTurnRenderer( - AgentContext agentContext, - ConversationTurn turn, - MessageListContext listContext, - Action requestRender) - { - _turn = turn; - _listContext = listContext; - _requestRender = requestRender; - - _blockAddedSub = agentContext.RegisterOnBlockAdded((t, block) => - { - if (ReferenceEquals(t, _turn)) - { - OnBlockAdded(block); - } - }); - - foreach (var block in turn.RequestBlocks) - { - _blockContainers.Add(new BlockContainer(block, _listContext, _requestRender)); - } - foreach (var block in turn.ResponseBlocks) - { - _blockContainers.Add(new BlockContainer(block, _listContext, _requestRender)); - } - } - - private void OnBlockAdded(ContentBlock block) - { - _blockContainers.Add(new BlockContainer(block, _listContext, _requestRender)); - _requestRender(); - } - - internal void RenderTo(RenderTreeBuilder builder, int baseSeq) - { - // Determine role from request blocks (user turn) or response blocks - var role = _turn.RequestBlocks.Count > 0 ? "user" : "assistant"; - builder.OpenElement(baseSeq, "div"); - builder.AddAttribute(baseSeq + 1, "class", $"sc-ai-turn sc-ai-turn--{role}"); - var seq = baseSeq + 10; - foreach (var container in _blockContainers) - { - container.RenderTo(builder, seq); - seq += 10; - } - builder.CloseElement(); - } - - public void Dispose() - { - _blockAddedSub?.Dispose(); - foreach (var container in _blockContainers) - { - container.Dispose(); - } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageList.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageList.cs deleted file mode 100644 index 70e703f29806..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageList.cs +++ /dev/null @@ -1,204 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Components.Rendering; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Renders the turns of the cascaded and updates them as blocks -/// stream in. -/// -[StreamRendering] -public class MessageList : IComponent, IDisposable -{ - private RenderHandle _renderHandle; - private AgentContext _agentContext = default!; - private RenderFragment? _childContent; - private RenderFragment? _footer; - private readonly MessageListContext _listContext = new(); - private readonly List _turnRenderers = new(); - private IDisposable? _turnAddedSub; - private IDisposable? _statusChangedSub; - - /// - /// Gets or sets the conversation rendered by this list. - /// - [CascadingParameter] - public AgentContext AgentContext { get; set; } = default!; - - /// - /// Gets or sets the content rendered above the turns. Use it to register - /// components. - /// - [Parameter] - public RenderFragment? ChildContent { get; set; } - - /// - /// Gets or sets the content rendered when the conversation has no turns. - /// - [Parameter] - public RenderFragment? EmptyContent { get; set; } - - /// - /// Gets or sets the content rendered below the turns. Defaults to the streaming and error - /// indicators. - /// - [Parameter] - public RenderFragment? Footer { get; set; } - - void IComponent.Attach(RenderHandle renderHandle) - { - _renderHandle = renderHandle; - } - - Task IComponent.SetParametersAsync(ParameterView parameters) - { - parameters.SetParameterProperties(this); - var newAgentContext = AgentContext - ?? throw new InvalidOperationException( - "MessageList must be inside an AgentBoundary."); - - if (!ReferenceEquals(_agentContext, newAgentContext)) - { - ResetRegistrations(); - _agentContext = newAgentContext; - _listContext.OnRegistrationsChanged = Render; - - _turnAddedSub = _agentContext.RegisterOnTurnAdded(OnTurnAdded); - _statusChangedSub = _agentContext.RegisterOnStatusChanged(_ => Render()); - - foreach (var turn in _agentContext.Turns) - { - var renderer = new ConversationTurnRenderer( - _agentContext, turn, _listContext, Render); - _turnRenderers.Add(renderer); - } - } - - _childContent = ChildContent; - _footer = Footer; - - Render(); - return Task.CompletedTask; - } - - private void OnTurnAdded(ConversationTurn turn) - { - var renderer = new ConversationTurnRenderer( - _agentContext, turn, _listContext, Render); - _turnRenderers.Add(renderer); - Render(); - } - - private void Render() - { - _renderHandle.Render(builder => - { - builder.OpenComponent>(0); - builder.AddComponentParameter(1, "Value", _listContext); - builder.AddComponentParameter(2, "IsFixed", true); - builder.AddComponentParameter(3, "ChildContent", - (RenderFragment)(inner => - { - inner.OpenElement(3, "div"); - inner.AddAttribute(3, "class", "sc-ai-message-list"); - if (_childContent is not null) - { - inner.AddContent(4, _childContent); - } - - if (_turnRenderers.Count == 0 && EmptyContent is not null) - { - inner.AddContent(5, EmptyContent); - } - - var seq = 100; - foreach (var turnRenderer in _turnRenderers) - { - turnRenderer.RenderTo(inner, seq); - seq += 100; - } - - inner.OpenElement(seq, "div"); - inner.AddAttribute(seq + 1, "class", "sc-ai-message-list__footer"); - if (_footer is not null) - { - inner.AddContent(seq + 2, _footer(_agentContext)); - } - else - { - RenderDefaultFooter(inner, seq + 2); - } - inner.CloseElement(); // footer div - - inner.CloseElement(); // sc-ai-message-list div - })); - builder.CloseComponent(); - }); - } - - private void RenderDefaultFooter(RenderTreeBuilder builder, int seq) - { - switch (_agentContext.Status) - { - case ConversationStatus.Streaming: - builder.OpenElement(seq, "div"); - builder.AddAttribute(seq + 1, "class", "sc-ai-typing"); - builder.AddAttribute(seq + 2, "role", "status"); - builder.AddAttribute(seq + 3, "aria-label", "Agent is typing"); - for (var i = 0; i < 3; i++) - { - builder.OpenElement(seq + 4 + i, "span"); - builder.AddAttribute(seq + 7 + i, "class", "sc-ai-typing__dot"); - builder.CloseElement(); - } - builder.CloseElement(); - break; - - case ConversationStatus.Error: - builder.OpenElement(seq, "div"); - builder.AddAttribute(seq + 1, "class", "sc-ai-error"); - builder.AddAttribute(seq + 2, "role", "alert"); - builder.OpenElement(seq + 3, "span"); - builder.AddAttribute(seq + 4, "class", "sc-ai-error__message"); - builder.AddContent(seq + 5, "Something went wrong. Please try again."); - builder.CloseElement(); // span - builder.OpenElement(seq + 6, "button"); - builder.AddAttribute(seq + 7, "type", "button"); - builder.AddAttribute(seq + 8, "class", "sc-ai-btn sc-ai-btn--secondary"); - builder.AddAttribute(seq + 9, "onclick", - EventCallback.Factory.Create(this, - () => _agentContext.RetryAsync())); - builder.AddContent(seq + 10, "Retry"); - builder.CloseElement(); // button - builder.CloseElement(); // div - break; - } - } - - private void ResetRegistrations() - { - _turnAddedSub?.Dispose(); - _turnAddedSub = null; - - _statusChangedSub?.Dispose(); - _statusChangedSub = null; - - foreach (var renderer in _turnRenderers) - { - renderer.Dispose(); - } - - _turnRenderers.Clear(); - } - - /// - /// Removes the subscriptions this list registered on the conversation. - /// - public void Dispose() - { - ResetRegistrations(); - GC.SuppressFinalize(this); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageListContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageListContext.cs deleted file mode 100644 index b262655f5864..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageListContext.cs +++ /dev/null @@ -1,451 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Components.Rendering; -using Microsoft.Extensions.AI; -using System.Text.Json; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Resolves the markup used to render a block inside a . Renderers -/// registered with take precedence over the built-in -/// rendering. -/// -public class MessageListContext -{ - private static readonly JsonSerializerOptions IndentedJsonOptions = new() - { - WriteIndented = true, - }; - - private readonly List _registrations = new(); - - /// - /// Returns the markup for a block. - /// - /// The block to render. - /// The markup that renders . - public RenderFragment RenderBlock(ContentBlock block) - { - ArgumentNullException.ThrowIfNull(block); - - for (var i = _registrations.Count - 1; i >= 0; i--) - { - var reg = _registrations[i]; - if (reg.BlockType.IsAssignableFrom(block.GetType()) - && (reg.When is null || reg.When(block))) - { - return reg.Render(block); - } - } - - return builder => - { - if (block is RichContentBlock rich) - { - var role = block.Role == ChatRole.User ? "user" : "assistant"; - builder.OpenElement(0, "div"); - builder.AddAttribute(1, "class", $"sc-ai-message sc-ai-message--{role}"); - builder.OpenElement(2, "div"); - builder.AddAttribute(3, "class", "sc-ai-message__bubble"); - builder.OpenElement(4, "div"); - var contentClass = block.LifecycleState == BlockLifecycleState.Active - ? "sc-ai-message__content sc-ai-message__content--streaming" - : "sc-ai-message__content"; - builder.AddAttribute(5, "class", contentClass); - if (rich.Content.Count > 0) - { - RenderRichTextNodes(builder, rich.Content); - } - else - { - builder.AddContent(6, rich.RawText); - } - builder.CloseElement(); // content div - builder.CloseElement(); // bubble div - builder.CloseElement(); // message div - } - else if (block is FunctionApprovalBlock approval) - { - RenderApprovalBlock(builder, approval); - } - else if (block is not FunctionInvocationContentBlock) - { - builder.OpenElement(0, "div"); - builder.AddAttribute(1, "class", "sc-ai-unknown-block"); - builder.AddContent(2, block.GetType().Name); - builder.CloseElement(); - } - }; - } - - internal Action? OnRegistrationsChanged { get; set; } - - internal void AddRegistration(BlockRendererRegistration registration) - { - _registrations.Add(registration); - OnRegistrationsChanged?.Invoke(); - } - - internal void RemoveRegistration(BlockRendererRegistration registration) - { - _registrations.Remove(registration); - OnRegistrationsChanged?.Invoke(); - } - - private static void RenderRichTextNodes( - RenderTreeBuilder builder, - IReadOnlyList nodes) - { - foreach (var node in nodes) - { - builder.OpenRegion(0); - RenderRichTextNode(builder, node); - builder.CloseRegion(); - } - } - - private static void RenderRichTextNode(RenderTreeBuilder builder, RichTextNode node) - { - switch (node) - { - case TextNode text: - builder.AddContent(0, text.Text); - break; - case ParagraphNode: - RenderElement(builder, "p", "sc-ai-rich-text__paragraph", node.Children); - break; - case HeadingNode heading: - RenderElement( - builder, - $"h{Math.Clamp(heading.Level, 1, 6)}", - "sc-ai-rich-text__heading", - node.Children); - break; - case EmphasisNode: - RenderElement(builder, "em", null, node.Children); - break; - case StrongNode: - RenderElement(builder, "strong", null, node.Children); - break; - case StrikethroughNode: - RenderElement(builder, "s", null, node.Children); - break; - case InlineCodeNode inlineCode: - builder.OpenElement(0, "code"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__inline-code"); - builder.AddContent(2, inlineCode.Code); - builder.CloseElement(); - break; - case CodeBlockNode codeBlock: - builder.OpenElement(0, "pre"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__code-block"); - builder.OpenElement(2, "code"); - if (!string.IsNullOrEmpty(codeBlock.Language)) - { - builder.AddAttribute(3, "data-language", codeBlock.Language); - } - builder.AddContent(4, codeBlock.Code); - builder.CloseElement(); - builder.CloseElement(); - break; - case BlockQuoteNode: - RenderElement(builder, "blockquote", "sc-ai-rich-text__quote", node.Children); - break; - case LineBreakNode: - builder.OpenElement(0, "br"); - builder.CloseElement(); - break; - case ThematicBreakNode: - builder.OpenElement(0, "hr"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__thematic-break"); - builder.CloseElement(); - break; - case ListNode list: - builder.OpenElement(0, list.Ordered ? "ol" : "ul"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__list"); - if (list.Ordered && list.Start is not null) - { - builder.AddAttribute(2, "start", list.Start.Value); - } - RenderRichTextNodes(builder, list.Children); - builder.CloseElement(); - break; - case ListItemNode item: - builder.OpenElement(0, "li"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__list-item"); - if (item.Checked is not null) - { - builder.OpenElement(2, "input"); - builder.AddAttribute(3, "type", "checkbox"); - builder.AddAttribute(4, "disabled", true); - if (item.Checked.Value) - { - builder.AddAttribute(5, "checked", true); - } - builder.CloseElement(); - } - RenderRichTextNodes(builder, item.Children); - builder.CloseElement(); - break; - case LinkNode link: - RenderLink(builder, link); - break; - case ImageNode image: - RenderImage(builder, image); - break; - case DefinitionNode definition: - builder.OpenElement(0, "span"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__definition"); - builder.AddContent(2, $"[{definition.Label}]: {definition.Url}"); - builder.CloseElement(); - break; - case LinkReferenceNode linkReference: - RenderReference(builder, linkReference.Label, linkReference.Children); - break; - case ImageReferenceNode imageReference: - builder.OpenElement(0, "span"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__image-reference"); - builder.AddContent(2, imageReference.Alt ?? imageReference.Label); - builder.CloseElement(); - break; - case FootnoteNode: - RenderElement(builder, "aside", "sc-ai-rich-text__footnote", node.Children); - break; - case FootnoteReferenceNode footnoteReference: - builder.OpenElement(0, "sup"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__footnote-reference"); - builder.AddContent(2, footnoteReference.Label); - builder.CloseElement(); - break; - case FootnoteDefinitionNode footnoteDefinition: - builder.OpenElement(0, "aside"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__footnote-definition"); - builder.AddAttribute(2, "data-label", footnoteDefinition.Label); - RenderRichTextNodes(builder, footnoteDefinition.Children); - builder.CloseElement(); - break; - case HtmlNode html: - builder.OpenElement(0, "code"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__html"); - builder.AddContent(2, html.Value); - builder.CloseElement(); - break; - case TableNode table: - RenderTable(builder, table); - break; - case TableRowNode: - case TableCellNode: - RenderRichTextNodes(builder, node.Children); - break; - default: - RenderRichTextNodes(builder, node.Children); - break; - } - } - - private static void RenderElement( - RenderTreeBuilder builder, - string elementName, - string? className, - IReadOnlyList children) - { - builder.OpenElement(0, elementName); - if (className is not null) - { - builder.AddAttribute(1, "class", className); - } - RenderRichTextNodes(builder, children); - builder.CloseElement(); - } - - private static void RenderLink(RenderTreeBuilder builder, LinkNode link) - { - var safeUrl = GetSafeUrl(link.Url, allowMailTo: true); - if (safeUrl is null) - { - RenderRichTextNodes(builder, link.Children); - return; - } - - builder.OpenElement(0, "a"); - builder.AddAttribute(1, "href", safeUrl); - if (link.Title is not null) - { - builder.AddAttribute(2, "title", link.Title); - } - RenderRichTextNodes(builder, link.Children); - builder.CloseElement(); - } - - private static void RenderImage(RenderTreeBuilder builder, ImageNode image) - { - var safeUrl = GetSafeUrl(image.Url, allowMailTo: false); - if (safeUrl is null) - { - builder.AddContent(0, image.Alt); - return; - } - - builder.OpenElement(0, "img"); - builder.AddAttribute(1, "src", safeUrl); - builder.AddAttribute(2, "alt", image.Alt ?? string.Empty); - if (image.Title is not null) - { - builder.AddAttribute(3, "title", image.Title); - } - builder.CloseElement(); - } - - private static void RenderReference( - RenderTreeBuilder builder, - string label, - IReadOnlyList children) - { - builder.OpenElement(0, "span"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__link-reference"); - if (children.Count > 0) - { - RenderRichTextNodes(builder, children); - } - else - { - builder.AddContent(2, label); - } - builder.CloseElement(); - } - - private static void RenderTable(RenderTreeBuilder builder, TableNode table) - { - builder.OpenElement(0, "div"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__table-container"); - builder.OpenElement(2, "table"); - builder.AddAttribute(3, "class", "sc-ai-rich-text__table"); - builder.OpenElement(4, "tbody"); - - foreach (var child in table.Children) - { - if (child is not TableRowNode row) - { - continue; - } - - builder.OpenRegion(5); - builder.OpenElement(0, "tr"); - var columnIndex = 0; - foreach (var rowChild in row.Children) - { - if (rowChild is not TableCellNode cell) - { - continue; - } - - builder.OpenRegion(1); - builder.OpenElement(0, "td"); - if (columnIndex < table.Alignment.Count && - table.Alignment[columnIndex] != TableColumnAlignment.None) - { - builder.AddAttribute( - 1, - "class", - $"sc-ai-rich-text__table-cell--{table.Alignment[columnIndex].ToString().ToLowerInvariant()}"); - } - RenderRichTextNodes(builder, cell.Children); - builder.CloseElement(); - builder.CloseRegion(); - columnIndex++; - } - builder.CloseElement(); - builder.CloseRegion(); - } - - builder.CloseElement(); - builder.CloseElement(); - builder.CloseElement(); - } - - private static string? GetSafeUrl(string url, bool allowMailTo) - { - if (!Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out var uri)) - { - return null; - } - - if (!uri.IsAbsoluteUri) - { - return url; - } - - if (uri.Scheme is "http" or "https" || - (allowMailTo && uri.Scheme == "mailto")) - { - return url; - } - - return null; - } - - private static void RenderApprovalBlock( - RenderTreeBuilder builder, - FunctionApprovalBlock block) - { - builder.OpenElement(0, "div"); - builder.AddAttribute(1, "class", "sc-ai-approval"); - - builder.OpenElement(2, "div"); - builder.AddAttribute(3, "class", "sc-ai-approval__header"); - builder.AddContent(4, "Approval required"); - builder.CloseElement(); - - builder.OpenElement(5, "div"); - builder.AddAttribute(6, "class", "sc-ai-approval__tool-name"); - builder.AddContent(7, block.ToolName ?? "Unknown tool"); - builder.CloseElement(); - - if (block.Arguments is { Count: > 0 }) - { - builder.OpenElement(8, "pre"); - builder.AddAttribute(9, "class", "sc-ai-approval__arguments"); - builder.AddContent(10, JsonSerializer.Serialize(block.Arguments, IndentedJsonOptions)); - builder.CloseElement(); - } - - if (block.Status == ApprovalStatus.Pending) - { - builder.OpenElement(11, "div"); - builder.AddAttribute(12, "class", "sc-ai-approval__actions"); - - builder.OpenElement(13, "button"); - builder.AddAttribute(14, "type", "button"); - builder.AddAttribute(15, "class", "sc-ai-btn sc-ai-btn--primary"); - builder.AddAttribute(16, "onclick", (Action)block.Approve); - builder.AddContent(17, "Approve"); - builder.CloseElement(); - - builder.OpenElement(18, "button"); - builder.AddAttribute(19, "type", "button"); - builder.AddAttribute(20, "class", "sc-ai-btn sc-ai-btn--secondary"); - builder.AddAttribute(21, "onclick", (Action)(() => block.Reject())); - builder.AddContent(22, "Reject"); - builder.CloseElement(); - - builder.CloseElement(); - } - else - { - var approved = block.Status == ApprovalStatus.Approved; - builder.OpenElement(23, "div"); - builder.AddAttribute( - 24, - "class", - approved - ? "sc-ai-approval__status sc-ai-approval__status--approved" - : "sc-ai-approval__status sc-ai-approval__status--rejected"); - builder.AddContent(25, approved ? "Approved" : "Rejected"); - builder.CloseElement(); - } - - builder.CloseElement(); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentState.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentState.cs deleted file mode 100644 index 294bd42fbe1f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentState.cs +++ /dev/null @@ -1,120 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Holds observable state associated with a . -/// -/// The type of state. -public class AgentState where T : class, new() -{ - private readonly List _callbacks = new(); - private T _value; - private T? _valueBeforePrediction; - - internal AgentState(T? initialValue = null) - { - _value = initialValue ?? new T(); - } - - /// - /// Gets or sets the current state value. - /// - public T Value - { - get => _value; - set - { - ArgumentNullException.ThrowIfNull(value); - _valueBeforePrediction = null; - _value = value; - NotifyChanged(); - } - } - - /// - /// Gets a value indicating whether contains provisional predictive state. - /// - public bool HasPendingPredictiveState => _valueBeforePrediction is not null; - - /// - /// Accepts the current predictive state as the committed value. - /// - public void AcceptPredictiveState() - { - if (_valueBeforePrediction is null) - { - return; - } - - _valueBeforePrediction = null; - NotifyChanged(); - } - - /// - /// Rejects the current predictive state and restores the value from before the prediction. - /// - public void RejectPredictiveState() - { - if (_valueBeforePrediction is not { } previousValue) - { - return; - } - - _valueBeforePrediction = null; - _value = previousValue; - NotifyChanged(); - } - - /// - /// Registers a callback invoked when changes. - /// - /// The callback to invoke. - /// A registration that removes the callback when disposed. - public IDisposable OnChanged(Action callback) - { - ArgumentNullException.ThrowIfNull(callback); - _callbacks.Add(callback); - return new CallbackRegistration(_callbacks, callback); - } - - internal void SetPredictiveValue(T value) - { - ArgumentNullException.ThrowIfNull(value); - _valueBeforePrediction ??= _value; - _value = value; - NotifyChanged(); - } - - private void NotifyChanged() - { - var snapshot = _callbacks.ToArray(); - foreach (var callback in snapshot) - { - callback(); - } - } - - private sealed class CallbackRegistration : IDisposable - { - private List? _callbacks; - private Action? _callback; - - internal CallbackRegistration(List callbacks, Action callback) - { - _callbacks = callbacks; - _callback = callback; - } - - public void Dispose() - { - if (_callbacks is not null && _callback is not null) - { - _callbacks.Remove(_callback); - _callbacks = null; - _callback = null; - } - } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/IConversationThread.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/IConversationThread.cs deleted file mode 100644 index 87756edd7d84..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/IConversationThread.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a persistent conversation thread that stores streamed chat updates. -/// -/// -/// Implementations control where and how conversation updates are persisted. -/// -public interface IConversationThread -{ - /// - /// Gets the unique identifier for this thread. - /// - string ThreadId { get; } - - /// - /// Gets a value indicating whether the remote service manages the conversation history. - /// - bool IsStateful { get; } - - /// - /// Gets the conversation identifier returned by a stateful remote service, if any. - /// - string? ConversationId { get; } - - /// - /// Begins a turn by appending the message sent to the chat client. - /// - /// The message that begins the turn. - void AppendUserMessage(ChatMessage message); - - /// - /// Appends an update received from the chat client to the current turn. - /// - /// The streamed update. - void AppendUpdate(ChatResponseUpdate update); - - /// - /// Commits the current turn to the stored history. - /// - void CompleteTurn(); - - /// - /// Gets all committed updates in chronological order. - /// - /// The committed updates. - IReadOnlyList GetUpdates(); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentOfT.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentOfT.cs deleted file mode 100644 index 5f10a5b1548a..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentOfT.cs +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Turns an stream into renderable content blocks and typed observable state. -/// -/// The type of state associated with the agent. -public class UIAgent : UIAgent where TState : class, new() -{ - /// - /// Initializes a new instance of the class. - /// - /// The chat client that produces model responses. - /// The initial state value. - public UIAgent(IChatClient chatClient, TState? initialState = null) - : this(chatClient, new UIAgentOptions(initialState), configure: null, loggerFactory: null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The chat client that produces model responses. - /// The options passed to the chat client. - /// The initial state value. - public UIAgent(IChatClient chatClient, ChatOptions chatOptions, TState? initialState = null) - : this( - chatClient, - new UIAgentOptions(initialState), - options => options.ChatOptions = chatOptions, - loggerFactory: null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The chat client that produces model responses. - /// A callback that configures the agent. - /// The initial state value. - public UIAgent( - IChatClient chatClient, - Action> configure, - TState? initialState = null) - : this(chatClient, new UIAgentOptions(initialState), configure, loggerFactory: null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The chat client that produces model responses. - /// A callback that configures the agent. - /// The logger factory used to trace block mapping. - /// The initial state value. - public UIAgent( - IChatClient chatClient, - Action> configure, - ILoggerFactory? loggerFactory, - TState? initialState = null) - : this(chatClient, new UIAgentOptions(initialState), configure, loggerFactory) - { - } - - private UIAgent( - IChatClient chatClient, - UIAgentOptions options, - Action>? configure, - ILoggerFactory? loggerFactory) - : base(chatClient, options, loggerFactory) - { - State = options.State; - configure?.Invoke(options); - } - - /// - /// Gets the observable state associated with this agent. - /// - public AgentState State { get; } - - internal override ChatResponseUpdate ApplyStateMapper(ChatResponseUpdate update) - { - if (Options.StateMapper is null) - { - return update; - } - - var context = new StateMapperContext(update); - Options.StateMapper(context); - - if (context.StateValue is not null) - { - if (context.StateValue is not TState typedState) - { - throw new InvalidOperationException( - $"The state mapper returned a value of type '{context.StateValue.GetType()}', " + - $"but this agent requires state of type '{typeof(TState)}'."); - } - - if (context.IsPredictiveState) - { - State.SetPredictiveValue(typedState); - } - else - { - State.Value = typedState; - } - } - - return context.HasHandledContent ? context.GetFilteredUpdate() : update; - } - - internal override void RejectPendingPredictiveState() - { - State.RejectPredictiveState(); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj deleted file mode 100644 index 06236046177b..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj +++ /dev/null @@ -1,45 +0,0 @@ - - - - $(DefaultNetCoreTargetFramework) - 0.1.0 - - $(AspNetCoreMajorMinorVersion).0.0 - enable - enable - true - true - true - Blazor component library for building AI conversational UIs on top of Microsoft.Extensions.AI. - blazor;ai;chat;components - - $(NoWarn);RS0026 - true - preview - 1 - - - - - - - - - - - - - - - - - - - - - diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ActivityHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ActivityHandler.cs deleted file mode 100644 index dd9488839c26..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ActivityHandler.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Maps activity snapshots and updates into a mutable content block. -/// -/// The activity block type. -public abstract class ActivityHandler : ContentBlockHandler - where TBlock : ActivityContentBlock, new() -{ - /// - public sealed override BlockMappingResult Handle( - BlockMappingContext context, - TBlock state) - { - if (state.Id == string.Empty) - { - if (TryCreateBlock(context, state)) - { - if (state.Id.Length == 0) - { - state.Id = context.Update.MessageId ?? Guid.NewGuid().ToString("N"); - } - - OnContentUpdated(state); - return BlockMappingResult.Emit(state, state); - } - - return BlockMappingResult.Pass(); - } - - if (TryUpdateBlock(context, state, out var isCompleted)) - { - OnContentUpdated(state); - return isCompleted - ? BlockMappingResult.Complete() - : BlockMappingResult.Update(state); - } - - return BlockMappingResult.Pass(); - } - - /// - /// Attempts to initialize a block from an activity snapshot. - /// - /// The update being mapped. - /// The block to initialize. - /// when the update created the block. - protected abstract bool TryCreateBlock(BlockMappingContext context, TBlock state); - - /// - /// Attempts to update an existing activity block. - /// - /// The update being mapped. - /// The block to update. - /// Whether the update completes the activity. - /// when the update belongs to the block. - protected abstract bool TryUpdateBlock( - BlockMappingContext context, - TBlock state, - out bool isCompleted); - - /// - /// Updates derived block state after the activity payload changes. - /// - /// The updated activity block. - protected virtual void OnContentUpdated(TBlock state) - { - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingContext.cs deleted file mode 100644 index c2262e228e97..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingContext.cs +++ /dev/null @@ -1,171 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Carries a single model update through the block mapping pipeline and tracks which -/// parts of the update handlers have already claimed. -/// -public class BlockMappingContext -{ - private readonly bool[] _handled; - private readonly IReadOnlyList? _handlers; - private int _handledCount; - private bool _updateHandled; - - internal BlockMappingContext( - ChatResponseUpdate update, - IReadOnlyList? handlers = null) - { - Update = update; - _handled = new bool[update.Contents.Count]; - _handlers = handlers; - } - - /// - /// Gets the update being mapped. - /// - public ChatResponseUpdate Update { get; } - - /// - /// Gets the contents of that no handler has claimed yet. - /// - public UnhandledContentsEnumerable UnhandledContents => new(Update.Contents, _handled); - - /// - /// Marks a content item as claimed so that later handlers do not see it. - /// - /// The content item that was handled. - public void MarkHandled(AIContent content) - { - var contents = Update.Contents; - for (var i = 0; i < contents.Count; i++) - { - if (ReferenceEquals(contents[i], content)) - { - if (!_handled[i]) - { - _handled[i] = true; - _handledCount++; - } - return; - } - } - } - - /// - /// Marks the update itself as handled. Use this for updates that carry no content items. - /// - public void MarkUpdateHandled() - { - _updateHandled = true; - } - - /// - /// Gets a value indicating whether every part of the update has been claimed. - /// - public bool AllHandled => - _handledCount >= Update.Contents.Count && (Update.Contents.Count > 0 || _updateHandled); - - internal int HandledProgress => _handledCount + (_updateHandled ? 1 : 0); - - /// - /// Maps content through the available handlers to create a nested block. - /// - /// The content to map. - /// The mapped block, or when no handler accepts the content. - public ContentBlock? CreateInnerBlock(AIContent content) - { - ArgumentNullException.ThrowIfNull(content); - - if (_handlers is null) - { - return null; - } - - var update = new ChatResponseUpdate - { - Role = Update.Role, - AuthorName = Update.AuthorName, - MessageId = Update.MessageId, - Contents = [content], - }; - var context = new BlockMappingContext(update, _handlers); - - foreach (var handler in _handlers) - { - var entry = handler.TryHandle(context); - if (entry is not null) - { - entry.Block.Role = update.Role; - entry.Block.AuthorName = update.AuthorName; - entry.Block.LifecycleState = BlockLifecycleState.Inactive; - return entry.Block; - } - } - - return null; - } - - /// - /// Enumerates the content items of an update that have not been claimed by a handler. - /// - public readonly struct UnhandledContentsEnumerable - { - private readonly IList _contents; - private readonly bool[] _handled; - - internal UnhandledContentsEnumerable(IList contents, bool[] handled) - { - _contents = contents; - _handled = handled; - } - - /// - /// Returns an enumerator over the unclaimed content items. - /// - /// An enumerator over the unclaimed content items. - public UnhandledContentsEnumerator GetEnumerator() => new(_contents, _handled); - } - - /// - /// Enumerator over the content items of an update that have not been claimed by a handler. - /// - public struct UnhandledContentsEnumerator - { - private readonly IList _contents; - private readonly bool[] _handled; - private int _index; - - internal UnhandledContentsEnumerator(IList contents, bool[] handled) - { - _contents = contents; - _handled = handled; - _index = -1; - } - - /// - /// Gets the content item at the current position. - /// - public AIContent Current => _contents[_index]; - - /// - /// Advances to the next unclaimed content item. - /// - /// if another unclaimed item exists; otherwise . - public bool MoveNext() - { - while (++_index < _contents.Count) - { - if (!_handled[_index]) - { - return true; - } - } - return false; - } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs deleted file mode 100644 index a526003ac207..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Components.AI; - -internal static partial class BlockMappingPipelineLog -{ - [LoggerMessage(1, LogLevel.Debug, "Processing update: Role={Role}, ContentCount={ContentCount}, ContentTypes=[{ContentTypes}]")] - internal static partial void ProcessingUpdate(ILogger logger, string? role, int contentCount, string contentTypes); - - [LoggerMessage(2, LogLevel.Debug, "Active handler {HandlerType} returned {ResultKind} for block {BlockId}")] - internal static partial void ActiveHandlerResult(ILogger logger, string handlerType, string resultKind, string? blockId); - - [LoggerMessage(3, LogLevel.Information, "Emitting new block: {BlockType} Id={BlockId} Role={Role}")] - internal static partial void EmittingBlock(ILogger logger, string blockType, string? blockId, string? role); - - [LoggerMessage(4, LogLevel.Debug, "Phase 2: Trying inactive handler {HandlerType} to claim remaining content")] - internal static partial void TryingInactiveHandler(ILogger logger, string handlerType); - - [LoggerMessage(5, LogLevel.Debug, "Finalize: Deactivating {ActiveCount} active blocks")] - internal static partial void Finalizing(ILogger logger, int activeCount); - - [LoggerMessage(6, LogLevel.Debug, "All content handled after active handlers, skipping Phase 2")] - internal static partial void AllContentHandledAfterPhase1(ILogger logger); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingResult.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingResult.cs deleted file mode 100644 index 4d02957ef03b..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingResult.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// The outcome of a invocation. -/// -/// The state the handler keeps across updates. -public readonly struct BlockMappingResult -{ - internal enum ResultKind { Pass, Emit, Update, Complete } - - internal ResultKind Kind { get; } - - internal ContentBlock? Block { get; } - - internal TState? State { get; } - - private BlockMappingResult(ResultKind kind, ContentBlock? block, TState? state) - { - Kind = kind; - Block = block; - State = state; - } - - /// - /// Indicates that the handler did not claim anything from the update. - /// - /// A result that leaves the update for other handlers. - public static BlockMappingResult Pass() => new(ResultKind.Pass, null, default); - - /// - /// Indicates that the handler produced a new block for the conversation. - /// - /// The block to add to the conversation. - /// The state to carry into subsequent updates. - /// A result that emits . - public static BlockMappingResult Emit(ContentBlock block, TState state) - { - ArgumentNullException.ThrowIfNull(block); - return new(ResultKind.Emit, block, state); - } - - /// - /// Indicates that the handler updated the block it previously emitted. - /// - /// The updated state. - /// A result that notifies the UI that the block changed. - public static BlockMappingResult Update(TState state) => new(ResultKind.Update, null, state); - - /// - /// Indicates that the block the handler emitted is complete. - /// - /// A result that deactivates the block. - public static BlockMappingResult Complete() => new(ResultKind.Complete, null, default); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ContentBlockHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ContentBlockHandler.cs deleted file mode 100644 index 514980c728b3..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/ContentBlockHandler.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Maps model updates into content blocks. A handler is invoked for every update until it -/// completes the block it emitted. -/// -/// The state the handler keeps across updates for a single block. -/// -/// -/// internal sealed class EchoHandler : ContentBlockHandler<RichContentBlock> -/// { -/// public override BlockMappingResult<RichContentBlock> Handle( -/// BlockMappingContext context, RichContentBlock state) -/// => BlockMappingResult<RichContentBlock>.Pass(); -/// } -/// -/// -public abstract class ContentBlockHandler where TState : new() -{ - /// - /// Handles an update. - /// - /// The update being mapped. - /// The state for the block this handler owns. - /// The outcome of the invocation. - public abstract BlockMappingResult Handle(BlockMappingContext context, TState state); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs deleted file mode 100644 index d5ff5164a434..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -internal sealed class FunctionApprovalHandler : - ContentBlockHandler -{ - public override BlockMappingResult Handle(BlockMappingContext context, State state) - { - if (state.Emitted) - { - return BlockMappingResult.Complete(); - } - - foreach (var content in context.UnhandledContents) - { - if (content is not ToolApprovalRequestContent approvalRequest) - { - continue; - } - - context.MarkHandled(approvalRequest); - - var innerBlock = context.CreateInnerBlock(approvalRequest.ToolCall) - ?? CreateFallbackInnerBlock(approvalRequest.ToolCall); - - state.Emitted = true; - return BlockMappingResult.Emit( - new FunctionApprovalBlock(innerBlock, approvalRequest) - { - Id = approvalRequest.ToolCall is FunctionCallContent functionCall - ? functionCall.CallId ?? approvalRequest.RequestId - : approvalRequest.RequestId - }, - state); - } - - return BlockMappingResult.Pass(); - } - - private static FunctionInvocationContentBlock CreateFallbackInnerBlock( - ToolCallContent toolCall) - { - var block = new FunctionInvocationContentBlock(); - if (toolCall is FunctionCallContent functionCall) - { - block.Call = functionCall; - } - - return block; - } - - internal sealed class State - { - internal bool Emitted { get; set; } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs deleted file mode 100644 index 367fd0063a1b..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -internal sealed class FunctionInvocationHandler : ContentBlockHandler -{ - public override BlockMappingResult Handle( - BlockMappingContext context, - FunctionInvocationContentBlock state) - { - if (state.Result is not null) - { - return BlockMappingResult.Complete(); - } - - var shouldEmit = false; - if (state.Call is null) - { - foreach (var content in context.UnhandledContents) - { - if (content is FunctionCallContent call) - { - context.MarkHandled(call); - state.Call = call; - shouldEmit = true; - break; - } - } - } - - if (state.Call is not null) - { - foreach (var content in context.UnhandledContents) - { - if (content is FunctionResultContent result && - result.CallId == state.Call.CallId) - { - context.MarkHandled(result); - state.Result = result; - return shouldEmit - ? BlockMappingResult.Emit(state, state) - : BlockMappingResult.Complete(); - } - } - } - - return shouldEmit - ? BlockMappingResult.Emit(state, state) - : BlockMappingResult.Pass(); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandleResult.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandleResult.cs deleted file mode 100644 index c48b3795f68b..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandleResult.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -internal readonly struct HandleResult -{ - internal enum ResultKind { Pass, Update, Complete } - - internal ResultKind Kind { get; } - - private HandleResult(ResultKind kind) - { - Kind = kind; - } - - internal static HandleResult Pass() => new(ResultKind.Pass); - - internal static HandleResult Update() => new(ResultKind.Update); - - internal static HandleResult Complete() => new(ResultKind.Complete); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandlerEntry.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandlerEntry.cs deleted file mode 100644 index 9b2fd5764871..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/HandlerEntry.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -internal sealed class HandlerEntry : IHandlerEntry where TState : new() -{ - private readonly ContentBlockHandler _handler; - - internal HandlerEntry(ContentBlockHandler handler) - { - _handler = handler; - } - - public IActiveEntry? TryHandle(BlockMappingContext context) - { - var state = new TState(); - var result = _handler.Handle(context, state); - if (result.Kind == BlockMappingResult.ResultKind.Emit) - { - return new ActiveEntry(_handler, result.State!, result.Block!); - } - - return null; - } - - private sealed class ActiveEntry : IActiveEntry - { - private readonly ContentBlockHandler _handler; - private TState _state; - - internal ActiveEntry( - ContentBlockHandler handler, - TState state, - ContentBlock block) - { - _handler = handler; - _state = state; - Block = block; - } - - public ContentBlock Block { get; } - - public HandleResult Invoke(BlockMappingContext context) - { - var result = _handler.Handle(context, _state); - switch (result.Kind) - { - case BlockMappingResult.ResultKind.Update: - _state = result.State!; - return HandleResult.Update(); - - case BlockMappingResult.ResultKind.Complete: - return HandleResult.Complete(); - - default: - return HandleResult.Pass(); - } - } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IActiveEntry.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IActiveEntry.cs deleted file mode 100644 index 555f43c83993..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IActiveEntry.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -internal interface IActiveEntry -{ - ContentBlock Block { get; } - - HandleResult Invoke(BlockMappingContext context); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IHandlerEntry.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IHandlerEntry.cs deleted file mode 100644 index 89d58b292ee8..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/IHandlerEntry.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -internal interface IHandlerEntry -{ - IActiveEntry? TryHandle(BlockMappingContext context); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/RichTextContentHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/RichTextContentHandler.cs deleted file mode 100644 index acad1a443a7e..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/RichTextContentHandler.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -internal sealed class RichTextContentHandler : ContentBlockHandler -{ - public override BlockMappingResult Handle( - BlockMappingContext context, RichContentBlock state) - { - RichTextContent? snapshot = null; - foreach (var content in context.UnhandledContents) - { - if (content is RichTextContent richText) - { - snapshot = richText; - } - } - - if (snapshot is null) - { - return state.Id.Length > 0 - ? BlockMappingResult.Complete() - : BlockMappingResult.Pass(); - } - - if (state.Id.Length > 0 && - context.Update.MessageId is { Length: > 0 } messageId && - !string.Equals(state.Id, messageId, StringComparison.Ordinal)) - { - return BlockMappingResult.Complete(); - } - - foreach (var content in context.UnhandledContents) - { - if (content is RichTextContent or TextContent) - { - context.MarkHandled(content); - } - } - - state.ReplaceContent(snapshot.Text, snapshot.Nodes); - - if (state.Id.Length == 0) - { - state.Id = context.Update.MessageId ?? Guid.NewGuid().ToString("N"); - return BlockMappingResult.Emit(state, state); - } - - return BlockMappingResult.Update(state); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/StateMapperContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/StateMapperContext.cs deleted file mode 100644 index fb1cce621d74..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/StateMapperContext.cs +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Carries a model update through typed state mapping and tracks content consumed as state. -/// -public class StateMapperContext -{ - private readonly bool[] _handled; - private int _handledCount; - - internal StateMapperContext(ChatResponseUpdate update) - { - Update = update; - _handled = new bool[update.Contents.Count]; - } - - /// - /// Gets the update being mapped. - /// - public ChatResponseUpdate Update { get; } - - /// - /// Gets content items that have not been consumed by the state mapper. - /// - public IEnumerable UnhandledContents - { - get - { - var contents = Update.Contents; - for (var i = 0; i < contents.Count; i++) - { - if (!_handled[i]) - { - yield return contents[i]; - } - } - } - } - - /// - /// Marks a content item as consumed by the state mapper. - /// - /// The content item that was handled. - public void MarkHandled(AIContent content) - { - ArgumentNullException.ThrowIfNull(content); - - var contents = Update.Contents; - for (var i = 0; i < contents.Count; i++) - { - if (ReferenceEquals(contents[i], content)) - { - if (!_handled[i]) - { - _handled[i] = true; - _handledCount++; - } - - return; - } - } - } - - internal object? StateValue { get; private set; } - - internal bool IsPredictiveState { get; private set; } - - /// - /// Sets the next typed state value. - /// - /// The next state value. - public void SetState(object value) - { - ArgumentNullException.ThrowIfNull(value); - StateValue = value; - IsPredictiveState = false; - } - - /// - /// Sets a provisional typed state value that must be accepted or rejected before the turn - /// completes. - /// - /// The next provisional state value. - public void SetPredictiveState(object value) - { - ArgumentNullException.ThrowIfNull(value); - StateValue = value; - IsPredictiveState = true; - } - - internal bool HasHandledContent => _handledCount > 0; - - internal ChatResponseUpdate GetFilteredUpdate() - { - if (_handledCount == 0) - { - return Update; - } - - var filtered = new List(); - var contents = Update.Contents; - for (var i = 0; i < contents.Count; i++) - { - if (!_handled[i]) - { - filtered.Add(contents[i]); - } - } - - return new ChatResponseUpdate - { - Role = Update.Role, - AuthorName = Update.AuthorName, - MessageId = Update.MessageId, - ResponseId = Update.ResponseId, - ConversationId = Update.ConversationId, - CreatedAt = Update.CreatedAt, - FinishReason = Update.FinishReason, - ModelId = Update.ModelId, - ContinuationToken = Update.ContinuationToken, - RawRepresentation = Update.RawRepresentation, - AdditionalProperties = Update.AdditionalProperties, - Contents = filtered, - }; - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/TextBlockHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/TextBlockHandler.cs deleted file mode 100644 index b8b5c04113f8..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/TextBlockHandler.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -// Fallback handler: claims TextContent and accumulates it into a single block for the -// duration of a model message. It runs last so more specific handlers get first refusal. -internal sealed class TextBlockHandler : ContentBlockHandler -{ - public override BlockMappingResult Handle( - BlockMappingContext context, RichContentBlock state) - { - TextContent? textContent = null; - foreach (var content in context.UnhandledContents) - { - if (content is TextContent tc) - { - textContent = tc; - break; - } - } - - if (textContent is null) - { - if (state.Id != string.Empty) - { - return BlockMappingResult.Complete(); - } - - return BlockMappingResult.Pass(); - } - - context.MarkHandled(textContent); - state.AppendText(textContent.Text ?? string.Empty); - RebuildParagraphs(state); - - if (state.Id == string.Empty) - { - state.Id = context.Update.MessageId ?? Guid.NewGuid().ToString("N"); - return BlockMappingResult.Emit(state, state); - } - - return BlockMappingResult.Update(state); - } - - internal static void RebuildParagraphs(RichContentBlock state) - { - var rawText = state.RawText; - if (rawText.Length == 0) - { - state.Content = Array.Empty(); - return; - } - - var paragraphs = new List(); - var start = 0; - while (start < rawText.Length) - { - var breakIndex = rawText.IndexOf("\n\n", start, StringComparison.Ordinal); - if (breakIndex < 0) - { - AddParagraph(paragraphs, rawText.AsSpan(start)); - break; - } - - if (breakIndex > start) - { - AddParagraph(paragraphs, rawText.AsSpan(start, breakIndex - start)); - } - - start = breakIndex + 2; - } - - state.Content = paragraphs; - } - - private static void AddParagraph(List paragraphs, ReadOnlySpan text) - { - var trimmed = text.TrimEnd("\r\n".AsSpan()); - if (trimmed.Length == 0) - { - return; - } - - var paragraph = new ParagraphNode(); - paragraph.AddChild(new TextNode(trimmed.ToString())); - paragraphs.Add(paragraph); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIActionHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIActionHandler.cs deleted file mode 100644 index f1c2ee27c9fe..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIActionHandler.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -internal sealed class UIActionHandler : ContentBlockHandler -{ - private readonly IReadOnlyDictionary _actions; - - internal UIActionHandler(IReadOnlyDictionary actions) - { - _actions = actions; - } - - public override BlockMappingResult Handle(BlockMappingContext context, State state) - { - if (state.HasEmitted) - { - return BlockMappingResult.Pass(); - } - - foreach (var content in context.UnhandledContents) - { - if (content is FunctionCallContent call && - !call.InformationalOnly && - _actions.TryGetValue(call.Name, out var function)) - { - context.MarkHandled(call); - state.HasEmitted = true; - return BlockMappingResult.Emit( - new UIActionBlock(function, call) - { - Id = call.CallId ?? Guid.NewGuid().ToString("N") - }, - state); - } - } - - return BlockMappingResult.Pass(); - } - - internal sealed class State - { - public bool HasEmitted { get; set; } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIAgentOptions.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIAgentOptions.cs deleted file mode 100644 index 546e27e5e4ed..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/UIAgentOptions.cs +++ /dev/null @@ -1,104 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Configures a . -/// -/// -/// -/// var agent = new UIAgent(chatClient, options => -/// { -/// options.ChatOptions = new ChatOptions { Instructions = "You are a helpful assistant." }; -/// }); -/// -/// -public class UIAgentOptions -{ - /// - /// Gets or sets the options passed to the underlying . - /// - public ChatOptions? ChatOptions { get; set; } - - /// - /// Gets or sets a callback that maps model updates into typed agent state. - /// - public Action? StateMapper { get; set; } - - /// - /// Gets or sets the persistent conversation thread that receives completed turns. - /// - public IConversationThread? Thread { get; set; } - - internal List HandlerRegistrations { get; } = new(); - - internal Dictionary UIActions { get; } = - new(StringComparer.Ordinal); - - /// - /// Registers a handler that maps model updates into content blocks. Registered handlers - /// run before the built-in ones, so they can claim content the built-in handlers would - /// otherwise map. - /// - /// The state the handler keeps across updates. - /// The handler to register. - public void AddBlockHandler(ContentBlockHandler handler) - where TState : new() - { - ArgumentNullException.ThrowIfNull(handler); - HandlerRegistrations.Add(new HandlerRegistration(handler)); - } - - /// - /// Registers a function that a matching model tool call executes in the UI. - /// The function is sent to the chat client as a declaration, not as an executable server tool. - /// - /// - /// The function to execute in the UI. Its name must be unique among the registered UI actions. - /// - /// - /// An action with the same name is already registered. - /// - public void RegisterUIAction(AIFunction function) - { - ArgumentNullException.ThrowIfNull(function); - UIActions.Add(function.Name, function); - } - - internal interface IHandlerRegistration - { - IHandlerEntry CreateEntry(); - } - - private sealed class HandlerRegistration : IHandlerRegistration where TState : new() - { - private readonly ContentBlockHandler _handler; - - internal HandlerRegistration(ContentBlockHandler handler) - { - _handler = handler; - } - - public IHandlerEntry CreateEntry() => new HandlerEntry(_handler); - } -} - -/// -/// Configures a . -/// -/// The type of state associated with the agent. -public sealed class UIAgentOptions : UIAgentOptions where TState : class, new() -{ - internal UIAgentOptions(TState? initialState) - { - State = new AgentState(initialState); - } - - /// - /// Gets the observable state associated with the agent. - /// - public AgentState State { get; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Shipped.txt b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Shipped.txt deleted file mode 100644 index 7dc5c58110bf..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Shipped.txt +++ /dev/null @@ -1 +0,0 @@ -#nullable enable diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Unshipped.txt b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Unshipped.txt deleted file mode 100644 index 2241a1e6ba68..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/PublicAPI.Unshipped.txt +++ /dev/null @@ -1,360 +0,0 @@ -#nullable enable -Microsoft.AspNetCore.Components.AI.AgentBoundary -Microsoft.AspNetCore.Components.AI.AgentBoundary.Agent.get -> Microsoft.AspNetCore.Components.AI.UIAgent! -Microsoft.AspNetCore.Components.AI.AgentBoundary.Agent.set -> void -Microsoft.AspNetCore.Components.AI.AgentBoundary.AgentBoundary() -> void -Microsoft.AspNetCore.Components.AI.AgentBoundary.ChildContent.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.AgentBoundary.ChildContent.set -> void -Microsoft.AspNetCore.Components.AI.AgentBoundary.Dispose() -> void -Microsoft.AspNetCore.Components.AI.AgentState -Microsoft.AspNetCore.Components.AI.AgentState.AcceptPredictiveState() -> void -Microsoft.AspNetCore.Components.AI.AgentState.HasPendingPredictiveState.get -> bool -Microsoft.AspNetCore.Components.AI.AgentState.OnChanged(System.Action! callback) -> System.IDisposable! -Microsoft.AspNetCore.Components.AI.AgentState.RejectPredictiveState() -> void -Microsoft.AspNetCore.Components.AI.AgentState.Value.get -> T! -Microsoft.AspNetCore.Components.AI.AgentState.Value.set -> void -Microsoft.AspNetCore.Components.AI.AgentContext -Microsoft.AspNetCore.Components.AI.AgentContext.AgentContext(Microsoft.AspNetCore.Components.AI.UIAgent! agent) -> void -Microsoft.AspNetCore.Components.AI.AgentContext.CancelAsync() -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.AgentContext.Dispose() -> void -Microsoft.AspNetCore.Components.AI.AgentContext.Error.get -> System.Exception? -Microsoft.AspNetCore.Components.AI.AgentContext.RegisterOnBlockAdded(System.Action! callback) -> System.IDisposable! -Microsoft.AspNetCore.Components.AI.AgentContext.RegisterOnStatusChanged(System.Action! callback) -> System.IDisposable! -Microsoft.AspNetCore.Components.AI.AgentContext.RegisterOnTurnAdded(System.Action! callback) -> System.IDisposable! -Microsoft.AspNetCore.Components.AI.AgentContext.RetryAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.AgentContext.RestoreAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.AgentContext.SendMessageAsync(Microsoft.Extensions.AI.ChatMessage! message, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.AgentContext.SendMessageAsync(string! text, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.AgentContext.Status.get -> Microsoft.AspNetCore.Components.AI.ConversationStatus -Microsoft.AspNetCore.Components.AI.AgentContext.Turns.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.ApprovalStatus -Microsoft.AspNetCore.Components.AI.ApprovalStatus.Approved = 1 -> Microsoft.AspNetCore.Components.AI.ApprovalStatus -Microsoft.AspNetCore.Components.AI.ApprovalStatus.Pending = 0 -> Microsoft.AspNetCore.Components.AI.ApprovalStatus -Microsoft.AspNetCore.Components.AI.ApprovalStatus.Rejected = 2 -> Microsoft.AspNetCore.Components.AI.ApprovalStatus -Microsoft.AspNetCore.Components.AI.ActivityContentBlock -Microsoft.AspNetCore.Components.AI.ActivityContentBlock.ActivityContentBlock() -> void -Microsoft.AspNetCore.Components.AI.ActivityContentBlock.ActivityType.get -> string! -Microsoft.AspNetCore.Components.AI.ActivityContentBlock.ActivityType.set -> void -Microsoft.AspNetCore.Components.AI.ActivityContentBlock.Content.get -> System.Text.Json.JsonElement -Microsoft.AspNetCore.Components.AI.ActivityContentBlock.Content.set -> void -Microsoft.AspNetCore.Components.AI.ActivityHandler -Microsoft.AspNetCore.Components.AI.ActivityHandler.ActivityHandler() -> void -Microsoft.AspNetCore.Components.AI.BlockLifecycleState -Microsoft.AspNetCore.Components.AI.BlockLifecycleState.Active = 1 -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState -Microsoft.AspNetCore.Components.AI.BlockLifecycleState.Inactive = 2 -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState -Microsoft.AspNetCore.Components.AI.BlockLifecycleState.Pending = 0 -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState -Microsoft.AspNetCore.Components.AI.BlockMappingContext -Microsoft.AspNetCore.Components.AI.BlockMappingContext.AllHandled.get -> bool -Microsoft.AspNetCore.Components.AI.BlockMappingContext.CreateInnerBlock(Microsoft.Extensions.AI.AIContent! content) -> Microsoft.AspNetCore.Components.AI.ContentBlock? -Microsoft.AspNetCore.Components.AI.BlockMappingContext.MarkHandled(Microsoft.Extensions.AI.AIContent! content) -> void -Microsoft.AspNetCore.Components.AI.BlockMappingContext.MarkUpdateHandled() -> void -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContents.get -> Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable.GetEnumerator() -> Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable.UnhandledContentsEnumerable() -> void -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator.Current.get -> Microsoft.Extensions.AI.AIContent! -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator.MoveNext() -> bool -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator.UnhandledContentsEnumerator() -> void -Microsoft.AspNetCore.Components.AI.BlockMappingContext.Update.get -> Microsoft.Extensions.AI.ChatResponseUpdate! -Microsoft.AspNetCore.Components.AI.BlockMappingResult -Microsoft.AspNetCore.Components.AI.BlockMappingResult.BlockMappingResult() -> void -Microsoft.AspNetCore.Components.AI.BlockQuoteNode -Microsoft.AspNetCore.Components.AI.BlockQuoteNode.BlockQuoteNode() -> void -Microsoft.AspNetCore.Components.AI.BlockRenderer -Microsoft.AspNetCore.Components.AI.BlockRenderer.BlockRenderer() -> void -Microsoft.AspNetCore.Components.AI.BlockRenderer.ChildContent.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.BlockRenderer.ChildContent.set -> void -Microsoft.AspNetCore.Components.AI.BlockRenderer.Dispose() -> void -Microsoft.AspNetCore.Components.AI.BlockRenderer.ListContext.get -> Microsoft.AspNetCore.Components.AI.MessageListContext! -Microsoft.AspNetCore.Components.AI.BlockRenderer.ListContext.set -> void -Microsoft.AspNetCore.Components.AI.BlockRenderer.When.get -> System.Func? -Microsoft.AspNetCore.Components.AI.BlockRenderer.When.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage -Microsoft.AspNetCore.Components.AI.ChatPage.AdditionalAttributes.get -> System.Collections.Generic.Dictionary? -Microsoft.AspNetCore.Components.AI.ChatPage.AdditionalAttributes.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.Agent.get -> Microsoft.AspNetCore.Components.AI.UIAgent! -Microsoft.AspNetCore.Components.AI.ChatPage.Agent.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.ChatPage() -> void -Microsoft.AspNetCore.Components.AI.ChatPage.Header.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.ChatPage.Header.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.InputLeadingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.ChatPage.InputLeadingActions.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.InputTrailingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.ChatPage.InputTrailingActions.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.MessageListContent.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.ChatPage.MessageListContent.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.Placeholder.get -> string? -Microsoft.AspNetCore.Components.AI.ChatPage.Placeholder.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.WelcomeContent.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.ChatPage.WelcomeContent.set -> void -Microsoft.AspNetCore.Components.AI.CodeBlockNode -Microsoft.AspNetCore.Components.AI.CodeBlockNode.Code.get -> string! -Microsoft.AspNetCore.Components.AI.CodeBlockNode.Code.set -> void -Microsoft.AspNetCore.Components.AI.CodeBlockNode.CodeBlockNode() -> void -Microsoft.AspNetCore.Components.AI.CodeBlockNode.CodeBlockNode(string! code, string? language = null) -> void -Microsoft.AspNetCore.Components.AI.CodeBlockNode.Language.get -> string? -Microsoft.AspNetCore.Components.AI.CodeBlockNode.Language.set -> void -Microsoft.AspNetCore.Components.AI.ContentBlock -Microsoft.AspNetCore.Components.AI.ContentBlock.AuthorName.get -> string? -Microsoft.AspNetCore.Components.AI.ContentBlock.ContentBlock() -> void -Microsoft.AspNetCore.Components.AI.ContentBlock.Id.get -> string! -Microsoft.AspNetCore.Components.AI.ContentBlock.LifecycleState.get -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState -Microsoft.AspNetCore.Components.AI.ContentBlock.NotifyChanged() -> void -Microsoft.AspNetCore.Components.AI.ContentBlock.OnChanged(System.Action! callback) -> Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription -Microsoft.AspNetCore.Components.AI.ContentBlock.Role.get -> Microsoft.Extensions.AI.ChatRole? -Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription -Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription.ContentBlockChangedSubscription() -> void -Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription.Dispose() -> void -Microsoft.AspNetCore.Components.AI.ContentBlockHandler -Microsoft.AspNetCore.Components.AI.ContentBlockHandler.ContentBlockHandler() -> void -Microsoft.AspNetCore.Components.AI.ConversationStatus -Microsoft.AspNetCore.Components.AI.ConversationStatus.AwaitingInput = 2 -> Microsoft.AspNetCore.Components.AI.ConversationStatus -Microsoft.AspNetCore.Components.AI.ConversationStatus.Error = 3 -> Microsoft.AspNetCore.Components.AI.ConversationStatus -Microsoft.AspNetCore.Components.AI.ConversationStatus.Idle = 0 -> Microsoft.AspNetCore.Components.AI.ConversationStatus -Microsoft.AspNetCore.Components.AI.ConversationStatus.Streaming = 1 -> Microsoft.AspNetCore.Components.AI.ConversationStatus -Microsoft.AspNetCore.Components.AI.ConversationTurn -Microsoft.AspNetCore.Components.AI.ConversationTurn.ConversationTurn() -> void -Microsoft.AspNetCore.Components.AI.ConversationTurn.Id.get -> string! -Microsoft.AspNetCore.Components.AI.ConversationTurn.RequestBlocks.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.ConversationTurn.ResponseBlocks.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.DefinitionNode -Microsoft.AspNetCore.Components.AI.DefinitionNode.DefinitionNode() -> void -Microsoft.AspNetCore.Components.AI.DefinitionNode.Label.get -> string! -Microsoft.AspNetCore.Components.AI.DefinitionNode.Label.set -> void -Microsoft.AspNetCore.Components.AI.DefinitionNode.Title.get -> string? -Microsoft.AspNetCore.Components.AI.DefinitionNode.Title.set -> void -Microsoft.AspNetCore.Components.AI.DefinitionNode.Url.get -> string! -Microsoft.AspNetCore.Components.AI.DefinitionNode.Url.set -> void -Microsoft.AspNetCore.Components.AI.EmphasisNode -Microsoft.AspNetCore.Components.AI.EmphasisNode.EmphasisNode() -> void -Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode -Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode.FootnoteDefinitionNode() -> void -Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode.Label.get -> string! -Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode.Label.set -> void -Microsoft.AspNetCore.Components.AI.FootnoteNode -Microsoft.AspNetCore.Components.AI.FootnoteNode.FootnoteNode() -> void -Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode -Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode.FootnoteReferenceNode() -> void -Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode.Label.get -> string! -Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode.Label.set -> void -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Arguments.get -> System.Collections.Generic.IDictionary? -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.ApprovalRequest.get -> Microsoft.Extensions.AI.ToolApprovalRequestContent! -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Approve() -> void -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Call.get -> Microsoft.Extensions.AI.FunctionCallContent? -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.GetResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.HasResult.get -> bool -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.InnerBlock.get -> Microsoft.AspNetCore.Components.AI.ContentBlock! -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Reject(string? reason = null) -> void -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Result.get -> Microsoft.Extensions.AI.FunctionResultContent? -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Status.get -> Microsoft.AspNetCore.Components.AI.ApprovalStatus -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.ToolName.get -> string? -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Arguments.get -> System.Collections.Generic.IDictionary? -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Call.get -> Microsoft.Extensions.AI.FunctionCallContent? -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Call.set -> void -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.FunctionInvocationContentBlock() -> void -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.HasResult.get -> bool -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Result.get -> Microsoft.Extensions.AI.FunctionResultContent? -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Result.set -> void -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.ToolName.get -> string? -Microsoft.AspNetCore.Components.AI.HeadingNode -Microsoft.AspNetCore.Components.AI.HeadingNode.HeadingNode() -> void -Microsoft.AspNetCore.Components.AI.HeadingNode.HeadingNode(int level) -> void -Microsoft.AspNetCore.Components.AI.HeadingNode.Level.get -> int -Microsoft.AspNetCore.Components.AI.HeadingNode.Level.set -> void -Microsoft.AspNetCore.Components.AI.HtmlNode -Microsoft.AspNetCore.Components.AI.HtmlNode.HtmlNode() -> void -Microsoft.AspNetCore.Components.AI.HtmlNode.HtmlNode(string! value) -> void -Microsoft.AspNetCore.Components.AI.HtmlNode.Value.get -> string! -Microsoft.AspNetCore.Components.AI.HtmlNode.Value.set -> void -Microsoft.AspNetCore.Components.AI.IInteractiveBlock -Microsoft.AspNetCore.Components.AI.IInteractiveBlock.GetResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.IConversationThread -Microsoft.AspNetCore.Components.AI.IConversationThread.AppendUpdate(Microsoft.Extensions.AI.ChatResponseUpdate! update) -> void -Microsoft.AspNetCore.Components.AI.IConversationThread.AppendUserMessage(Microsoft.Extensions.AI.ChatMessage! message) -> void -Microsoft.AspNetCore.Components.AI.IConversationThread.CompleteTurn() -> void -Microsoft.AspNetCore.Components.AI.IConversationThread.ConversationId.get -> string? -Microsoft.AspNetCore.Components.AI.IConversationThread.GetUpdates() -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.IConversationThread.IsStateful.get -> bool -Microsoft.AspNetCore.Components.AI.IConversationThread.ThreadId.get -> string! -Microsoft.AspNetCore.Components.AI.ImageNode -Microsoft.AspNetCore.Components.AI.ImageNode.Alt.get -> string? -Microsoft.AspNetCore.Components.AI.ImageNode.Alt.set -> void -Microsoft.AspNetCore.Components.AI.ImageNode.ImageNode() -> void -Microsoft.AspNetCore.Components.AI.ImageNode.ImageNode(string! url, string? alt = null, string? title = null) -> void -Microsoft.AspNetCore.Components.AI.ImageNode.Title.get -> string? -Microsoft.AspNetCore.Components.AI.ImageNode.Title.set -> void -Microsoft.AspNetCore.Components.AI.ImageNode.Url.get -> string! -Microsoft.AspNetCore.Components.AI.ImageNode.Url.set -> void -Microsoft.AspNetCore.Components.AI.ImageReferenceNode -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Alt.get -> string? -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Alt.set -> void -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.ImageReferenceNode() -> void -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Label.get -> string! -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Label.set -> void -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.ReferenceKind.get -> Microsoft.AspNetCore.Components.AI.ReferenceKind -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.ReferenceKind.set -> void -Microsoft.AspNetCore.Components.AI.InlineCodeNode -Microsoft.AspNetCore.Components.AI.InlineCodeNode.Code.get -> string! -Microsoft.AspNetCore.Components.AI.InlineCodeNode.Code.set -> void -Microsoft.AspNetCore.Components.AI.InlineCodeNode.InlineCodeNode() -> void -Microsoft.AspNetCore.Components.AI.InlineCodeNode.InlineCodeNode(string! code) -> void -Microsoft.AspNetCore.Components.AI.LineBreakNode -Microsoft.AspNetCore.Components.AI.LineBreakNode.LineBreakNode() -> void -Microsoft.AspNetCore.Components.AI.LinkNode -Microsoft.AspNetCore.Components.AI.LinkNode.LinkNode() -> void -Microsoft.AspNetCore.Components.AI.LinkNode.LinkNode(string! url, string? title = null) -> void -Microsoft.AspNetCore.Components.AI.LinkNode.Title.get -> string? -Microsoft.AspNetCore.Components.AI.LinkNode.Title.set -> void -Microsoft.AspNetCore.Components.AI.LinkNode.Url.get -> string! -Microsoft.AspNetCore.Components.AI.LinkNode.Url.set -> void -Microsoft.AspNetCore.Components.AI.LinkReferenceNode -Microsoft.AspNetCore.Components.AI.LinkReferenceNode.Label.get -> string! -Microsoft.AspNetCore.Components.AI.LinkReferenceNode.Label.set -> void -Microsoft.AspNetCore.Components.AI.LinkReferenceNode.LinkReferenceNode() -> void -Microsoft.AspNetCore.Components.AI.LinkReferenceNode.ReferenceKind.get -> Microsoft.AspNetCore.Components.AI.ReferenceKind -Microsoft.AspNetCore.Components.AI.LinkReferenceNode.ReferenceKind.set -> void -Microsoft.AspNetCore.Components.AI.ListItemNode -Microsoft.AspNetCore.Components.AI.ListItemNode.Checked.get -> bool? -Microsoft.AspNetCore.Components.AI.ListItemNode.Checked.set -> void -Microsoft.AspNetCore.Components.AI.ListItemNode.ListItemNode() -> void -Microsoft.AspNetCore.Components.AI.ListNode -Microsoft.AspNetCore.Components.AI.ListNode.ListNode() -> void -Microsoft.AspNetCore.Components.AI.ListNode.ListNode(bool ordered, int? start = null) -> void -Microsoft.AspNetCore.Components.AI.ListNode.Ordered.get -> bool -Microsoft.AspNetCore.Components.AI.ListNode.Ordered.set -> void -Microsoft.AspNetCore.Components.AI.ListNode.Start.get -> int? -Microsoft.AspNetCore.Components.AI.ListNode.Start.set -> void -Microsoft.AspNetCore.Components.AI.MessageInput -Microsoft.AspNetCore.Components.AI.MessageInput.AgentContext.get -> Microsoft.AspNetCore.Components.AI.AgentContext! -Microsoft.AspNetCore.Components.AI.MessageInput.AgentContext.set -> void -Microsoft.AspNetCore.Components.AI.MessageInput.Dispose() -> void -Microsoft.AspNetCore.Components.AI.MessageInput.LeadingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.MessageInput.LeadingActions.set -> void -Microsoft.AspNetCore.Components.AI.MessageInput.MessageInput() -> void -Microsoft.AspNetCore.Components.AI.MessageInput.Placeholder.get -> string? -Microsoft.AspNetCore.Components.AI.MessageInput.Placeholder.set -> void -Microsoft.AspNetCore.Components.AI.MessageInput.TrailingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.MessageInput.TrailingActions.set -> void -Microsoft.AspNetCore.Components.AI.MessageList -Microsoft.AspNetCore.Components.AI.MessageList.AgentContext.get -> Microsoft.AspNetCore.Components.AI.AgentContext! -Microsoft.AspNetCore.Components.AI.MessageList.AgentContext.set -> void -Microsoft.AspNetCore.Components.AI.MessageList.ChildContent.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.MessageList.ChildContent.set -> void -Microsoft.AspNetCore.Components.AI.MessageList.Dispose() -> void -Microsoft.AspNetCore.Components.AI.MessageList.EmptyContent.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.MessageList.EmptyContent.set -> void -Microsoft.AspNetCore.Components.AI.MessageList.Footer.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.MessageList.Footer.set -> void -Microsoft.AspNetCore.Components.AI.MessageList.MessageList() -> void -Microsoft.AspNetCore.Components.AI.MessageListContext -Microsoft.AspNetCore.Components.AI.MessageListContext.MessageListContext() -> void -Microsoft.AspNetCore.Components.AI.MessageListContext.RenderBlock(Microsoft.AspNetCore.Components.AI.ContentBlock! block) -> Microsoft.AspNetCore.Components.RenderFragment! -Microsoft.AspNetCore.Components.AI.ParagraphNode -Microsoft.AspNetCore.Components.AI.ParagraphNode.ParagraphNode() -> void -Microsoft.AspNetCore.Components.AI.ReferenceKind -Microsoft.AspNetCore.Components.AI.ReferenceKind.Collapsed = 1 -> Microsoft.AspNetCore.Components.AI.ReferenceKind -Microsoft.AspNetCore.Components.AI.ReferenceKind.Full = 2 -> Microsoft.AspNetCore.Components.AI.ReferenceKind -Microsoft.AspNetCore.Components.AI.ReferenceKind.Shortcut = 0 -> Microsoft.AspNetCore.Components.AI.ReferenceKind -Microsoft.AspNetCore.Components.AI.RichContentBlock -Microsoft.AspNetCore.Components.AI.RichContentBlock.AppendText(string! text) -> void -Microsoft.AspNetCore.Components.AI.RichContentBlock.Content.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.RichContentBlock.RawText.get -> string! -Microsoft.AspNetCore.Components.AI.RichContentBlock.RichContentBlock() -> void -Microsoft.AspNetCore.Components.AI.RichTextContent -Microsoft.AspNetCore.Components.AI.RichTextContent.Nodes.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.RichTextContent.RichTextContent(string! text, System.Collections.Generic.IReadOnlyList! nodes) -> void -Microsoft.AspNetCore.Components.AI.RichTextContent.Text.get -> string! -Microsoft.AspNetCore.Components.AI.RichTextNode -Microsoft.AspNetCore.Components.AI.RichTextNode.AddChild(Microsoft.AspNetCore.Components.AI.RichTextNode! child) -> void -Microsoft.AspNetCore.Components.AI.RichTextNode.Children.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.RichTextNode.RichTextNode() -> void -Microsoft.AspNetCore.Components.AI.StrikethroughNode -Microsoft.AspNetCore.Components.AI.StrikethroughNode.StrikethroughNode() -> void -Microsoft.AspNetCore.Components.AI.StrongNode -Microsoft.AspNetCore.Components.AI.StrongNode.StrongNode() -> void -Microsoft.AspNetCore.Components.AI.StateMapperContext -Microsoft.AspNetCore.Components.AI.StateMapperContext.MarkHandled(Microsoft.Extensions.AI.AIContent! content) -> void -Microsoft.AspNetCore.Components.AI.StateMapperContext.SetPredictiveState(object! value) -> void -Microsoft.AspNetCore.Components.AI.StateMapperContext.SetState(object! value) -> void -Microsoft.AspNetCore.Components.AI.StateMapperContext.UnhandledContents.get -> System.Collections.Generic.IEnumerable! -Microsoft.AspNetCore.Components.AI.StateMapperContext.Update.get -> Microsoft.Extensions.AI.ChatResponseUpdate! -Microsoft.AspNetCore.Components.AI.TableCellNode -Microsoft.AspNetCore.Components.AI.TableCellNode.TableCellNode() -> void -Microsoft.AspNetCore.Components.AI.TableColumnAlignment -Microsoft.AspNetCore.Components.AI.TableColumnAlignment.Center = 2 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment -Microsoft.AspNetCore.Components.AI.TableColumnAlignment.Left = 1 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment -Microsoft.AspNetCore.Components.AI.TableColumnAlignment.None = 0 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment -Microsoft.AspNetCore.Components.AI.TableColumnAlignment.Right = 3 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment -Microsoft.AspNetCore.Components.AI.TableNode -Microsoft.AspNetCore.Components.AI.TableNode.Alignment.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.TableNode.Alignment.set -> void -Microsoft.AspNetCore.Components.AI.TableNode.TableNode() -> void -Microsoft.AspNetCore.Components.AI.TableRowNode -Microsoft.AspNetCore.Components.AI.TableRowNode.TableRowNode() -> void -Microsoft.AspNetCore.Components.AI.TextNode -Microsoft.AspNetCore.Components.AI.TextNode.Text.get -> string! -Microsoft.AspNetCore.Components.AI.TextNode.Text.set -> void -Microsoft.AspNetCore.Components.AI.TextNode.TextNode() -> void -Microsoft.AspNetCore.Components.AI.TextNode.TextNode(string! text) -> void -Microsoft.AspNetCore.Components.AI.ThematicBreakNode -Microsoft.AspNetCore.Components.AI.ThematicBreakNode.ThematicBreakNode() -> void -Microsoft.AspNetCore.Components.AI.ToolBlockAttribute -Microsoft.AspNetCore.Components.AI.ToolBlockAttribute.ToolBlockAttribute(string! toolName) -> void -Microsoft.AspNetCore.Components.AI.ToolBlockAttribute.ToolName.get -> string! -Microsoft.AspNetCore.Components.AI.ToolParameterAttribute -Microsoft.AspNetCore.Components.AI.ToolParameterAttribute.Name.get -> string? -Microsoft.AspNetCore.Components.AI.ToolParameterAttribute.Name.set -> void -Microsoft.AspNetCore.Components.AI.ToolParameterAttribute.ToolParameterAttribute() -> void -Microsoft.AspNetCore.Components.AI.ToolResultAttribute -Microsoft.AspNetCore.Components.AI.ToolResultAttribute.Name.get -> string? -Microsoft.AspNetCore.Components.AI.ToolResultAttribute.Name.set -> void -Microsoft.AspNetCore.Components.AI.ToolResultAttribute.ToolResultAttribute() -> void -Microsoft.AspNetCore.Components.AI.UIAgent -Microsoft.AspNetCore.Components.AI.UIAgent.Dispose() -> void -Microsoft.AspNetCore.Components.AI.UIAgent.RestoreAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!>! -Microsoft.AspNetCore.Components.AI.UIAgent.SendMessageAsync(Microsoft.Extensions.AI.ChatMessage! message, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, Microsoft.Extensions.AI.ChatOptions! chatOptions) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, Microsoft.Extensions.AI.ChatOptions! chatOptions, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action? configure) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action? configure, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) -> void -Microsoft.AspNetCore.Components.AI.UIAgent -Microsoft.AspNetCore.Components.AI.UIAgent.State.get -> Microsoft.AspNetCore.Components.AI.AgentState! -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, Microsoft.Extensions.AI.ChatOptions! chatOptions, TState? initialState = null) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action!>! configure, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory, TState? initialState = null) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action!>! configure, TState? initialState = null) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, TState? initialState = null) -> void -Microsoft.AspNetCore.Components.AI.UIAgentOptions -Microsoft.AspNetCore.Components.AI.UIAgentOptions.AddBlockHandler(Microsoft.AspNetCore.Components.AI.ContentBlockHandler! handler) -> void -Microsoft.AspNetCore.Components.AI.UIAgentOptions.ChatOptions.get -> Microsoft.Extensions.AI.ChatOptions? -Microsoft.AspNetCore.Components.AI.UIAgentOptions.ChatOptions.set -> void -Microsoft.AspNetCore.Components.AI.UIAgentOptions.RegisterUIAction(Microsoft.Extensions.AI.AIFunction! function) -> void -Microsoft.AspNetCore.Components.AI.UIAgentOptions -Microsoft.AspNetCore.Components.AI.UIAgentOptions.State.get -> Microsoft.AspNetCore.Components.AI.AgentState! -Microsoft.AspNetCore.Components.AI.UIAgentOptions.StateMapper.get -> System.Action? -Microsoft.AspNetCore.Components.AI.UIAgentOptions.StateMapper.set -> void -Microsoft.AspNetCore.Components.AI.UIAgentOptions.Thread.get -> Microsoft.AspNetCore.Components.AI.IConversationThread? -Microsoft.AspNetCore.Components.AI.UIAgentOptions.Thread.set -> void -Microsoft.AspNetCore.Components.AI.UIAgentOptions.UIAgentOptions() -> void -Microsoft.AspNetCore.Components.AI.UIActionBlock -Microsoft.AspNetCore.Components.AI.UIActionBlock.Call.get -> Microsoft.Extensions.AI.FunctionCallContent! -Microsoft.AspNetCore.Components.AI.UIActionBlock.GetResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.UIActionBlock.InvokeAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.UIActionBlock.IsComplete.get -> bool -Microsoft.AspNetCore.Components.AI.UIActionBlock.Result.get -> Microsoft.Extensions.AI.FunctionResultContent? -Microsoft.AspNetCore.Components.AI.UIActionBlock.ToolName.get -> string! -abstract Microsoft.AspNetCore.Components.AI.ContentBlockHandler.Handle(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TState state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult -abstract Microsoft.AspNetCore.Components.AI.ActivityHandler.TryCreateBlock(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TBlock! state) -> bool -abstract Microsoft.AspNetCore.Components.AI.ActivityHandler.TryUpdateBlock(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TBlock! state, out bool isCompleted) -> bool -override sealed Microsoft.AspNetCore.Components.AI.ActivityHandler.Handle(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TBlock! state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult -override Microsoft.AspNetCore.Components.AI.AgentBoundary.BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder! builder) -> void -override Microsoft.AspNetCore.Components.AI.AgentBoundary.OnInitialized() -> void -override Microsoft.AspNetCore.Components.AI.AgentBoundary.OnParametersSet() -> void -virtual Microsoft.AspNetCore.Components.AI.ActivityHandler.OnContentUpdated(TBlock! state) -> void -static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Complete() -> Microsoft.AspNetCore.Components.AI.BlockMappingResult -static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Emit(Microsoft.AspNetCore.Components.AI.ContentBlock! block, TState state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult -static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Pass() -> Microsoft.AspNetCore.Components.AI.BlockMappingResult -static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Update(TState state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/wwwroot/ai-chat.css b/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/wwwroot/ai-chat.css deleted file mode 100644 index 83877fb4d07a..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/wwwroot/ai-chat.css +++ /dev/null @@ -1,457 +0,0 @@ -/* ========================================================================== - Microsoft.AspNetCore.Components.AI — Design Tokens & Default Styles - ========================================================================== */ - -/* ---------- Root scope ---------- */ -.sc-ai-root { - /* ---- Typography ---- */ - --sc-ai-font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; - --sc-ai-font-size: 0.9375rem; - --sc-ai-font-size-sm: 0.8125rem; - --sc-ai-font-size-lg: 1.125rem; - --sc-ai-line-height: 1.5; - --sc-ai-font-weight-normal: 400; - --sc-ai-font-weight-medium: 500; - --sc-ai-font-weight-bold: 600; - - /* ---- Colors — Surface & Background ---- */ - --sc-ai-color-bg: #ffffff; - --sc-ai-color-surface: #ffffff; - --sc-ai-color-surface-hover: #f8f9fa; - --sc-ai-color-text: #212529; - --sc-ai-color-text-secondary: #6c757d; - --sc-ai-color-text-on-accent: #ffffff; - --sc-ai-color-accent: #0d6efd; - --sc-ai-color-accent-hover: #0b5ed7; - --sc-ai-color-border: #dee2e6; - --sc-ai-color-success: #198754; - --sc-ai-color-error: #dc3545; - --sc-ai-color-error-bg: #f8d7da; - - /* ---- Colors — Message Bubbles ---- */ - --sc-ai-color-bubble-user: #e9ecef; - --sc-ai-color-bubble-user-text: #212529; - --sc-ai-color-bubble-assistant: transparent; - --sc-ai-color-bubble-assistant-text: #212529; - - /* ---- Layout & Spacing ---- */ - --sc-ai-spacing-xs: 0.25rem; - --sc-ai-spacing-sm: 0.5rem; - --sc-ai-spacing-md: 1rem; - --sc-ai-spacing-lg: 1.5rem; - --sc-ai-max-width: 48rem; - --sc-ai-border-radius-sm: 0.375rem; - --sc-ai-border-radius-lg: 1.5rem; - --sc-ai-input-height: 3rem; - - /* ---- Transitions ---- */ - --sc-ai-transition-fast: 120ms ease; - - /* ---- Focus & States ---- */ - --sc-ai-focus-ring: 0 0 0 2px var(--sc-ai-color-accent); - --sc-ai-disabled-opacity: 0.5; - - /* Apply base typography */ - font-family: var(--sc-ai-font-family); - font-size: var(--sc-ai-font-size); - line-height: var(--sc-ai-line-height); - color: var(--sc-ai-color-text); - box-sizing: border-box; -} - -.sc-ai-root *, -.sc-ai-root *::before, -.sc-ai-root *::after { - box-sizing: inherit; -} - -/* ---------- Buttons ---------- */ -.sc-ai-btn { - display: inline-flex; - align-items: center; - justify-content: center; - gap: var(--sc-ai-spacing-xs); - padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); - border: 1px solid transparent; - border-radius: var(--sc-ai-border-radius-sm); - font-family: inherit; - font-size: var(--sc-ai-font-size-sm); - font-weight: var(--sc-ai-font-weight-medium); - cursor: pointer; - transition: background var(--sc-ai-transition-fast), - color var(--sc-ai-transition-fast), - border-color var(--sc-ai-transition-fast), - opacity var(--sc-ai-transition-fast); - line-height: 1; -} - -.sc-ai-btn:focus-visible { - outline: none; - box-shadow: var(--sc-ai-focus-ring); -} - -.sc-ai-btn:disabled { - opacity: var(--sc-ai-disabled-opacity); - cursor: not-allowed; -} - -.sc-ai-btn--primary { - background: var(--sc-ai-color-accent); - color: var(--sc-ai-color-text-on-accent); -} - -.sc-ai-btn--primary:hover:not(:disabled) { - background: var(--sc-ai-color-accent-hover); -} - -.sc-ai-btn--secondary { - background: var(--sc-ai-color-surface); - color: var(--sc-ai-color-text); - border-color: var(--sc-ai-color-border); -} - -.sc-ai-btn--secondary:hover:not(:disabled) { - background: var(--sc-ai-color-surface-hover); -} - -/* ---------- Message List ---------- */ -.sc-ai-message-list { - display: flex; - flex-direction: column; - gap: var(--sc-ai-spacing-md); - max-width: var(--sc-ai-max-width); - margin: 0 auto; - padding: var(--sc-ai-spacing-lg); - width: 100%; -} - -.sc-ai-message-list__footer { - min-height: var(--sc-ai-spacing-lg); -} - -/* ---------- Turn ---------- */ -.sc-ai-turn { - display: flex; - flex-direction: column; - gap: var(--sc-ai-spacing-sm); -} - -/* ---------- Message Bubbles ---------- */ -.sc-ai-message { - display: flex; -} - -.sc-ai-message--user { - justify-content: flex-end; -} - -.sc-ai-message--assistant { - justify-content: flex-start; -} - -.sc-ai-message__bubble { - max-width: 85%; - padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); - border-radius: var(--sc-ai-border-radius-lg); - word-break: break-word; -} - -.sc-ai-message--user .sc-ai-message__bubble { - background: var(--sc-ai-color-bubble-user); - color: var(--sc-ai-color-bubble-user-text); - border-bottom-right-radius: var(--sc-ai-border-radius-sm); -} - -.sc-ai-message--assistant .sc-ai-message__bubble { - background: var(--sc-ai-color-bubble-assistant); - color: var(--sc-ai-color-bubble-assistant-text); - border-bottom-left-radius: var(--sc-ai-border-radius-sm); -} - -.sc-ai-message__content { - white-space: pre-wrap; -} - -.sc-ai-rich-text__paragraph, -.sc-ai-rich-text__heading, -.sc-ai-rich-text__quote, -.sc-ai-rich-text__list, -.sc-ai-rich-text__code-block, -.sc-ai-rich-text__table-container { - margin-block: 0 0.75em; -} - -.sc-ai-message__content > :last-child { - margin-bottom: 0; -} - -.sc-ai-rich-text__heading { - line-height: 1.25; -} - -.sc-ai-rich-text__inline-code, -.sc-ai-rich-text__code-block { - font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; - background: var(--sc-ai-color-surface-hover); - border-radius: var(--sc-ai-border-radius-sm); -} - -.sc-ai-rich-text__inline-code { - padding: 0.1em 0.3em; -} - -.sc-ai-rich-text__code-block { - overflow-x: auto; - padding: var(--sc-ai-spacing-sm); -} - -.sc-ai-rich-text__quote { - border-left: 0.25rem solid var(--sc-ai-color-border); - padding-left: var(--sc-ai-spacing-md); -} - -.sc-ai-rich-text__list-item > .sc-ai-rich-text__paragraph { - display: inline; -} - -.sc-ai-rich-text__table-container { - overflow-x: auto; -} - -.sc-ai-rich-text__table { - border-collapse: collapse; - width: 100%; -} - -.sc-ai-rich-text__table td { - border: 1px solid var(--sc-ai-color-border); - padding: var(--sc-ai-spacing-xs) var(--sc-ai-spacing-sm); -} - -.sc-ai-rich-text__table-cell--center { - text-align: center; -} - -.sc-ai-rich-text__table-cell--right { - text-align: right; -} - -/* Streaming cursor */ -.sc-ai-message__content--streaming::after { - content: ""; - display: inline-block; - width: 2px; - height: 1em; - background: currentColor; - margin-left: 1px; - vertical-align: text-bottom; - animation: sc-ai-blink 1s step-end infinite; -} - -@keyframes sc-ai-blink { - 0%, 100% { opacity: 1; } - 50% { opacity: 0; } -} - -/* ---------- Approval ---------- */ -.sc-ai-approval { - border: 1px solid var(--sc-ai-color-border); - border-radius: var(--sc-ai-border-radius-sm); - padding: var(--sc-ai-spacing-md); -} - -.sc-ai-approval__header { - margin-bottom: var(--sc-ai-spacing-sm); - font-weight: var(--sc-ai-font-weight-medium); -} - -.sc-ai-approval__tool-name, -.sc-ai-approval__status { - font-size: var(--sc-ai-font-size-sm); -} - -.sc-ai-approval__tool-name { - color: var(--sc-ai-color-text-secondary); - margin-bottom: var(--sc-ai-spacing-sm); -} - -.sc-ai-approval__arguments { - overflow-x: auto; - padding: var(--sc-ai-spacing-sm); - background: var(--sc-ai-color-surface-hover); - border-radius: var(--sc-ai-border-radius-sm); -} - -.sc-ai-approval__actions { - display: flex; - gap: var(--sc-ai-spacing-sm); -} - -.sc-ai-approval__status { - font-weight: var(--sc-ai-font-weight-medium); -} - -.sc-ai-approval__status--approved { - color: var(--sc-ai-color-success); -} - -.sc-ai-approval__status--rejected { - color: var(--sc-ai-color-error); -} - -/* ---------- Typing Indicator ---------- */ -.sc-ai-typing { - display: inline-flex; - align-items: center; - gap: 4px; - padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); -} - -.sc-ai-typing__dot { - width: 6px; - height: 6px; - border-radius: 50%; - background: var(--sc-ai-color-text-secondary); - animation: sc-ai-bounce 1.4s ease-in-out infinite; -} - -.sc-ai-typing__dot:nth-child(2) { - animation-delay: 0.2s; -} - -.sc-ai-typing__dot:nth-child(3) { - animation-delay: 0.4s; -} - -@keyframes sc-ai-bounce { - 0%, 80%, 100% { transform: translateY(0); } - 40% { transform: translateY(-6px); } -} - -/* ---------- Error Banner ---------- */ -.sc-ai-error { - display: flex; - align-items: center; - gap: var(--sc-ai-spacing-sm); - padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); - background: var(--sc-ai-color-error-bg); - color: var(--sc-ai-color-error); - border-radius: var(--sc-ai-border-radius-sm); - font-size: var(--sc-ai-font-size-sm); -} - -.sc-ai-error__message { - flex: 1; -} - -/* ---------- Message Input ---------- */ -.sc-ai-input { - display: flex; - align-items: flex-end; - gap: var(--sc-ai-spacing-sm); - padding: var(--sc-ai-spacing-sm); - background: var(--sc-ai-color-surface); - border: 1px solid var(--sc-ai-color-border); - border-radius: var(--sc-ai-border-radius-lg); - transition: border-color var(--sc-ai-transition-fast); -} - -.sc-ai-input:focus-within { - border-color: var(--sc-ai-color-accent); -} - -.sc-ai-input__body { - flex: 1; - display: flex; - flex-direction: column; -} - -.sc-ai-input__textarea { - flex: 1; - border: none; - outline: none; - resize: none; - font-family: inherit; - font-size: inherit; - line-height: var(--sc-ai-line-height); - color: var(--sc-ai-color-text); - background: transparent; - min-height: var(--sc-ai-input-height); - max-height: 10rem; - padding: var(--sc-ai-spacing-sm); -} - -.sc-ai-input__textarea::placeholder { - color: var(--sc-ai-color-text-secondary); -} - -.sc-ai-input__textarea:disabled { - opacity: var(--sc-ai-disabled-opacity); -} - -.sc-ai-input__send { - width: 2.25rem; - height: 2.25rem; - padding: 0; - border: none; - border-radius: 50%; - background: var(--sc-ai-color-accent); - color: var(--sc-ai-color-text-on-accent); - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - flex-shrink: 0; - transition: background var(--sc-ai-transition-fast), - opacity var(--sc-ai-transition-fast); -} - -.sc-ai-input__send:hover:not(:disabled) { - background: var(--sc-ai-color-accent-hover); -} - -.sc-ai-input__send:focus-visible { - outline: none; - box-shadow: var(--sc-ai-focus-ring); -} - -.sc-ai-input__send:disabled { - opacity: var(--sc-ai-disabled-opacity); - cursor: not-allowed; -} - -.sc-ai-input__send svg { - width: 1.125rem; - height: 1.125rem; -} - -/* ---------- Chat Page Shell ---------- */ -.sc-ai-chat-page { - display: flex; - flex-direction: column; - height: 100vh; - height: 100dvh; - background: var(--sc-ai-color-bg); -} - -.sc-ai-chat-page__header { - flex-shrink: 0; -} - -.sc-ai-chat-page__body { - flex: 1; - overflow-y: auto; - -webkit-overflow-scrolling: touch; -} - -.sc-ai-chat-page__footer { - flex-shrink: 0; - border-top: 1px solid var(--sc-ai-color-border); - background: var(--sc-ai-color-surface); - padding: var(--sc-ai-spacing-md); -} - -.sc-ai-chat-page__input-container { - max-width: var(--sc-ai-max-width); - margin: 0 auto; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolBlockAttribute.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolBlockAttribute.cs deleted file mode 100644 index aace44de33cc..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolBlockAttribute.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Associates a typed with a tool name. -/// -/// -/// -/// [ToolBlock("get_weather")] -/// public partial class WeatherBlock : FunctionInvocationContentBlock; -/// -/// -[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] -public sealed class ToolBlockAttribute : Attribute -{ - /// - /// Initializes a new instance of . - /// - /// The function name emitted by the model. - public ToolBlockAttribute(string toolName) - { - ArgumentException.ThrowIfNullOrEmpty(toolName); - ToolName = toolName; - } - - /// - /// Gets the function name associated with the block. - /// - public string ToolName { get; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolParameterAttribute.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolParameterAttribute.cs deleted file mode 100644 index 945f0da645b7..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolParameterAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Populates a typed block property from a function-call argument. -/// -[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] -public sealed class ToolParameterAttribute : Attribute -{ - /// - /// Gets or sets the function argument name. The property name is used when omitted. - /// - public string? Name { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolResultAttribute.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolResultAttribute.cs deleted file mode 100644 index 0a1534c83e20..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Attributes/ToolResultAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Populates a typed block property from a function result. -/// -[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] -public sealed class ToolResultAttribute : Attribute -{ - /// - /// Gets or sets the result property name. The block property name is used when omitted. - /// - public string? Name { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ActivityContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ActivityContentBlock.cs deleted file mode 100644 index eb271897f57f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ActivityContentBlock.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Text.Json; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents activity or progress content that can change while a response streams. -/// -public class ActivityContentBlock : ContentBlock -{ - /// - /// Gets or sets the application-defined activity type. - /// - public string ActivityType { get; set; } = string.Empty; - - /// - /// Gets or sets the current activity payload. - /// - public JsonElement Content { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ApprovalStatus.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ApprovalStatus.cs deleted file mode 100644 index 52fbc2227e09..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ApprovalStatus.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Describes the response to a function approval request. -/// -public enum ApprovalStatus -{ - /// - /// The function is waiting for a response. - /// - Pending, - - /// - /// The function was approved. - /// - Approved, - - /// - /// The function was rejected. - /// - Rejected, -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/BlockLifecycleState.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/BlockLifecycleState.cs deleted file mode 100644 index 5fed8b70873c..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/BlockLifecycleState.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Describes where a is in its streaming lifecycle. -/// -public enum BlockLifecycleState -{ - /// - /// The block has been created but has not been emitted to the conversation yet. - /// - Pending, - - /// - /// The block is part of the conversation and can still receive updates from the model stream. - /// - Active, - - /// - /// The block is complete and will not receive further updates. - /// - Inactive, -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs deleted file mode 100644 index 1404a6957887..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a subscription to . -/// Disposing the subscription removes the callback from the block. -/// -public readonly struct ContentBlockChangedSubscription : IDisposable -{ - private readonly ContentBlock _owner; - private readonly Action _callback; - - internal ContentBlockChangedSubscription(ContentBlock owner, Action callback) - { - _owner = owner; - _callback = callback; - } - - /// - /// Removes the callback from the block it was registered on. - /// - public void Dispose() - { - _owner?.RemoveCallback(_callback); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs deleted file mode 100644 index e057416e7f06..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs +++ /dev/null @@ -1,123 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a function invocation that requires approval before the conversation can continue. -/// -/// -/// -/// if (block.Status == ApprovalStatus.Pending) -/// { -/// block.Approve(); -/// } -/// -/// -public class FunctionApprovalBlock : ContentBlock, IInteractiveBlock -{ - private readonly TaskCompletionSource _resultSource = - new(TaskCreationOptions.RunContinuationsAsynchronously); - private readonly object _responseLock = new(); - - internal FunctionApprovalBlock( - ContentBlock innerBlock, - ToolApprovalRequestContent request) - { - ArgumentNullException.ThrowIfNull(innerBlock); - InnerBlock = innerBlock; - ApprovalRequest = request; - } - - /// - /// Gets the wrapped function invocation block. - /// - public ContentBlock InnerBlock { get; } - - /// - /// Gets the function call represented by this block. - /// - public FunctionCallContent? Call => InnerBlock switch - { - FunctionInvocationContentBlock invocation => invocation.Call, - UIActionBlock action => action.Call, - _ => null, - }; - - /// - /// Gets the function result represented by this block. - /// - public FunctionResultContent? Result => InnerBlock switch - { - FunctionInvocationContentBlock invocation => invocation.Result, - UIActionBlock action => action.Result, - _ => null, - }; - - /// - /// Gets the name of the invoked tool. - /// - public string? ToolName => Call?.Name; - - /// - /// Gets the arguments supplied to the tool. - /// - public IDictionary? Arguments => Call?.Arguments; - - /// - /// Gets a value indicating whether the server produced a result. - /// - public bool HasResult => Result is not null; - - /// - /// Gets the current approval status. - /// - public ApprovalStatus Status { get; private set; } - - /// - /// Gets the approval request received from the chat client. - /// - public ToolApprovalRequestContent ApprovalRequest { get; } - - /// - /// Approves the function invocation. Only the first response is applied. - /// - public void Approve() - { - Respond(ApprovalStatus.Approved, reason: null); - } - - /// - /// Rejects the function invocation. Only the first response is applied. - /// - /// An optional explanation for the rejection. - public void Reject(string? reason = null) - { - Respond(ApprovalStatus.Rejected, reason); - } - - /// - public Task GetResultAsync(CancellationToken cancellationToken = default) - => _resultSource.Task.WaitAsync(cancellationToken); - - private void Respond(ApprovalStatus status, string? reason) - { - lock (_responseLock) - { - if (Status != ApprovalStatus.Pending) - { - return; - } - - Status = status; - var response = ApprovalRequest.CreateResponse( - approved: status == ApprovalStatus.Approved, - reason); - _resultSource.SetResult(response); - } - - NotifyChanged(); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs deleted file mode 100644 index f37022dfff01..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a server-side function invocation and its eventual result. -/// -/// -/// Custom content blocks that represent function invocations should derive from this type -/// and populate . This keeps the call, tool name, and arguments available -/// when other features, such as function approval, wrap the custom block. -/// -/// -/// -/// public sealed class WeatherContentBlock : FunctionInvocationContentBlock -/// { -/// public string? Location { get; set; } -/// } -/// -/// -public class FunctionInvocationContentBlock : ContentBlock -{ - private FunctionCallContent? _call; - - /// - /// Gets or sets the function call represented by this block. - /// - public FunctionCallContent? Call - { - get => _call; - set - { - _call = value; - if (value is not null) - { - Id = value.CallId; - } - } - } - - /// - /// Gets or sets the function result paired with . - /// - public FunctionResultContent? Result { get; set; } - - /// - /// Gets the name of the invoked tool. - /// - public string? ToolName => Call?.Name; - - /// - /// Gets the arguments supplied to the tool. - /// - public IDictionary? Arguments => Call?.Arguments; - - /// - /// Gets a value indicating whether the server produced a result. - /// - public bool HasResult => Result is not null; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichContentBlock.cs deleted file mode 100644 index 59887909b337..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichContentBlock.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// A block of conversational text. Text arrives in fragments while the model streams, -/// so the block accumulates the fragments and exposes both the raw text and the -/// paragraphs derived from it. -/// -public class RichContentBlock : ContentBlock -{ - private readonly List _segments = new(); - private string? _cachedText; - - /// - /// Gets the concatenation of every text fragment received so far. - /// - public string RawText => _cachedText ??= string.Concat(_segments); - - /// - /// Gets the structured representation of . - /// - public IReadOnlyList Content { get; internal set; } = Array.Empty(); - - /// - /// Appends a text fragment to this block. - /// - /// The fragment to append. - public void AppendText(string text) - { - ArgumentNullException.ThrowIfNull(text); - - _segments.Add(text); - _cachedText = null; - } - - internal void ReplaceContent(string text, IReadOnlyList content) - { - _segments.Clear(); - _segments.Add(text); - _cachedText = text; - Content = content; - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs deleted file mode 100644 index d92dfc5066a8..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a block quotation. -/// -public class BlockQuoteNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs deleted file mode 100644 index 34f5f5a674ea..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a block of code. -/// -public class CodeBlockNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public CodeBlockNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The code. - /// The optional language identifier. - public CodeBlockNode(string code, string? language = null) - { - ArgumentNullException.ThrowIfNull(code); - Code = code; - Language = language; - } - - /// - /// Gets or sets the language identifier. - /// - public string? Language { get; set; } - - /// - /// Gets or sets the code. - /// - public string Code { get; set; } = string.Empty; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs deleted file mode 100644 index a3b9507608b6..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a link or image reference definition. -/// -public class DefinitionNode : RichTextNode -{ - /// - /// Gets or sets the reference label. - /// - public string Label { get; set; } = string.Empty; - - /// - /// Gets or sets the target URL. - /// - public string Url { get; set; } = string.Empty; - - /// - /// Gets or sets the optional title. - /// - public string? Title { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs deleted file mode 100644 index 300932d81b29..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents emphasized text. -/// -public class EmphasisNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs deleted file mode 100644 index 7f12bf111a4d..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a footnote definition. -/// -/// -/// A mapper can use this node for labeled footnote content, such as content represented by -/// a Markdig footnote container. The core library does not parse or resolve footnote syntax. -/// -public class FootnoteDefinitionNode : RichTextNode -{ - /// - /// Gets or sets the footnote label. - /// - public string Label { get; set; } = string.Empty; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs deleted file mode 100644 index 97d4926e368c..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents footnote content supplied by an application's rich-text mapper. -/// -/// -/// Parsers model footnotes differently. For example, Markdig exposes footnote containers, -/// links, and an end-of-document footnote group. A mapper can project those parser-specific -/// objects into the footnote presentation nodes without introducing a parser dependency. -/// -public class FootnoteNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs deleted file mode 100644 index 9c67171555fb..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a footnote reference. -/// -/// -/// A mapper can use this node for a reference such as a Markdig footnote link. The core -/// library does not parse the reference or resolve its label. -/// -public class FootnoteReferenceNode : RichTextNode -{ - /// - /// Gets or sets the footnote label. - /// - public string Label { get; set; } = string.Empty; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HeadingNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HeadingNode.cs deleted file mode 100644 index bc36c95d3968..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HeadingNode.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a heading. -/// -public class HeadingNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public HeadingNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The heading level. - public HeadingNode(int level) - { - Level = level; - } - - /// - /// Gets or sets the heading level. - /// - public int Level { get; set; } = 1; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HtmlNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HtmlNode.cs deleted file mode 100644 index 8358abe5f750..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/HtmlNode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents HTML source. The default renderer displays the source as text. -/// -public class HtmlNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public HtmlNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The HTML source. - public HtmlNode(string value) - { - ArgumentNullException.ThrowIfNull(value); - Value = value; - } - - /// - /// Gets or sets the HTML source. - /// - public string Value { get; set; } = string.Empty; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageNode.cs deleted file mode 100644 index e1838c7d1fca..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageNode.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents an image. -/// -public class ImageNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public ImageNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The image URL. - /// The alternative text. - /// The optional title. - public ImageNode(string url, string? alt = null, string? title = null) - { - ArgumentNullException.ThrowIfNull(url); - Url = url; - Alt = alt; - Title = title; - } - - /// - /// Gets or sets the image URL. - /// - public string Url { get; set; } = string.Empty; - - /// - /// Gets or sets the alternative text. - /// - public string? Alt { get; set; } - - /// - /// Gets or sets the optional title. - /// - public string? Title { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs deleted file mode 100644 index 75b3c2af11aa..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a reference-style image. -/// -public class ImageReferenceNode : RichTextNode -{ - /// - /// Gets or sets the reference label. - /// - public string Label { get; set; } = string.Empty; - - /// - /// Gets or sets the alternative text. - /// - public string? Alt { get; set; } - - /// - /// Gets or sets the reference syntax. - /// - public ReferenceKind ReferenceKind { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs deleted file mode 100644 index 4be230f1651d..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents inline code. -/// -public class InlineCodeNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public InlineCodeNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The code. - public InlineCodeNode(string code) - { - ArgumentNullException.ThrowIfNull(code); - Code = code; - } - - /// - /// Gets or sets the code. - /// - public string Code { get; set; } = string.Empty; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs deleted file mode 100644 index 3d62aabab60f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a forced visual line break. -/// -/// -/// This node does not encode a parser-specific soft or hard line-ending distinction. A -/// mapper from Markdig or any other parser decides whether a source line ending becomes -/// whitespace, text, or a . -/// -public class LineBreakNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkNode.cs deleted file mode 100644 index 8542750d2168..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkNode.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a hyperlink. -/// -public class LinkNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public LinkNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The link URL. - /// The optional title. - public LinkNode(string url, string? title = null) - { - ArgumentNullException.ThrowIfNull(url); - Url = url; - Title = title; - } - - /// - /// Gets or sets the link URL. - /// - public string Url { get; set; } = string.Empty; - - /// - /// Gets or sets the optional title. - /// - public string? Title { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs deleted file mode 100644 index 16a71493402f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a reference-style link. -/// -public class LinkReferenceNode : RichTextNode -{ - /// - /// Gets or sets the reference label. - /// - public string Label { get; set; } = string.Empty; - - /// - /// Gets or sets the reference syntax. - /// - public ReferenceKind ReferenceKind { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListItemNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListItemNode.cs deleted file mode 100644 index a85200b58442..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListItemNode.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a list item. -/// -public class ListItemNode : RichTextNode -{ - /// - /// Gets or sets the checked state when the item is a task. - /// - public bool? Checked { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListNode.cs deleted file mode 100644 index 6c7d263e6143..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ListNode.cs +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents an ordered or unordered list. -/// -public class ListNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public ListNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// Whether the list is ordered. - /// The optional starting number. - public ListNode(bool ordered, int? start = null) - { - Ordered = ordered; - Start = start; - } - - /// - /// Gets or sets a value indicating whether the list is ordered. - /// - public bool Ordered { get; set; } - - /// - /// Gets or sets the starting number of an ordered list. - /// - public int? Start { get; set; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs deleted file mode 100644 index 7b105148c32d..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a paragraph. -/// -public class ParagraphNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs deleted file mode 100644 index 16486d946fa2..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Describes the syntax used by a reference. -/// -public enum ReferenceKind -{ - /// - /// A shortcut reference. - /// - Shortcut, - - /// - /// A collapsed reference. - /// - Collapsed, - - /// - /// A full reference. - /// - Full, -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextContent.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextContent.cs deleted file mode 100644 index ea65d1dd4748..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextContent.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a complete snapshot of structured text in a streaming chat response. -/// -/// -/// Providers can emit a new snapshot as text streams. The block mapping pipeline replaces -/// the previous snapshot without exposing a partially mutated tree to renderers. -/// The constructor copies the top-level node list, but the nodes themselves remain shared. -/// Callers must not mutate nodes after publishing the content. -/// -public class RichTextContent : AIContent -{ - /// - /// Initializes a new instance of . - /// - /// The plain-text representation of the content. - /// - /// The structured nodes that represent . The constructor copies this - /// list but does not clone the nodes. - /// - public RichTextContent(string text, IReadOnlyList nodes) - { - ArgumentNullException.ThrowIfNull(text); - ArgumentNullException.ThrowIfNull(nodes); - - Text = text; - Nodes = [.. nodes]; - } - - /// - /// Gets the plain-text representation of the content. - /// - public string Text { get; } - - /// - /// Gets the structured nodes that represent . - /// - public IReadOnlyList Nodes { get; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextNode.cs deleted file mode 100644 index 7c66c897d9fa..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextNode.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a node in structured conversational text. -/// -/// -/// This hierarchy describes presentation semantics and does not prescribe a source format -/// or parser. Applications can map output from Markdig or any other parser into these nodes. -/// The mapper is responsible for interpreting source syntax, resolving references, and -/// deciding which presentation node represents each source construct. -/// -public abstract class RichTextNode -{ - private List? _children; - - /// - /// Gets the child nodes. - /// - public IReadOnlyList Children => - _children ?? (IReadOnlyList)Array.Empty(); - - /// - /// Adds a child node. - /// - /// The child to add. - public void AddChild(RichTextNode child) - { - ArgumentNullException.ThrowIfNull(child); - - _children ??= new(); - _children.Add(child); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs deleted file mode 100644 index adac69763c9f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents struck-through text. -/// -public class StrikethroughNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrongNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrongNode.cs deleted file mode 100644 index b2c12926d787..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/StrongNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents strongly emphasized text. -/// -public class StrongNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableCellNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableCellNode.cs deleted file mode 100644 index 79e42f2743d5..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableCellNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a table cell. -/// -public class TableCellNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs deleted file mode 100644 index e5bcad07eff7..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Describes the alignment of a table column. -/// -public enum TableColumnAlignment -{ - /// - /// No alignment was specified. - /// - None, - - /// - /// Left-aligned. - /// - Left, - - /// - /// Center-aligned. - /// - Center, - - /// - /// Right-aligned. - /// - Right, -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableNode.cs deleted file mode 100644 index e819464fe62f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableNode.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a table. -/// -public class TableNode : RichTextNode -{ - /// - /// Gets or sets each column's alignment. - /// - public IReadOnlyList Alignment { get; set; } = - Array.Empty(); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableRowNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableRowNode.cs deleted file mode 100644 index e09ce01bb34f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TableRowNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a table row. -/// -public class TableRowNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TextNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TextNode.cs deleted file mode 100644 index 958be5d930d2..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/TextNode.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents plain text. -/// -public class TextNode : RichTextNode -{ - /// - /// Initializes a new instance of . - /// - public TextNode() - { - } - - /// - /// Initializes a new instance of . - /// - /// The text. - public TextNode(string text) - { - ArgumentNullException.ThrowIfNull(text); - Text = text; - } - - /// - /// Gets or sets the text. - /// - public string Text { get; set; } = string.Empty; -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs deleted file mode 100644 index e465c724a625..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a thematic break. -/// -public class ThematicBreakNode : RichTextNode; diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/UIActionBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/UIActionBlock.cs deleted file mode 100644 index 6389624516e7..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/UIActionBlock.cs +++ /dev/null @@ -1,101 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a function call that must execute in the UI before the conversation can continue. -/// -/// -/// Register the corresponding function with -/// . Renderers can call -/// to execute it in the current UI circuit. -/// -/// -/// -/// <BlockRenderer TBlock="UIActionBlock" Context="action"> -/// <button @onclick="() => action.InvokeAsync()">Run</button> -/// </BlockRenderer> -/// -/// -public class UIActionBlock : ContentBlock, IInteractiveBlock -{ - private readonly AIFunction _function; - private readonly TaskCompletionSource _resultSource = - new(TaskCreationOptions.RunContinuationsAsynchronously); - private readonly object _invocationLock = new(); - private Task? _invocation; - - internal UIActionBlock(AIFunction function, FunctionCallContent call) - { - _function = function; - Call = call; - } - - /// - /// Gets the function call requested by the model. - /// - public FunctionCallContent Call { get; } - - /// - /// Gets the registered UI action name. - /// - public string ToolName => Call.Name; - - /// - /// Gets the function result after the action completes. - /// - public FunctionResultContent? Result { get; private set; } - - /// - /// Gets a value indicating whether the action completed successfully. - /// - public bool IsComplete => Result is not null; - - /// - /// Executes the registered function once using the arguments supplied by the model. - /// - /// - /// A token that cancels the action when this call starts it. Subsequent calls return the - /// existing invocation task and do not replace its cancellation token. - /// - /// A task that completes when the action has finished. - public Task InvokeAsync(CancellationToken cancellationToken = default) - { - lock (_invocationLock) - { - _invocation ??= InvokeCoreAsync(cancellationToken); - return _invocation; - } - } - - /// - public Task GetResultAsync(CancellationToken cancellationToken = default) - => _resultSource.Task.WaitAsync(cancellationToken); - - private async Task InvokeCoreAsync(CancellationToken cancellationToken) - { - try - { - var arguments = Call.Arguments is not null - ? new AIFunctionArguments(Call.Arguments) - : null; - var result = await _function.InvokeAsync(arguments, cancellationToken); - Result = new FunctionResultContent(Call.CallId ?? Id, result); - NotifyChanged(); - _resultSource.TrySetResult(Result); - } - catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested) - { - _resultSource.TrySetCanceled(cancellationToken); - throw; - } - catch (Exception exception) - { - _resultSource.TrySetException(exception); - throw; - } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/AgentBoundary.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/AgentBoundary.cs deleted file mode 100644 index 11712b97b29f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/AgentBoundary.cs +++ /dev/null @@ -1,78 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Components.Rendering; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Creates the for a and cascades it to the -/// chat components underneath it. -/// -public class AgentBoundary : ComponentBase, IDisposable -{ - private AgentContext _context = default!; - private UIAgent _currentAgent = default!; - - /// - /// Gets or sets the agent that drives the conversation. - /// - [Parameter, EditorRequired] - public UIAgent Agent { get; set; } = default!; - - /// - /// Gets or sets the content rendered inside the boundary. - /// - [Parameter] - public RenderFragment? ChildContent { get; set; } - - /// - protected override void OnInitialized() - { - _currentAgent = Agent; - _context = new AgentContext(Agent); - } - - /// - protected override void OnParametersSet() - { - if (!ReferenceEquals(Agent, _currentAgent)) - { - // Agent changed — tear down the old context and create a new one. - // BuildRenderTree uses OpenRegion keyed on the context, so Blazor will - // also tear down and recreate all descendant components. - _context?.Dispose(); - _currentAgent = Agent; - _context = new AgentContext(Agent); - } - } - - /// - protected override void BuildRenderTree(RenderTreeBuilder builder) - { - // If Agent changes, the region key changes, causing Blazor to tear down - // and recreate all descendants. This is the same trick EditForm uses with - // EditContext. It lets us safely use IsFixed=true on the CascadingValue. - builder.OpenRegion(_context.GetHashCode()); - - builder.OpenComponent>(0); - builder.AddComponentParameter(1, "Value", _context); - builder.AddComponentParameter(2, "IsFixed", true); - builder.AddComponentParameter(3, "ChildContent", (RenderFragment)(inner => - { - inner.AddContent(10, ChildContent); - })); - builder.CloseComponent(); - - builder.CloseRegion(); - } - - /// - /// Disposes the owned by this boundary. - /// - public void Dispose() - { - _context?.Dispose(); - GC.SuppressFinalize(this); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockContainer.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockContainer.cs deleted file mode 100644 index f26a04e57ab0..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockContainer.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -// Renders a single block and re-renders the message list when the block changes. -internal class BlockContainer : IDisposable -{ - private readonly ContentBlock _block; - private readonly MessageListContext _listContext; - private readonly ContentBlockChangedSubscription _changedSub; - - internal BlockContainer(ContentBlock block, MessageListContext listContext, Action requestRender) - { - _block = block; - _listContext = listContext; - _changedSub = block.OnChanged(requestRender); - } - - internal void RenderTo(Rendering.RenderTreeBuilder builder, int seq) - { - var fragment = _listContext.RenderBlock(_block); - builder.AddContent(seq, fragment); - } - - public void Dispose() - { - _changedSub.Dispose(); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRenderer.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRenderer.cs deleted file mode 100644 index 7a3492a7255e..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRenderer.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Registers custom markup for a block type inside a . The most -/// recently registered renderer that matches a block wins. -/// -/// The block type this renderer handles. -/// -/// -/// <MessageList> -/// <BlockRenderer TBlock="RichContentBlock" Context="block"> -/// <p>@block.RawText</p> -/// </BlockRenderer> -/// </MessageList> -/// -/// -public class BlockRenderer : IComponent, IDisposable where TBlock : ContentBlock -{ - private RenderHandle _renderHandle; - private bool _initialized; - private BlockRendererRegistration? _registration; - - /// - /// Gets or sets the message list this renderer registers with. - /// - [CascadingParameter] - public MessageListContext ListContext { get; set; } = default!; - - /// - /// Gets or sets the markup rendered for a matching block. - /// - [Parameter] - public RenderFragment? ChildContent { get; set; } - - /// - /// Gets or sets a predicate that narrows which blocks this renderer handles. - /// - [Parameter] - public Func? When { get; set; } - - void IComponent.Attach(RenderHandle renderHandle) - { - _renderHandle = renderHandle; - } - - Task IComponent.SetParametersAsync(ParameterView parameters) - { - parameters.SetParameterProperties(this); - - if (ListContext is null) - { - throw new InvalidOperationException( - "BlockRenderer must be placed inside a MessageList."); - } - - if (ChildContent is null) - { - throw new InvalidOperationException("BlockRenderer requires child content."); - } - - if (!_initialized) - { - _initialized = true; - - _registration = new BlockRendererRegistration - { - BlockType = typeof(TBlock), - // Capture 'this' so the lambda reads the latest When/ChildContent at invocation time - When = block => block is TBlock typed && (When is null || When(typed)), - Render = block => ChildContent((TBlock)block) - }; - - ListContext.AddRegistration(_registration); - } - - return Task.CompletedTask; - } - - /// - /// Removes this renderer from the message list. - /// - public void Dispose() - { - if (_registration is not null) - { - ListContext?.RemoveRegistration(_registration); - } - - GC.SuppressFinalize(this); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRendererRegistration.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRendererRegistration.cs deleted file mode 100644 index b876c68cb91f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/BlockRendererRegistration.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -internal class BlockRendererRegistration -{ - public required Type BlockType { get; init; } - - public Func? When { get; init; } - - public required Func Render { get; init; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ChatPage.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ChatPage.cs deleted file mode 100644 index e40835a996e1..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ChatPage.cs +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Components.Rendering; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Full page chat shell: an around a scrollable -/// and a . -/// -/// -/// -/// <ChatPage Agent="agent" Placeholder="Ask me anything" /> -/// -/// -public sealed class ChatPage : ComponentBase -{ - /// - /// Gets or sets the agent that drives the conversation. - /// - [Parameter, EditorRequired] - public UIAgent Agent { get; set; } = default!; - - /// - /// Gets or sets the content rendered above the conversation. - /// - [Parameter] - public RenderFragment? Header { get; set; } - - /// - /// Gets or sets the content rendered when the conversation is empty. - /// - [Parameter] - public RenderFragment? WelcomeContent { get; set; } - - /// - /// Gets or sets the content rendered inside the message list, typically - /// registrations. - /// - [Parameter] - public RenderFragment? MessageListContent { get; set; } - - /// - /// Gets or sets the placeholder text of the message input. - /// - [Parameter] - public string? Placeholder { get; set; } - - /// - /// Gets or sets the content rendered before the message input text area. - /// - [Parameter] - public RenderFragment? InputLeadingActions { get; set; } - - /// - /// Gets or sets the content rendered after the message input text area. - /// - [Parameter] - public RenderFragment? InputTrailingActions { get; set; } - - /// - /// Gets or sets additional attributes applied to the root element. - /// - [Parameter(CaptureUnmatchedValues = true)] - public Dictionary? AdditionalAttributes { get; set; } - - /// - protected override void BuildRenderTree(RenderTreeBuilder builder) - { - builder.OpenElement(0, "div"); - builder.AddMultipleAttributes(1, AdditionalAttributes); - builder.AddAttribute(2, "class", CssClass()); - - if (Header is not null) - { - builder.OpenElement(10, "div"); - builder.AddAttribute(11, "class", "sc-ai-chat-page__header"); - builder.AddContent(12, Header); - builder.CloseElement(); - } - - builder.OpenComponent(20); - builder.AddComponentParameter(21, "Agent", Agent); - builder.AddComponentParameter(22, "ChildContent", (RenderFragment)(inner => - { - // Body (scrollable area) - inner.OpenElement(30, "div"); - inner.AddAttribute(31, "class", "sc-ai-chat-page__body"); - - inner.OpenComponent(32); - inner.AddComponentParameter(33, "ChildContent", MessageListContent); - inner.AddComponentParameter(34, "EmptyContent", WelcomeContent); - inner.CloseComponent(); // MessageList - - inner.CloseElement(); // body - - // Footer (input area) - inner.OpenElement(50, "div"); - inner.AddAttribute(51, "class", "sc-ai-chat-page__footer"); - inner.OpenElement(52, "div"); - inner.AddAttribute(53, "class", "sc-ai-chat-page__input-container"); - - inner.OpenComponent(54); - inner.AddComponentParameter(55, "Placeholder", Placeholder); - inner.AddComponentParameter(56, "LeadingActions", InputLeadingActions); - inner.AddComponentParameter(57, "TrailingActions", InputTrailingActions); - inner.CloseComponent(); // MessageInput - - inner.CloseElement(); // input-container - inner.CloseElement(); // footer - })); - builder.CloseComponent(); // AgentBoundary - - builder.CloseElement(); // root div - } - - private string CssClass() - { - var css = "sc-ai-root sc-ai-chat-page"; - if (AdditionalAttributes?.TryGetValue("class", out var existing) == true && existing is string s) - { - css = $"{css} {s}"; - } - - return css; - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ConversationTurnRenderer.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ConversationTurnRenderer.cs deleted file mode 100644 index a3666f9aef00..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/ConversationTurnRenderer.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Components.Rendering; - -namespace Microsoft.AspNetCore.Components.AI; - -// Renders one conversation turn: its request blocks followed by its response blocks. -internal class ConversationTurnRenderer : IDisposable -{ - private readonly ConversationTurn _turn; - private readonly MessageListContext _listContext; - private readonly Action _requestRender; - private readonly List _blockContainers = new(); - private readonly IDisposable? _blockAddedSub; - - internal ConversationTurnRenderer( - AgentContext agentContext, - ConversationTurn turn, - MessageListContext listContext, - Action requestRender) - { - _turn = turn; - _listContext = listContext; - _requestRender = requestRender; - - _blockAddedSub = agentContext.RegisterOnBlockAdded((t, block) => - { - if (ReferenceEquals(t, _turn)) - { - OnBlockAdded(block); - } - }); - - foreach (var block in turn.RequestBlocks) - { - _blockContainers.Add(new BlockContainer(block, _listContext, _requestRender)); - } - foreach (var block in turn.ResponseBlocks) - { - _blockContainers.Add(new BlockContainer(block, _listContext, _requestRender)); - } - } - - private void OnBlockAdded(ContentBlock block) - { - _blockContainers.Add(new BlockContainer(block, _listContext, _requestRender)); - _requestRender(); - } - - internal void RenderTo(RenderTreeBuilder builder, int baseSeq) - { - // Determine role from request blocks (user turn) or response blocks - var role = _turn.RequestBlocks.Count > 0 ? "user" : "assistant"; - builder.OpenElement(baseSeq, "div"); - builder.AddAttribute(baseSeq + 1, "class", $"sc-ai-turn sc-ai-turn--{role}"); - var seq = baseSeq + 10; - foreach (var container in _blockContainers) - { - container.RenderTo(builder, seq); - seq += 10; - } - builder.CloseElement(); - } - - public void Dispose() - { - _blockAddedSub?.Dispose(); - foreach (var container in _blockContainers) - { - container.Dispose(); - } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageList.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageList.cs deleted file mode 100644 index 70e703f29806..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageList.cs +++ /dev/null @@ -1,204 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Components.Rendering; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Renders the turns of the cascaded and updates them as blocks -/// stream in. -/// -[StreamRendering] -public class MessageList : IComponent, IDisposable -{ - private RenderHandle _renderHandle; - private AgentContext _agentContext = default!; - private RenderFragment? _childContent; - private RenderFragment? _footer; - private readonly MessageListContext _listContext = new(); - private readonly List _turnRenderers = new(); - private IDisposable? _turnAddedSub; - private IDisposable? _statusChangedSub; - - /// - /// Gets or sets the conversation rendered by this list. - /// - [CascadingParameter] - public AgentContext AgentContext { get; set; } = default!; - - /// - /// Gets or sets the content rendered above the turns. Use it to register - /// components. - /// - [Parameter] - public RenderFragment? ChildContent { get; set; } - - /// - /// Gets or sets the content rendered when the conversation has no turns. - /// - [Parameter] - public RenderFragment? EmptyContent { get; set; } - - /// - /// Gets or sets the content rendered below the turns. Defaults to the streaming and error - /// indicators. - /// - [Parameter] - public RenderFragment? Footer { get; set; } - - void IComponent.Attach(RenderHandle renderHandle) - { - _renderHandle = renderHandle; - } - - Task IComponent.SetParametersAsync(ParameterView parameters) - { - parameters.SetParameterProperties(this); - var newAgentContext = AgentContext - ?? throw new InvalidOperationException( - "MessageList must be inside an AgentBoundary."); - - if (!ReferenceEquals(_agentContext, newAgentContext)) - { - ResetRegistrations(); - _agentContext = newAgentContext; - _listContext.OnRegistrationsChanged = Render; - - _turnAddedSub = _agentContext.RegisterOnTurnAdded(OnTurnAdded); - _statusChangedSub = _agentContext.RegisterOnStatusChanged(_ => Render()); - - foreach (var turn in _agentContext.Turns) - { - var renderer = new ConversationTurnRenderer( - _agentContext, turn, _listContext, Render); - _turnRenderers.Add(renderer); - } - } - - _childContent = ChildContent; - _footer = Footer; - - Render(); - return Task.CompletedTask; - } - - private void OnTurnAdded(ConversationTurn turn) - { - var renderer = new ConversationTurnRenderer( - _agentContext, turn, _listContext, Render); - _turnRenderers.Add(renderer); - Render(); - } - - private void Render() - { - _renderHandle.Render(builder => - { - builder.OpenComponent>(0); - builder.AddComponentParameter(1, "Value", _listContext); - builder.AddComponentParameter(2, "IsFixed", true); - builder.AddComponentParameter(3, "ChildContent", - (RenderFragment)(inner => - { - inner.OpenElement(3, "div"); - inner.AddAttribute(3, "class", "sc-ai-message-list"); - if (_childContent is not null) - { - inner.AddContent(4, _childContent); - } - - if (_turnRenderers.Count == 0 && EmptyContent is not null) - { - inner.AddContent(5, EmptyContent); - } - - var seq = 100; - foreach (var turnRenderer in _turnRenderers) - { - turnRenderer.RenderTo(inner, seq); - seq += 100; - } - - inner.OpenElement(seq, "div"); - inner.AddAttribute(seq + 1, "class", "sc-ai-message-list__footer"); - if (_footer is not null) - { - inner.AddContent(seq + 2, _footer(_agentContext)); - } - else - { - RenderDefaultFooter(inner, seq + 2); - } - inner.CloseElement(); // footer div - - inner.CloseElement(); // sc-ai-message-list div - })); - builder.CloseComponent(); - }); - } - - private void RenderDefaultFooter(RenderTreeBuilder builder, int seq) - { - switch (_agentContext.Status) - { - case ConversationStatus.Streaming: - builder.OpenElement(seq, "div"); - builder.AddAttribute(seq + 1, "class", "sc-ai-typing"); - builder.AddAttribute(seq + 2, "role", "status"); - builder.AddAttribute(seq + 3, "aria-label", "Agent is typing"); - for (var i = 0; i < 3; i++) - { - builder.OpenElement(seq + 4 + i, "span"); - builder.AddAttribute(seq + 7 + i, "class", "sc-ai-typing__dot"); - builder.CloseElement(); - } - builder.CloseElement(); - break; - - case ConversationStatus.Error: - builder.OpenElement(seq, "div"); - builder.AddAttribute(seq + 1, "class", "sc-ai-error"); - builder.AddAttribute(seq + 2, "role", "alert"); - builder.OpenElement(seq + 3, "span"); - builder.AddAttribute(seq + 4, "class", "sc-ai-error__message"); - builder.AddContent(seq + 5, "Something went wrong. Please try again."); - builder.CloseElement(); // span - builder.OpenElement(seq + 6, "button"); - builder.AddAttribute(seq + 7, "type", "button"); - builder.AddAttribute(seq + 8, "class", "sc-ai-btn sc-ai-btn--secondary"); - builder.AddAttribute(seq + 9, "onclick", - EventCallback.Factory.Create(this, - () => _agentContext.RetryAsync())); - builder.AddContent(seq + 10, "Retry"); - builder.CloseElement(); // button - builder.CloseElement(); // div - break; - } - } - - private void ResetRegistrations() - { - _turnAddedSub?.Dispose(); - _turnAddedSub = null; - - _statusChangedSub?.Dispose(); - _statusChangedSub = null; - - foreach (var renderer in _turnRenderers) - { - renderer.Dispose(); - } - - _turnRenderers.Clear(); - } - - /// - /// Removes the subscriptions this list registered on the conversation. - /// - public void Dispose() - { - ResetRegistrations(); - GC.SuppressFinalize(this); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageListContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageListContext.cs deleted file mode 100644 index b262655f5864..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageListContext.cs +++ /dev/null @@ -1,451 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Components.Rendering; -using Microsoft.Extensions.AI; -using System.Text.Json; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Resolves the markup used to render a block inside a . Renderers -/// registered with take precedence over the built-in -/// rendering. -/// -public class MessageListContext -{ - private static readonly JsonSerializerOptions IndentedJsonOptions = new() - { - WriteIndented = true, - }; - - private readonly List _registrations = new(); - - /// - /// Returns the markup for a block. - /// - /// The block to render. - /// The markup that renders . - public RenderFragment RenderBlock(ContentBlock block) - { - ArgumentNullException.ThrowIfNull(block); - - for (var i = _registrations.Count - 1; i >= 0; i--) - { - var reg = _registrations[i]; - if (reg.BlockType.IsAssignableFrom(block.GetType()) - && (reg.When is null || reg.When(block))) - { - return reg.Render(block); - } - } - - return builder => - { - if (block is RichContentBlock rich) - { - var role = block.Role == ChatRole.User ? "user" : "assistant"; - builder.OpenElement(0, "div"); - builder.AddAttribute(1, "class", $"sc-ai-message sc-ai-message--{role}"); - builder.OpenElement(2, "div"); - builder.AddAttribute(3, "class", "sc-ai-message__bubble"); - builder.OpenElement(4, "div"); - var contentClass = block.LifecycleState == BlockLifecycleState.Active - ? "sc-ai-message__content sc-ai-message__content--streaming" - : "sc-ai-message__content"; - builder.AddAttribute(5, "class", contentClass); - if (rich.Content.Count > 0) - { - RenderRichTextNodes(builder, rich.Content); - } - else - { - builder.AddContent(6, rich.RawText); - } - builder.CloseElement(); // content div - builder.CloseElement(); // bubble div - builder.CloseElement(); // message div - } - else if (block is FunctionApprovalBlock approval) - { - RenderApprovalBlock(builder, approval); - } - else if (block is not FunctionInvocationContentBlock) - { - builder.OpenElement(0, "div"); - builder.AddAttribute(1, "class", "sc-ai-unknown-block"); - builder.AddContent(2, block.GetType().Name); - builder.CloseElement(); - } - }; - } - - internal Action? OnRegistrationsChanged { get; set; } - - internal void AddRegistration(BlockRendererRegistration registration) - { - _registrations.Add(registration); - OnRegistrationsChanged?.Invoke(); - } - - internal void RemoveRegistration(BlockRendererRegistration registration) - { - _registrations.Remove(registration); - OnRegistrationsChanged?.Invoke(); - } - - private static void RenderRichTextNodes( - RenderTreeBuilder builder, - IReadOnlyList nodes) - { - foreach (var node in nodes) - { - builder.OpenRegion(0); - RenderRichTextNode(builder, node); - builder.CloseRegion(); - } - } - - private static void RenderRichTextNode(RenderTreeBuilder builder, RichTextNode node) - { - switch (node) - { - case TextNode text: - builder.AddContent(0, text.Text); - break; - case ParagraphNode: - RenderElement(builder, "p", "sc-ai-rich-text__paragraph", node.Children); - break; - case HeadingNode heading: - RenderElement( - builder, - $"h{Math.Clamp(heading.Level, 1, 6)}", - "sc-ai-rich-text__heading", - node.Children); - break; - case EmphasisNode: - RenderElement(builder, "em", null, node.Children); - break; - case StrongNode: - RenderElement(builder, "strong", null, node.Children); - break; - case StrikethroughNode: - RenderElement(builder, "s", null, node.Children); - break; - case InlineCodeNode inlineCode: - builder.OpenElement(0, "code"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__inline-code"); - builder.AddContent(2, inlineCode.Code); - builder.CloseElement(); - break; - case CodeBlockNode codeBlock: - builder.OpenElement(0, "pre"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__code-block"); - builder.OpenElement(2, "code"); - if (!string.IsNullOrEmpty(codeBlock.Language)) - { - builder.AddAttribute(3, "data-language", codeBlock.Language); - } - builder.AddContent(4, codeBlock.Code); - builder.CloseElement(); - builder.CloseElement(); - break; - case BlockQuoteNode: - RenderElement(builder, "blockquote", "sc-ai-rich-text__quote", node.Children); - break; - case LineBreakNode: - builder.OpenElement(0, "br"); - builder.CloseElement(); - break; - case ThematicBreakNode: - builder.OpenElement(0, "hr"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__thematic-break"); - builder.CloseElement(); - break; - case ListNode list: - builder.OpenElement(0, list.Ordered ? "ol" : "ul"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__list"); - if (list.Ordered && list.Start is not null) - { - builder.AddAttribute(2, "start", list.Start.Value); - } - RenderRichTextNodes(builder, list.Children); - builder.CloseElement(); - break; - case ListItemNode item: - builder.OpenElement(0, "li"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__list-item"); - if (item.Checked is not null) - { - builder.OpenElement(2, "input"); - builder.AddAttribute(3, "type", "checkbox"); - builder.AddAttribute(4, "disabled", true); - if (item.Checked.Value) - { - builder.AddAttribute(5, "checked", true); - } - builder.CloseElement(); - } - RenderRichTextNodes(builder, item.Children); - builder.CloseElement(); - break; - case LinkNode link: - RenderLink(builder, link); - break; - case ImageNode image: - RenderImage(builder, image); - break; - case DefinitionNode definition: - builder.OpenElement(0, "span"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__definition"); - builder.AddContent(2, $"[{definition.Label}]: {definition.Url}"); - builder.CloseElement(); - break; - case LinkReferenceNode linkReference: - RenderReference(builder, linkReference.Label, linkReference.Children); - break; - case ImageReferenceNode imageReference: - builder.OpenElement(0, "span"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__image-reference"); - builder.AddContent(2, imageReference.Alt ?? imageReference.Label); - builder.CloseElement(); - break; - case FootnoteNode: - RenderElement(builder, "aside", "sc-ai-rich-text__footnote", node.Children); - break; - case FootnoteReferenceNode footnoteReference: - builder.OpenElement(0, "sup"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__footnote-reference"); - builder.AddContent(2, footnoteReference.Label); - builder.CloseElement(); - break; - case FootnoteDefinitionNode footnoteDefinition: - builder.OpenElement(0, "aside"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__footnote-definition"); - builder.AddAttribute(2, "data-label", footnoteDefinition.Label); - RenderRichTextNodes(builder, footnoteDefinition.Children); - builder.CloseElement(); - break; - case HtmlNode html: - builder.OpenElement(0, "code"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__html"); - builder.AddContent(2, html.Value); - builder.CloseElement(); - break; - case TableNode table: - RenderTable(builder, table); - break; - case TableRowNode: - case TableCellNode: - RenderRichTextNodes(builder, node.Children); - break; - default: - RenderRichTextNodes(builder, node.Children); - break; - } - } - - private static void RenderElement( - RenderTreeBuilder builder, - string elementName, - string? className, - IReadOnlyList children) - { - builder.OpenElement(0, elementName); - if (className is not null) - { - builder.AddAttribute(1, "class", className); - } - RenderRichTextNodes(builder, children); - builder.CloseElement(); - } - - private static void RenderLink(RenderTreeBuilder builder, LinkNode link) - { - var safeUrl = GetSafeUrl(link.Url, allowMailTo: true); - if (safeUrl is null) - { - RenderRichTextNodes(builder, link.Children); - return; - } - - builder.OpenElement(0, "a"); - builder.AddAttribute(1, "href", safeUrl); - if (link.Title is not null) - { - builder.AddAttribute(2, "title", link.Title); - } - RenderRichTextNodes(builder, link.Children); - builder.CloseElement(); - } - - private static void RenderImage(RenderTreeBuilder builder, ImageNode image) - { - var safeUrl = GetSafeUrl(image.Url, allowMailTo: false); - if (safeUrl is null) - { - builder.AddContent(0, image.Alt); - return; - } - - builder.OpenElement(0, "img"); - builder.AddAttribute(1, "src", safeUrl); - builder.AddAttribute(2, "alt", image.Alt ?? string.Empty); - if (image.Title is not null) - { - builder.AddAttribute(3, "title", image.Title); - } - builder.CloseElement(); - } - - private static void RenderReference( - RenderTreeBuilder builder, - string label, - IReadOnlyList children) - { - builder.OpenElement(0, "span"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__link-reference"); - if (children.Count > 0) - { - RenderRichTextNodes(builder, children); - } - else - { - builder.AddContent(2, label); - } - builder.CloseElement(); - } - - private static void RenderTable(RenderTreeBuilder builder, TableNode table) - { - builder.OpenElement(0, "div"); - builder.AddAttribute(1, "class", "sc-ai-rich-text__table-container"); - builder.OpenElement(2, "table"); - builder.AddAttribute(3, "class", "sc-ai-rich-text__table"); - builder.OpenElement(4, "tbody"); - - foreach (var child in table.Children) - { - if (child is not TableRowNode row) - { - continue; - } - - builder.OpenRegion(5); - builder.OpenElement(0, "tr"); - var columnIndex = 0; - foreach (var rowChild in row.Children) - { - if (rowChild is not TableCellNode cell) - { - continue; - } - - builder.OpenRegion(1); - builder.OpenElement(0, "td"); - if (columnIndex < table.Alignment.Count && - table.Alignment[columnIndex] != TableColumnAlignment.None) - { - builder.AddAttribute( - 1, - "class", - $"sc-ai-rich-text__table-cell--{table.Alignment[columnIndex].ToString().ToLowerInvariant()}"); - } - RenderRichTextNodes(builder, cell.Children); - builder.CloseElement(); - builder.CloseRegion(); - columnIndex++; - } - builder.CloseElement(); - builder.CloseRegion(); - } - - builder.CloseElement(); - builder.CloseElement(); - builder.CloseElement(); - } - - private static string? GetSafeUrl(string url, bool allowMailTo) - { - if (!Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out var uri)) - { - return null; - } - - if (!uri.IsAbsoluteUri) - { - return url; - } - - if (uri.Scheme is "http" or "https" || - (allowMailTo && uri.Scheme == "mailto")) - { - return url; - } - - return null; - } - - private static void RenderApprovalBlock( - RenderTreeBuilder builder, - FunctionApprovalBlock block) - { - builder.OpenElement(0, "div"); - builder.AddAttribute(1, "class", "sc-ai-approval"); - - builder.OpenElement(2, "div"); - builder.AddAttribute(3, "class", "sc-ai-approval__header"); - builder.AddContent(4, "Approval required"); - builder.CloseElement(); - - builder.OpenElement(5, "div"); - builder.AddAttribute(6, "class", "sc-ai-approval__tool-name"); - builder.AddContent(7, block.ToolName ?? "Unknown tool"); - builder.CloseElement(); - - if (block.Arguments is { Count: > 0 }) - { - builder.OpenElement(8, "pre"); - builder.AddAttribute(9, "class", "sc-ai-approval__arguments"); - builder.AddContent(10, JsonSerializer.Serialize(block.Arguments, IndentedJsonOptions)); - builder.CloseElement(); - } - - if (block.Status == ApprovalStatus.Pending) - { - builder.OpenElement(11, "div"); - builder.AddAttribute(12, "class", "sc-ai-approval__actions"); - - builder.OpenElement(13, "button"); - builder.AddAttribute(14, "type", "button"); - builder.AddAttribute(15, "class", "sc-ai-btn sc-ai-btn--primary"); - builder.AddAttribute(16, "onclick", (Action)block.Approve); - builder.AddContent(17, "Approve"); - builder.CloseElement(); - - builder.OpenElement(18, "button"); - builder.AddAttribute(19, "type", "button"); - builder.AddAttribute(20, "class", "sc-ai-btn sc-ai-btn--secondary"); - builder.AddAttribute(21, "onclick", (Action)(() => block.Reject())); - builder.AddContent(22, "Reject"); - builder.CloseElement(); - - builder.CloseElement(); - } - else - { - var approved = block.Status == ApprovalStatus.Approved; - builder.OpenElement(23, "div"); - builder.AddAttribute( - 24, - "class", - approved - ? "sc-ai-approval__status sc-ai-approval__status--approved" - : "sc-ai-approval__status sc-ai-approval__status--rejected"); - builder.AddContent(25, approved ? "Approved" : "Rejected"); - builder.CloseElement(); - } - - builder.CloseElement(); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentState.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentState.cs deleted file mode 100644 index 294bd42fbe1f..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentState.cs +++ /dev/null @@ -1,120 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Holds observable state associated with a . -/// -/// The type of state. -public class AgentState where T : class, new() -{ - private readonly List _callbacks = new(); - private T _value; - private T? _valueBeforePrediction; - - internal AgentState(T? initialValue = null) - { - _value = initialValue ?? new T(); - } - - /// - /// Gets or sets the current state value. - /// - public T Value - { - get => _value; - set - { - ArgumentNullException.ThrowIfNull(value); - _valueBeforePrediction = null; - _value = value; - NotifyChanged(); - } - } - - /// - /// Gets a value indicating whether contains provisional predictive state. - /// - public bool HasPendingPredictiveState => _valueBeforePrediction is not null; - - /// - /// Accepts the current predictive state as the committed value. - /// - public void AcceptPredictiveState() - { - if (_valueBeforePrediction is null) - { - return; - } - - _valueBeforePrediction = null; - NotifyChanged(); - } - - /// - /// Rejects the current predictive state and restores the value from before the prediction. - /// - public void RejectPredictiveState() - { - if (_valueBeforePrediction is not { } previousValue) - { - return; - } - - _valueBeforePrediction = null; - _value = previousValue; - NotifyChanged(); - } - - /// - /// Registers a callback invoked when changes. - /// - /// The callback to invoke. - /// A registration that removes the callback when disposed. - public IDisposable OnChanged(Action callback) - { - ArgumentNullException.ThrowIfNull(callback); - _callbacks.Add(callback); - return new CallbackRegistration(_callbacks, callback); - } - - internal void SetPredictiveValue(T value) - { - ArgumentNullException.ThrowIfNull(value); - _valueBeforePrediction ??= _value; - _value = value; - NotifyChanged(); - } - - private void NotifyChanged() - { - var snapshot = _callbacks.ToArray(); - foreach (var callback in snapshot) - { - callback(); - } - } - - private sealed class CallbackRegistration : IDisposable - { - private List? _callbacks; - private Action? _callback; - - internal CallbackRegistration(List callbacks, Action callback) - { - _callbacks = callbacks; - _callback = callback; - } - - public void Dispose() - { - if (_callbacks is not null && _callback is not null) - { - _callbacks.Remove(_callback); - _callbacks = null; - _callback = null; - } - } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/IConversationThread.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/IConversationThread.cs deleted file mode 100644 index 87756edd7d84..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/IConversationThread.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a persistent conversation thread that stores streamed chat updates. -/// -/// -/// Implementations control where and how conversation updates are persisted. -/// -public interface IConversationThread -{ - /// - /// Gets the unique identifier for this thread. - /// - string ThreadId { get; } - - /// - /// Gets a value indicating whether the remote service manages the conversation history. - /// - bool IsStateful { get; } - - /// - /// Gets the conversation identifier returned by a stateful remote service, if any. - /// - string? ConversationId { get; } - - /// - /// Begins a turn by appending the message sent to the chat client. - /// - /// The message that begins the turn. - void AppendUserMessage(ChatMessage message); - - /// - /// Appends an update received from the chat client to the current turn. - /// - /// The streamed update. - void AppendUpdate(ChatResponseUpdate update); - - /// - /// Commits the current turn to the stored history. - /// - void CompleteTurn(); - - /// - /// Gets all committed updates in chronological order. - /// - /// The committed updates. - IReadOnlyList GetUpdates(); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentOfT.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentOfT.cs deleted file mode 100644 index 5f10a5b1548a..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentOfT.cs +++ /dev/null @@ -1,122 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Turns an stream into renderable content blocks and typed observable state. -/// -/// The type of state associated with the agent. -public class UIAgent : UIAgent where TState : class, new() -{ - /// - /// Initializes a new instance of the class. - /// - /// The chat client that produces model responses. - /// The initial state value. - public UIAgent(IChatClient chatClient, TState? initialState = null) - : this(chatClient, new UIAgentOptions(initialState), configure: null, loggerFactory: null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The chat client that produces model responses. - /// The options passed to the chat client. - /// The initial state value. - public UIAgent(IChatClient chatClient, ChatOptions chatOptions, TState? initialState = null) - : this( - chatClient, - new UIAgentOptions(initialState), - options => options.ChatOptions = chatOptions, - loggerFactory: null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The chat client that produces model responses. - /// A callback that configures the agent. - /// The initial state value. - public UIAgent( - IChatClient chatClient, - Action> configure, - TState? initialState = null) - : this(chatClient, new UIAgentOptions(initialState), configure, loggerFactory: null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The chat client that produces model responses. - /// A callback that configures the agent. - /// The logger factory used to trace block mapping. - /// The initial state value. - public UIAgent( - IChatClient chatClient, - Action> configure, - ILoggerFactory? loggerFactory, - TState? initialState = null) - : this(chatClient, new UIAgentOptions(initialState), configure, loggerFactory) - { - } - - private UIAgent( - IChatClient chatClient, - UIAgentOptions options, - Action>? configure, - ILoggerFactory? loggerFactory) - : base(chatClient, options, loggerFactory) - { - State = options.State; - configure?.Invoke(options); - } - - /// - /// Gets the observable state associated with this agent. - /// - public AgentState State { get; } - - internal override ChatResponseUpdate ApplyStateMapper(ChatResponseUpdate update) - { - if (Options.StateMapper is null) - { - return update; - } - - var context = new StateMapperContext(update); - Options.StateMapper(context); - - if (context.StateValue is not null) - { - if (context.StateValue is not TState typedState) - { - throw new InvalidOperationException( - $"The state mapper returned a value of type '{context.StateValue.GetType()}', " + - $"but this agent requires state of type '{typeof(TState)}'."); - } - - if (context.IsPredictiveState) - { - State.SetPredictiveValue(typedState); - } - else - { - State.Value = typedState; - } - } - - return context.HasHandledContent ? context.GetFilteredUpdate() : update; - } - - internal override void RejectPendingPredictiveState() - { - State.RejectPredictiveState(); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj deleted file mode 100644 index 06236046177b..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj +++ /dev/null @@ -1,45 +0,0 @@ - - - - $(DefaultNetCoreTargetFramework) - 0.1.0 - - $(AspNetCoreMajorMinorVersion).0.0 - enable - enable - true - true - true - Blazor component library for building AI conversational UIs on top of Microsoft.Extensions.AI. - blazor;ai;chat;components - - $(NoWarn);RS0026 - true - preview - 1 - - - - - - - - - - - - - - - - - - - - - diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ActivityHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ActivityHandler.cs deleted file mode 100644 index dd9488839c26..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ActivityHandler.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Maps activity snapshots and updates into a mutable content block. -/// -/// The activity block type. -public abstract class ActivityHandler : ContentBlockHandler - where TBlock : ActivityContentBlock, new() -{ - /// - public sealed override BlockMappingResult Handle( - BlockMappingContext context, - TBlock state) - { - if (state.Id == string.Empty) - { - if (TryCreateBlock(context, state)) - { - if (state.Id.Length == 0) - { - state.Id = context.Update.MessageId ?? Guid.NewGuid().ToString("N"); - } - - OnContentUpdated(state); - return BlockMappingResult.Emit(state, state); - } - - return BlockMappingResult.Pass(); - } - - if (TryUpdateBlock(context, state, out var isCompleted)) - { - OnContentUpdated(state); - return isCompleted - ? BlockMappingResult.Complete() - : BlockMappingResult.Update(state); - } - - return BlockMappingResult.Pass(); - } - - /// - /// Attempts to initialize a block from an activity snapshot. - /// - /// The update being mapped. - /// The block to initialize. - /// when the update created the block. - protected abstract bool TryCreateBlock(BlockMappingContext context, TBlock state); - - /// - /// Attempts to update an existing activity block. - /// - /// The update being mapped. - /// The block to update. - /// Whether the update completes the activity. - /// when the update belongs to the block. - protected abstract bool TryUpdateBlock( - BlockMappingContext context, - TBlock state, - out bool isCompleted); - - /// - /// Updates derived block state after the activity payload changes. - /// - /// The updated activity block. - protected virtual void OnContentUpdated(TBlock state) - { - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingContext.cs deleted file mode 100644 index c2262e228e97..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingContext.cs +++ /dev/null @@ -1,171 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Carries a single model update through the block mapping pipeline and tracks which -/// parts of the update handlers have already claimed. -/// -public class BlockMappingContext -{ - private readonly bool[] _handled; - private readonly IReadOnlyList? _handlers; - private int _handledCount; - private bool _updateHandled; - - internal BlockMappingContext( - ChatResponseUpdate update, - IReadOnlyList? handlers = null) - { - Update = update; - _handled = new bool[update.Contents.Count]; - _handlers = handlers; - } - - /// - /// Gets the update being mapped. - /// - public ChatResponseUpdate Update { get; } - - /// - /// Gets the contents of that no handler has claimed yet. - /// - public UnhandledContentsEnumerable UnhandledContents => new(Update.Contents, _handled); - - /// - /// Marks a content item as claimed so that later handlers do not see it. - /// - /// The content item that was handled. - public void MarkHandled(AIContent content) - { - var contents = Update.Contents; - for (var i = 0; i < contents.Count; i++) - { - if (ReferenceEquals(contents[i], content)) - { - if (!_handled[i]) - { - _handled[i] = true; - _handledCount++; - } - return; - } - } - } - - /// - /// Marks the update itself as handled. Use this for updates that carry no content items. - /// - public void MarkUpdateHandled() - { - _updateHandled = true; - } - - /// - /// Gets a value indicating whether every part of the update has been claimed. - /// - public bool AllHandled => - _handledCount >= Update.Contents.Count && (Update.Contents.Count > 0 || _updateHandled); - - internal int HandledProgress => _handledCount + (_updateHandled ? 1 : 0); - - /// - /// Maps content through the available handlers to create a nested block. - /// - /// The content to map. - /// The mapped block, or when no handler accepts the content. - public ContentBlock? CreateInnerBlock(AIContent content) - { - ArgumentNullException.ThrowIfNull(content); - - if (_handlers is null) - { - return null; - } - - var update = new ChatResponseUpdate - { - Role = Update.Role, - AuthorName = Update.AuthorName, - MessageId = Update.MessageId, - Contents = [content], - }; - var context = new BlockMappingContext(update, _handlers); - - foreach (var handler in _handlers) - { - var entry = handler.TryHandle(context); - if (entry is not null) - { - entry.Block.Role = update.Role; - entry.Block.AuthorName = update.AuthorName; - entry.Block.LifecycleState = BlockLifecycleState.Inactive; - return entry.Block; - } - } - - return null; - } - - /// - /// Enumerates the content items of an update that have not been claimed by a handler. - /// - public readonly struct UnhandledContentsEnumerable - { - private readonly IList _contents; - private readonly bool[] _handled; - - internal UnhandledContentsEnumerable(IList contents, bool[] handled) - { - _contents = contents; - _handled = handled; - } - - /// - /// Returns an enumerator over the unclaimed content items. - /// - /// An enumerator over the unclaimed content items. - public UnhandledContentsEnumerator GetEnumerator() => new(_contents, _handled); - } - - /// - /// Enumerator over the content items of an update that have not been claimed by a handler. - /// - public struct UnhandledContentsEnumerator - { - private readonly IList _contents; - private readonly bool[] _handled; - private int _index; - - internal UnhandledContentsEnumerator(IList contents, bool[] handled) - { - _contents = contents; - _handled = handled; - _index = -1; - } - - /// - /// Gets the content item at the current position. - /// - public AIContent Current => _contents[_index]; - - /// - /// Advances to the next unclaimed content item. - /// - /// if another unclaimed item exists; otherwise . - public bool MoveNext() - { - while (++_index < _contents.Count) - { - if (!_handled[_index]) - { - return true; - } - } - return false; - } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs deleted file mode 100644 index a526003ac207..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Components.AI; - -internal static partial class BlockMappingPipelineLog -{ - [LoggerMessage(1, LogLevel.Debug, "Processing update: Role={Role}, ContentCount={ContentCount}, ContentTypes=[{ContentTypes}]")] - internal static partial void ProcessingUpdate(ILogger logger, string? role, int contentCount, string contentTypes); - - [LoggerMessage(2, LogLevel.Debug, "Active handler {HandlerType} returned {ResultKind} for block {BlockId}")] - internal static partial void ActiveHandlerResult(ILogger logger, string handlerType, string resultKind, string? blockId); - - [LoggerMessage(3, LogLevel.Information, "Emitting new block: {BlockType} Id={BlockId} Role={Role}")] - internal static partial void EmittingBlock(ILogger logger, string blockType, string? blockId, string? role); - - [LoggerMessage(4, LogLevel.Debug, "Phase 2: Trying inactive handler {HandlerType} to claim remaining content")] - internal static partial void TryingInactiveHandler(ILogger logger, string handlerType); - - [LoggerMessage(5, LogLevel.Debug, "Finalize: Deactivating {ActiveCount} active blocks")] - internal static partial void Finalizing(ILogger logger, int activeCount); - - [LoggerMessage(6, LogLevel.Debug, "All content handled after active handlers, skipping Phase 2")] - internal static partial void AllContentHandledAfterPhase1(ILogger logger); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingResult.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingResult.cs deleted file mode 100644 index 4d02957ef03b..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingResult.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// The outcome of a invocation. -/// -/// The state the handler keeps across updates. -public readonly struct BlockMappingResult -{ - internal enum ResultKind { Pass, Emit, Update, Complete } - - internal ResultKind Kind { get; } - - internal ContentBlock? Block { get; } - - internal TState? State { get; } - - private BlockMappingResult(ResultKind kind, ContentBlock? block, TState? state) - { - Kind = kind; - Block = block; - State = state; - } - - /// - /// Indicates that the handler did not claim anything from the update. - /// - /// A result that leaves the update for other handlers. - public static BlockMappingResult Pass() => new(ResultKind.Pass, null, default); - - /// - /// Indicates that the handler produced a new block for the conversation. - /// - /// The block to add to the conversation. - /// The state to carry into subsequent updates. - /// A result that emits . - public static BlockMappingResult Emit(ContentBlock block, TState state) - { - ArgumentNullException.ThrowIfNull(block); - return new(ResultKind.Emit, block, state); - } - - /// - /// Indicates that the handler updated the block it previously emitted. - /// - /// The updated state. - /// A result that notifies the UI that the block changed. - public static BlockMappingResult Update(TState state) => new(ResultKind.Update, null, state); - - /// - /// Indicates that the block the handler emitted is complete. - /// - /// A result that deactivates the block. - public static BlockMappingResult Complete() => new(ResultKind.Complete, null, default); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ContentBlockHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ContentBlockHandler.cs deleted file mode 100644 index 514980c728b3..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/ContentBlockHandler.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Maps model updates into content blocks. A handler is invoked for every update until it -/// completes the block it emitted. -/// -/// The state the handler keeps across updates for a single block. -/// -/// -/// internal sealed class EchoHandler : ContentBlockHandler<RichContentBlock> -/// { -/// public override BlockMappingResult<RichContentBlock> Handle( -/// BlockMappingContext context, RichContentBlock state) -/// => BlockMappingResult<RichContentBlock>.Pass(); -/// } -/// -/// -public abstract class ContentBlockHandler where TState : new() -{ - /// - /// Handles an update. - /// - /// The update being mapped. - /// The state for the block this handler owns. - /// The outcome of the invocation. - public abstract BlockMappingResult Handle(BlockMappingContext context, TState state); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs deleted file mode 100644 index d5ff5164a434..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -internal sealed class FunctionApprovalHandler : - ContentBlockHandler -{ - public override BlockMappingResult Handle(BlockMappingContext context, State state) - { - if (state.Emitted) - { - return BlockMappingResult.Complete(); - } - - foreach (var content in context.UnhandledContents) - { - if (content is not ToolApprovalRequestContent approvalRequest) - { - continue; - } - - context.MarkHandled(approvalRequest); - - var innerBlock = context.CreateInnerBlock(approvalRequest.ToolCall) - ?? CreateFallbackInnerBlock(approvalRequest.ToolCall); - - state.Emitted = true; - return BlockMappingResult.Emit( - new FunctionApprovalBlock(innerBlock, approvalRequest) - { - Id = approvalRequest.ToolCall is FunctionCallContent functionCall - ? functionCall.CallId ?? approvalRequest.RequestId - : approvalRequest.RequestId - }, - state); - } - - return BlockMappingResult.Pass(); - } - - private static FunctionInvocationContentBlock CreateFallbackInnerBlock( - ToolCallContent toolCall) - { - var block = new FunctionInvocationContentBlock(); - if (toolCall is FunctionCallContent functionCall) - { - block.Call = functionCall; - } - - return block; - } - - internal sealed class State - { - internal bool Emitted { get; set; } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs deleted file mode 100644 index 367fd0063a1b..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -internal sealed class FunctionInvocationHandler : ContentBlockHandler -{ - public override BlockMappingResult Handle( - BlockMappingContext context, - FunctionInvocationContentBlock state) - { - if (state.Result is not null) - { - return BlockMappingResult.Complete(); - } - - var shouldEmit = false; - if (state.Call is null) - { - foreach (var content in context.UnhandledContents) - { - if (content is FunctionCallContent call) - { - context.MarkHandled(call); - state.Call = call; - shouldEmit = true; - break; - } - } - } - - if (state.Call is not null) - { - foreach (var content in context.UnhandledContents) - { - if (content is FunctionResultContent result && - result.CallId == state.Call.CallId) - { - context.MarkHandled(result); - state.Result = result; - return shouldEmit - ? BlockMappingResult.Emit(state, state) - : BlockMappingResult.Complete(); - } - } - } - - return shouldEmit - ? BlockMappingResult.Emit(state, state) - : BlockMappingResult.Pass(); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandleResult.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandleResult.cs deleted file mode 100644 index c48b3795f68b..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandleResult.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -internal readonly struct HandleResult -{ - internal enum ResultKind { Pass, Update, Complete } - - internal ResultKind Kind { get; } - - private HandleResult(ResultKind kind) - { - Kind = kind; - } - - internal static HandleResult Pass() => new(ResultKind.Pass); - - internal static HandleResult Update() => new(ResultKind.Update); - - internal static HandleResult Complete() => new(ResultKind.Complete); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandlerEntry.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandlerEntry.cs deleted file mode 100644 index 9b2fd5764871..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/HandlerEntry.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -internal sealed class HandlerEntry : IHandlerEntry where TState : new() -{ - private readonly ContentBlockHandler _handler; - - internal HandlerEntry(ContentBlockHandler handler) - { - _handler = handler; - } - - public IActiveEntry? TryHandle(BlockMappingContext context) - { - var state = new TState(); - var result = _handler.Handle(context, state); - if (result.Kind == BlockMappingResult.ResultKind.Emit) - { - return new ActiveEntry(_handler, result.State!, result.Block!); - } - - return null; - } - - private sealed class ActiveEntry : IActiveEntry - { - private readonly ContentBlockHandler _handler; - private TState _state; - - internal ActiveEntry( - ContentBlockHandler handler, - TState state, - ContentBlock block) - { - _handler = handler; - _state = state; - Block = block; - } - - public ContentBlock Block { get; } - - public HandleResult Invoke(BlockMappingContext context) - { - var result = _handler.Handle(context, _state); - switch (result.Kind) - { - case BlockMappingResult.ResultKind.Update: - _state = result.State!; - return HandleResult.Update(); - - case BlockMappingResult.ResultKind.Complete: - return HandleResult.Complete(); - - default: - return HandleResult.Pass(); - } - } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IActiveEntry.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IActiveEntry.cs deleted file mode 100644 index 555f43c83993..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IActiveEntry.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -internal interface IActiveEntry -{ - ContentBlock Block { get; } - - HandleResult Invoke(BlockMappingContext context); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IHandlerEntry.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IHandlerEntry.cs deleted file mode 100644 index 89d58b292ee8..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/IHandlerEntry.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -internal interface IHandlerEntry -{ - IActiveEntry? TryHandle(BlockMappingContext context); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/RichTextContentHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/RichTextContentHandler.cs deleted file mode 100644 index acad1a443a7e..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/RichTextContentHandler.cs +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -internal sealed class RichTextContentHandler : ContentBlockHandler -{ - public override BlockMappingResult Handle( - BlockMappingContext context, RichContentBlock state) - { - RichTextContent? snapshot = null; - foreach (var content in context.UnhandledContents) - { - if (content is RichTextContent richText) - { - snapshot = richText; - } - } - - if (snapshot is null) - { - return state.Id.Length > 0 - ? BlockMappingResult.Complete() - : BlockMappingResult.Pass(); - } - - if (state.Id.Length > 0 && - context.Update.MessageId is { Length: > 0 } messageId && - !string.Equals(state.Id, messageId, StringComparison.Ordinal)) - { - return BlockMappingResult.Complete(); - } - - foreach (var content in context.UnhandledContents) - { - if (content is RichTextContent or TextContent) - { - context.MarkHandled(content); - } - } - - state.ReplaceContent(snapshot.Text, snapshot.Nodes); - - if (state.Id.Length == 0) - { - state.Id = context.Update.MessageId ?? Guid.NewGuid().ToString("N"); - return BlockMappingResult.Emit(state, state); - } - - return BlockMappingResult.Update(state); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/StateMapperContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/StateMapperContext.cs deleted file mode 100644 index fb1cce621d74..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/StateMapperContext.cs +++ /dev/null @@ -1,131 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Carries a model update through typed state mapping and tracks content consumed as state. -/// -public class StateMapperContext -{ - private readonly bool[] _handled; - private int _handledCount; - - internal StateMapperContext(ChatResponseUpdate update) - { - Update = update; - _handled = new bool[update.Contents.Count]; - } - - /// - /// Gets the update being mapped. - /// - public ChatResponseUpdate Update { get; } - - /// - /// Gets content items that have not been consumed by the state mapper. - /// - public IEnumerable UnhandledContents - { - get - { - var contents = Update.Contents; - for (var i = 0; i < contents.Count; i++) - { - if (!_handled[i]) - { - yield return contents[i]; - } - } - } - } - - /// - /// Marks a content item as consumed by the state mapper. - /// - /// The content item that was handled. - public void MarkHandled(AIContent content) - { - ArgumentNullException.ThrowIfNull(content); - - var contents = Update.Contents; - for (var i = 0; i < contents.Count; i++) - { - if (ReferenceEquals(contents[i], content)) - { - if (!_handled[i]) - { - _handled[i] = true; - _handledCount++; - } - - return; - } - } - } - - internal object? StateValue { get; private set; } - - internal bool IsPredictiveState { get; private set; } - - /// - /// Sets the next typed state value. - /// - /// The next state value. - public void SetState(object value) - { - ArgumentNullException.ThrowIfNull(value); - StateValue = value; - IsPredictiveState = false; - } - - /// - /// Sets a provisional typed state value that must be accepted or rejected before the turn - /// completes. - /// - /// The next provisional state value. - public void SetPredictiveState(object value) - { - ArgumentNullException.ThrowIfNull(value); - StateValue = value; - IsPredictiveState = true; - } - - internal bool HasHandledContent => _handledCount > 0; - - internal ChatResponseUpdate GetFilteredUpdate() - { - if (_handledCount == 0) - { - return Update; - } - - var filtered = new List(); - var contents = Update.Contents; - for (var i = 0; i < contents.Count; i++) - { - if (!_handled[i]) - { - filtered.Add(contents[i]); - } - } - - return new ChatResponseUpdate - { - Role = Update.Role, - AuthorName = Update.AuthorName, - MessageId = Update.MessageId, - ResponseId = Update.ResponseId, - ConversationId = Update.ConversationId, - CreatedAt = Update.CreatedAt, - FinishReason = Update.FinishReason, - ModelId = Update.ModelId, - ContinuationToken = Update.ContinuationToken, - RawRepresentation = Update.RawRepresentation, - AdditionalProperties = Update.AdditionalProperties, - Contents = filtered, - }; - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/TextBlockHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/TextBlockHandler.cs deleted file mode 100644 index b8b5c04113f8..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/TextBlockHandler.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -// Fallback handler: claims TextContent and accumulates it into a single block for the -// duration of a model message. It runs last so more specific handlers get first refusal. -internal sealed class TextBlockHandler : ContentBlockHandler -{ - public override BlockMappingResult Handle( - BlockMappingContext context, RichContentBlock state) - { - TextContent? textContent = null; - foreach (var content in context.UnhandledContents) - { - if (content is TextContent tc) - { - textContent = tc; - break; - } - } - - if (textContent is null) - { - if (state.Id != string.Empty) - { - return BlockMappingResult.Complete(); - } - - return BlockMappingResult.Pass(); - } - - context.MarkHandled(textContent); - state.AppendText(textContent.Text ?? string.Empty); - RebuildParagraphs(state); - - if (state.Id == string.Empty) - { - state.Id = context.Update.MessageId ?? Guid.NewGuid().ToString("N"); - return BlockMappingResult.Emit(state, state); - } - - return BlockMappingResult.Update(state); - } - - internal static void RebuildParagraphs(RichContentBlock state) - { - var rawText = state.RawText; - if (rawText.Length == 0) - { - state.Content = Array.Empty(); - return; - } - - var paragraphs = new List(); - var start = 0; - while (start < rawText.Length) - { - var breakIndex = rawText.IndexOf("\n\n", start, StringComparison.Ordinal); - if (breakIndex < 0) - { - AddParagraph(paragraphs, rawText.AsSpan(start)); - break; - } - - if (breakIndex > start) - { - AddParagraph(paragraphs, rawText.AsSpan(start, breakIndex - start)); - } - - start = breakIndex + 2; - } - - state.Content = paragraphs; - } - - private static void AddParagraph(List paragraphs, ReadOnlySpan text) - { - var trimmed = text.TrimEnd("\r\n".AsSpan()); - if (trimmed.Length == 0) - { - return; - } - - var paragraph = new ParagraphNode(); - paragraph.AddChild(new TextNode(trimmed.ToString())); - paragraphs.Add(paragraph); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIActionHandler.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIActionHandler.cs deleted file mode 100644 index f1c2ee27c9fe..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIActionHandler.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -internal sealed class UIActionHandler : ContentBlockHandler -{ - private readonly IReadOnlyDictionary _actions; - - internal UIActionHandler(IReadOnlyDictionary actions) - { - _actions = actions; - } - - public override BlockMappingResult Handle(BlockMappingContext context, State state) - { - if (state.HasEmitted) - { - return BlockMappingResult.Pass(); - } - - foreach (var content in context.UnhandledContents) - { - if (content is FunctionCallContent call && - !call.InformationalOnly && - _actions.TryGetValue(call.Name, out var function)) - { - context.MarkHandled(call); - state.HasEmitted = true; - return BlockMappingResult.Emit( - new UIActionBlock(function, call) - { - Id = call.CallId ?? Guid.NewGuid().ToString("N") - }, - state); - } - } - - return BlockMappingResult.Pass(); - } - - internal sealed class State - { - public bool HasEmitted { get; set; } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIAgentOptions.cs b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIAgentOptions.cs deleted file mode 100644 index 546e27e5e4ed..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/UIAgentOptions.cs +++ /dev/null @@ -1,104 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Configures a . -/// -/// -/// -/// var agent = new UIAgent(chatClient, options => -/// { -/// options.ChatOptions = new ChatOptions { Instructions = "You are a helpful assistant." }; -/// }); -/// -/// -public class UIAgentOptions -{ - /// - /// Gets or sets the options passed to the underlying . - /// - public ChatOptions? ChatOptions { get; set; } - - /// - /// Gets or sets a callback that maps model updates into typed agent state. - /// - public Action? StateMapper { get; set; } - - /// - /// Gets or sets the persistent conversation thread that receives completed turns. - /// - public IConversationThread? Thread { get; set; } - - internal List HandlerRegistrations { get; } = new(); - - internal Dictionary UIActions { get; } = - new(StringComparer.Ordinal); - - /// - /// Registers a handler that maps model updates into content blocks. Registered handlers - /// run before the built-in ones, so they can claim content the built-in handlers would - /// otherwise map. - /// - /// The state the handler keeps across updates. - /// The handler to register. - public void AddBlockHandler(ContentBlockHandler handler) - where TState : new() - { - ArgumentNullException.ThrowIfNull(handler); - HandlerRegistrations.Add(new HandlerRegistration(handler)); - } - - /// - /// Registers a function that a matching model tool call executes in the UI. - /// The function is sent to the chat client as a declaration, not as an executable server tool. - /// - /// - /// The function to execute in the UI. Its name must be unique among the registered UI actions. - /// - /// - /// An action with the same name is already registered. - /// - public void RegisterUIAction(AIFunction function) - { - ArgumentNullException.ThrowIfNull(function); - UIActions.Add(function.Name, function); - } - - internal interface IHandlerRegistration - { - IHandlerEntry CreateEntry(); - } - - private sealed class HandlerRegistration : IHandlerRegistration where TState : new() - { - private readonly ContentBlockHandler _handler; - - internal HandlerRegistration(ContentBlockHandler handler) - { - _handler = handler; - } - - public IHandlerEntry CreateEntry() => new HandlerEntry(_handler); - } -} - -/// -/// Configures a . -/// -/// The type of state associated with the agent. -public sealed class UIAgentOptions : UIAgentOptions where TState : class, new() -{ - internal UIAgentOptions(TState? initialState) - { - State = new AgentState(initialState); - } - - /// - /// Gets the observable state associated with the agent. - /// - public AgentState State { get; } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Shipped.txt b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Shipped.txt deleted file mode 100644 index 7dc5c58110bf..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Shipped.txt +++ /dev/null @@ -1 +0,0 @@ -#nullable enable diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Unshipped.txt b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Unshipped.txt deleted file mode 100644 index 2241a1e6ba68..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/PublicAPI.Unshipped.txt +++ /dev/null @@ -1,360 +0,0 @@ -#nullable enable -Microsoft.AspNetCore.Components.AI.AgentBoundary -Microsoft.AspNetCore.Components.AI.AgentBoundary.Agent.get -> Microsoft.AspNetCore.Components.AI.UIAgent! -Microsoft.AspNetCore.Components.AI.AgentBoundary.Agent.set -> void -Microsoft.AspNetCore.Components.AI.AgentBoundary.AgentBoundary() -> void -Microsoft.AspNetCore.Components.AI.AgentBoundary.ChildContent.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.AgentBoundary.ChildContent.set -> void -Microsoft.AspNetCore.Components.AI.AgentBoundary.Dispose() -> void -Microsoft.AspNetCore.Components.AI.AgentState -Microsoft.AspNetCore.Components.AI.AgentState.AcceptPredictiveState() -> void -Microsoft.AspNetCore.Components.AI.AgentState.HasPendingPredictiveState.get -> bool -Microsoft.AspNetCore.Components.AI.AgentState.OnChanged(System.Action! callback) -> System.IDisposable! -Microsoft.AspNetCore.Components.AI.AgentState.RejectPredictiveState() -> void -Microsoft.AspNetCore.Components.AI.AgentState.Value.get -> T! -Microsoft.AspNetCore.Components.AI.AgentState.Value.set -> void -Microsoft.AspNetCore.Components.AI.AgentContext -Microsoft.AspNetCore.Components.AI.AgentContext.AgentContext(Microsoft.AspNetCore.Components.AI.UIAgent! agent) -> void -Microsoft.AspNetCore.Components.AI.AgentContext.CancelAsync() -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.AgentContext.Dispose() -> void -Microsoft.AspNetCore.Components.AI.AgentContext.Error.get -> System.Exception? -Microsoft.AspNetCore.Components.AI.AgentContext.RegisterOnBlockAdded(System.Action! callback) -> System.IDisposable! -Microsoft.AspNetCore.Components.AI.AgentContext.RegisterOnStatusChanged(System.Action! callback) -> System.IDisposable! -Microsoft.AspNetCore.Components.AI.AgentContext.RegisterOnTurnAdded(System.Action! callback) -> System.IDisposable! -Microsoft.AspNetCore.Components.AI.AgentContext.RetryAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.AgentContext.RestoreAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.AgentContext.SendMessageAsync(Microsoft.Extensions.AI.ChatMessage! message, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.AgentContext.SendMessageAsync(string! text, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.AgentContext.Status.get -> Microsoft.AspNetCore.Components.AI.ConversationStatus -Microsoft.AspNetCore.Components.AI.AgentContext.Turns.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.ApprovalStatus -Microsoft.AspNetCore.Components.AI.ApprovalStatus.Approved = 1 -> Microsoft.AspNetCore.Components.AI.ApprovalStatus -Microsoft.AspNetCore.Components.AI.ApprovalStatus.Pending = 0 -> Microsoft.AspNetCore.Components.AI.ApprovalStatus -Microsoft.AspNetCore.Components.AI.ApprovalStatus.Rejected = 2 -> Microsoft.AspNetCore.Components.AI.ApprovalStatus -Microsoft.AspNetCore.Components.AI.ActivityContentBlock -Microsoft.AspNetCore.Components.AI.ActivityContentBlock.ActivityContentBlock() -> void -Microsoft.AspNetCore.Components.AI.ActivityContentBlock.ActivityType.get -> string! -Microsoft.AspNetCore.Components.AI.ActivityContentBlock.ActivityType.set -> void -Microsoft.AspNetCore.Components.AI.ActivityContentBlock.Content.get -> System.Text.Json.JsonElement -Microsoft.AspNetCore.Components.AI.ActivityContentBlock.Content.set -> void -Microsoft.AspNetCore.Components.AI.ActivityHandler -Microsoft.AspNetCore.Components.AI.ActivityHandler.ActivityHandler() -> void -Microsoft.AspNetCore.Components.AI.BlockLifecycleState -Microsoft.AspNetCore.Components.AI.BlockLifecycleState.Active = 1 -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState -Microsoft.AspNetCore.Components.AI.BlockLifecycleState.Inactive = 2 -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState -Microsoft.AspNetCore.Components.AI.BlockLifecycleState.Pending = 0 -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState -Microsoft.AspNetCore.Components.AI.BlockMappingContext -Microsoft.AspNetCore.Components.AI.BlockMappingContext.AllHandled.get -> bool -Microsoft.AspNetCore.Components.AI.BlockMappingContext.CreateInnerBlock(Microsoft.Extensions.AI.AIContent! content) -> Microsoft.AspNetCore.Components.AI.ContentBlock? -Microsoft.AspNetCore.Components.AI.BlockMappingContext.MarkHandled(Microsoft.Extensions.AI.AIContent! content) -> void -Microsoft.AspNetCore.Components.AI.BlockMappingContext.MarkUpdateHandled() -> void -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContents.get -> Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable.GetEnumerator() -> Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerable.UnhandledContentsEnumerable() -> void -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator.Current.get -> Microsoft.Extensions.AI.AIContent! -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator.MoveNext() -> bool -Microsoft.AspNetCore.Components.AI.BlockMappingContext.UnhandledContentsEnumerator.UnhandledContentsEnumerator() -> void -Microsoft.AspNetCore.Components.AI.BlockMappingContext.Update.get -> Microsoft.Extensions.AI.ChatResponseUpdate! -Microsoft.AspNetCore.Components.AI.BlockMappingResult -Microsoft.AspNetCore.Components.AI.BlockMappingResult.BlockMappingResult() -> void -Microsoft.AspNetCore.Components.AI.BlockQuoteNode -Microsoft.AspNetCore.Components.AI.BlockQuoteNode.BlockQuoteNode() -> void -Microsoft.AspNetCore.Components.AI.BlockRenderer -Microsoft.AspNetCore.Components.AI.BlockRenderer.BlockRenderer() -> void -Microsoft.AspNetCore.Components.AI.BlockRenderer.ChildContent.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.BlockRenderer.ChildContent.set -> void -Microsoft.AspNetCore.Components.AI.BlockRenderer.Dispose() -> void -Microsoft.AspNetCore.Components.AI.BlockRenderer.ListContext.get -> Microsoft.AspNetCore.Components.AI.MessageListContext! -Microsoft.AspNetCore.Components.AI.BlockRenderer.ListContext.set -> void -Microsoft.AspNetCore.Components.AI.BlockRenderer.When.get -> System.Func? -Microsoft.AspNetCore.Components.AI.BlockRenderer.When.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage -Microsoft.AspNetCore.Components.AI.ChatPage.AdditionalAttributes.get -> System.Collections.Generic.Dictionary? -Microsoft.AspNetCore.Components.AI.ChatPage.AdditionalAttributes.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.Agent.get -> Microsoft.AspNetCore.Components.AI.UIAgent! -Microsoft.AspNetCore.Components.AI.ChatPage.Agent.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.ChatPage() -> void -Microsoft.AspNetCore.Components.AI.ChatPage.Header.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.ChatPage.Header.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.InputLeadingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.ChatPage.InputLeadingActions.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.InputTrailingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.ChatPage.InputTrailingActions.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.MessageListContent.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.ChatPage.MessageListContent.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.Placeholder.get -> string? -Microsoft.AspNetCore.Components.AI.ChatPage.Placeholder.set -> void -Microsoft.AspNetCore.Components.AI.ChatPage.WelcomeContent.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.ChatPage.WelcomeContent.set -> void -Microsoft.AspNetCore.Components.AI.CodeBlockNode -Microsoft.AspNetCore.Components.AI.CodeBlockNode.Code.get -> string! -Microsoft.AspNetCore.Components.AI.CodeBlockNode.Code.set -> void -Microsoft.AspNetCore.Components.AI.CodeBlockNode.CodeBlockNode() -> void -Microsoft.AspNetCore.Components.AI.CodeBlockNode.CodeBlockNode(string! code, string? language = null) -> void -Microsoft.AspNetCore.Components.AI.CodeBlockNode.Language.get -> string? -Microsoft.AspNetCore.Components.AI.CodeBlockNode.Language.set -> void -Microsoft.AspNetCore.Components.AI.ContentBlock -Microsoft.AspNetCore.Components.AI.ContentBlock.AuthorName.get -> string? -Microsoft.AspNetCore.Components.AI.ContentBlock.ContentBlock() -> void -Microsoft.AspNetCore.Components.AI.ContentBlock.Id.get -> string! -Microsoft.AspNetCore.Components.AI.ContentBlock.LifecycleState.get -> Microsoft.AspNetCore.Components.AI.BlockLifecycleState -Microsoft.AspNetCore.Components.AI.ContentBlock.NotifyChanged() -> void -Microsoft.AspNetCore.Components.AI.ContentBlock.OnChanged(System.Action! callback) -> Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription -Microsoft.AspNetCore.Components.AI.ContentBlock.Role.get -> Microsoft.Extensions.AI.ChatRole? -Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription -Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription.ContentBlockChangedSubscription() -> void -Microsoft.AspNetCore.Components.AI.ContentBlockChangedSubscription.Dispose() -> void -Microsoft.AspNetCore.Components.AI.ContentBlockHandler -Microsoft.AspNetCore.Components.AI.ContentBlockHandler.ContentBlockHandler() -> void -Microsoft.AspNetCore.Components.AI.ConversationStatus -Microsoft.AspNetCore.Components.AI.ConversationStatus.AwaitingInput = 2 -> Microsoft.AspNetCore.Components.AI.ConversationStatus -Microsoft.AspNetCore.Components.AI.ConversationStatus.Error = 3 -> Microsoft.AspNetCore.Components.AI.ConversationStatus -Microsoft.AspNetCore.Components.AI.ConversationStatus.Idle = 0 -> Microsoft.AspNetCore.Components.AI.ConversationStatus -Microsoft.AspNetCore.Components.AI.ConversationStatus.Streaming = 1 -> Microsoft.AspNetCore.Components.AI.ConversationStatus -Microsoft.AspNetCore.Components.AI.ConversationTurn -Microsoft.AspNetCore.Components.AI.ConversationTurn.ConversationTurn() -> void -Microsoft.AspNetCore.Components.AI.ConversationTurn.Id.get -> string! -Microsoft.AspNetCore.Components.AI.ConversationTurn.RequestBlocks.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.ConversationTurn.ResponseBlocks.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.DefinitionNode -Microsoft.AspNetCore.Components.AI.DefinitionNode.DefinitionNode() -> void -Microsoft.AspNetCore.Components.AI.DefinitionNode.Label.get -> string! -Microsoft.AspNetCore.Components.AI.DefinitionNode.Label.set -> void -Microsoft.AspNetCore.Components.AI.DefinitionNode.Title.get -> string? -Microsoft.AspNetCore.Components.AI.DefinitionNode.Title.set -> void -Microsoft.AspNetCore.Components.AI.DefinitionNode.Url.get -> string! -Microsoft.AspNetCore.Components.AI.DefinitionNode.Url.set -> void -Microsoft.AspNetCore.Components.AI.EmphasisNode -Microsoft.AspNetCore.Components.AI.EmphasisNode.EmphasisNode() -> void -Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode -Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode.FootnoteDefinitionNode() -> void -Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode.Label.get -> string! -Microsoft.AspNetCore.Components.AI.FootnoteDefinitionNode.Label.set -> void -Microsoft.AspNetCore.Components.AI.FootnoteNode -Microsoft.AspNetCore.Components.AI.FootnoteNode.FootnoteNode() -> void -Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode -Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode.FootnoteReferenceNode() -> void -Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode.Label.get -> string! -Microsoft.AspNetCore.Components.AI.FootnoteReferenceNode.Label.set -> void -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Arguments.get -> System.Collections.Generic.IDictionary? -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.ApprovalRequest.get -> Microsoft.Extensions.AI.ToolApprovalRequestContent! -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Approve() -> void -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Call.get -> Microsoft.Extensions.AI.FunctionCallContent? -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.GetResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.HasResult.get -> bool -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.InnerBlock.get -> Microsoft.AspNetCore.Components.AI.ContentBlock! -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Reject(string? reason = null) -> void -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Result.get -> Microsoft.Extensions.AI.FunctionResultContent? -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.Status.get -> Microsoft.AspNetCore.Components.AI.ApprovalStatus -Microsoft.AspNetCore.Components.AI.FunctionApprovalBlock.ToolName.get -> string? -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Arguments.get -> System.Collections.Generic.IDictionary? -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Call.get -> Microsoft.Extensions.AI.FunctionCallContent? -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Call.set -> void -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.FunctionInvocationContentBlock() -> void -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.HasResult.get -> bool -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Result.get -> Microsoft.Extensions.AI.FunctionResultContent? -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.Result.set -> void -Microsoft.AspNetCore.Components.AI.FunctionInvocationContentBlock.ToolName.get -> string? -Microsoft.AspNetCore.Components.AI.HeadingNode -Microsoft.AspNetCore.Components.AI.HeadingNode.HeadingNode() -> void -Microsoft.AspNetCore.Components.AI.HeadingNode.HeadingNode(int level) -> void -Microsoft.AspNetCore.Components.AI.HeadingNode.Level.get -> int -Microsoft.AspNetCore.Components.AI.HeadingNode.Level.set -> void -Microsoft.AspNetCore.Components.AI.HtmlNode -Microsoft.AspNetCore.Components.AI.HtmlNode.HtmlNode() -> void -Microsoft.AspNetCore.Components.AI.HtmlNode.HtmlNode(string! value) -> void -Microsoft.AspNetCore.Components.AI.HtmlNode.Value.get -> string! -Microsoft.AspNetCore.Components.AI.HtmlNode.Value.set -> void -Microsoft.AspNetCore.Components.AI.IInteractiveBlock -Microsoft.AspNetCore.Components.AI.IInteractiveBlock.GetResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.IConversationThread -Microsoft.AspNetCore.Components.AI.IConversationThread.AppendUpdate(Microsoft.Extensions.AI.ChatResponseUpdate! update) -> void -Microsoft.AspNetCore.Components.AI.IConversationThread.AppendUserMessage(Microsoft.Extensions.AI.ChatMessage! message) -> void -Microsoft.AspNetCore.Components.AI.IConversationThread.CompleteTurn() -> void -Microsoft.AspNetCore.Components.AI.IConversationThread.ConversationId.get -> string? -Microsoft.AspNetCore.Components.AI.IConversationThread.GetUpdates() -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.IConversationThread.IsStateful.get -> bool -Microsoft.AspNetCore.Components.AI.IConversationThread.ThreadId.get -> string! -Microsoft.AspNetCore.Components.AI.ImageNode -Microsoft.AspNetCore.Components.AI.ImageNode.Alt.get -> string? -Microsoft.AspNetCore.Components.AI.ImageNode.Alt.set -> void -Microsoft.AspNetCore.Components.AI.ImageNode.ImageNode() -> void -Microsoft.AspNetCore.Components.AI.ImageNode.ImageNode(string! url, string? alt = null, string? title = null) -> void -Microsoft.AspNetCore.Components.AI.ImageNode.Title.get -> string? -Microsoft.AspNetCore.Components.AI.ImageNode.Title.set -> void -Microsoft.AspNetCore.Components.AI.ImageNode.Url.get -> string! -Microsoft.AspNetCore.Components.AI.ImageNode.Url.set -> void -Microsoft.AspNetCore.Components.AI.ImageReferenceNode -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Alt.get -> string? -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Alt.set -> void -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.ImageReferenceNode() -> void -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Label.get -> string! -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.Label.set -> void -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.ReferenceKind.get -> Microsoft.AspNetCore.Components.AI.ReferenceKind -Microsoft.AspNetCore.Components.AI.ImageReferenceNode.ReferenceKind.set -> void -Microsoft.AspNetCore.Components.AI.InlineCodeNode -Microsoft.AspNetCore.Components.AI.InlineCodeNode.Code.get -> string! -Microsoft.AspNetCore.Components.AI.InlineCodeNode.Code.set -> void -Microsoft.AspNetCore.Components.AI.InlineCodeNode.InlineCodeNode() -> void -Microsoft.AspNetCore.Components.AI.InlineCodeNode.InlineCodeNode(string! code) -> void -Microsoft.AspNetCore.Components.AI.LineBreakNode -Microsoft.AspNetCore.Components.AI.LineBreakNode.LineBreakNode() -> void -Microsoft.AspNetCore.Components.AI.LinkNode -Microsoft.AspNetCore.Components.AI.LinkNode.LinkNode() -> void -Microsoft.AspNetCore.Components.AI.LinkNode.LinkNode(string! url, string? title = null) -> void -Microsoft.AspNetCore.Components.AI.LinkNode.Title.get -> string? -Microsoft.AspNetCore.Components.AI.LinkNode.Title.set -> void -Microsoft.AspNetCore.Components.AI.LinkNode.Url.get -> string! -Microsoft.AspNetCore.Components.AI.LinkNode.Url.set -> void -Microsoft.AspNetCore.Components.AI.LinkReferenceNode -Microsoft.AspNetCore.Components.AI.LinkReferenceNode.Label.get -> string! -Microsoft.AspNetCore.Components.AI.LinkReferenceNode.Label.set -> void -Microsoft.AspNetCore.Components.AI.LinkReferenceNode.LinkReferenceNode() -> void -Microsoft.AspNetCore.Components.AI.LinkReferenceNode.ReferenceKind.get -> Microsoft.AspNetCore.Components.AI.ReferenceKind -Microsoft.AspNetCore.Components.AI.LinkReferenceNode.ReferenceKind.set -> void -Microsoft.AspNetCore.Components.AI.ListItemNode -Microsoft.AspNetCore.Components.AI.ListItemNode.Checked.get -> bool? -Microsoft.AspNetCore.Components.AI.ListItemNode.Checked.set -> void -Microsoft.AspNetCore.Components.AI.ListItemNode.ListItemNode() -> void -Microsoft.AspNetCore.Components.AI.ListNode -Microsoft.AspNetCore.Components.AI.ListNode.ListNode() -> void -Microsoft.AspNetCore.Components.AI.ListNode.ListNode(bool ordered, int? start = null) -> void -Microsoft.AspNetCore.Components.AI.ListNode.Ordered.get -> bool -Microsoft.AspNetCore.Components.AI.ListNode.Ordered.set -> void -Microsoft.AspNetCore.Components.AI.ListNode.Start.get -> int? -Microsoft.AspNetCore.Components.AI.ListNode.Start.set -> void -Microsoft.AspNetCore.Components.AI.MessageInput -Microsoft.AspNetCore.Components.AI.MessageInput.AgentContext.get -> Microsoft.AspNetCore.Components.AI.AgentContext! -Microsoft.AspNetCore.Components.AI.MessageInput.AgentContext.set -> void -Microsoft.AspNetCore.Components.AI.MessageInput.Dispose() -> void -Microsoft.AspNetCore.Components.AI.MessageInput.LeadingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.MessageInput.LeadingActions.set -> void -Microsoft.AspNetCore.Components.AI.MessageInput.MessageInput() -> void -Microsoft.AspNetCore.Components.AI.MessageInput.Placeholder.get -> string? -Microsoft.AspNetCore.Components.AI.MessageInput.Placeholder.set -> void -Microsoft.AspNetCore.Components.AI.MessageInput.TrailingActions.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.MessageInput.TrailingActions.set -> void -Microsoft.AspNetCore.Components.AI.MessageList -Microsoft.AspNetCore.Components.AI.MessageList.AgentContext.get -> Microsoft.AspNetCore.Components.AI.AgentContext! -Microsoft.AspNetCore.Components.AI.MessageList.AgentContext.set -> void -Microsoft.AspNetCore.Components.AI.MessageList.ChildContent.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.MessageList.ChildContent.set -> void -Microsoft.AspNetCore.Components.AI.MessageList.Dispose() -> void -Microsoft.AspNetCore.Components.AI.MessageList.EmptyContent.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.MessageList.EmptyContent.set -> void -Microsoft.AspNetCore.Components.AI.MessageList.Footer.get -> Microsoft.AspNetCore.Components.RenderFragment? -Microsoft.AspNetCore.Components.AI.MessageList.Footer.set -> void -Microsoft.AspNetCore.Components.AI.MessageList.MessageList() -> void -Microsoft.AspNetCore.Components.AI.MessageListContext -Microsoft.AspNetCore.Components.AI.MessageListContext.MessageListContext() -> void -Microsoft.AspNetCore.Components.AI.MessageListContext.RenderBlock(Microsoft.AspNetCore.Components.AI.ContentBlock! block) -> Microsoft.AspNetCore.Components.RenderFragment! -Microsoft.AspNetCore.Components.AI.ParagraphNode -Microsoft.AspNetCore.Components.AI.ParagraphNode.ParagraphNode() -> void -Microsoft.AspNetCore.Components.AI.ReferenceKind -Microsoft.AspNetCore.Components.AI.ReferenceKind.Collapsed = 1 -> Microsoft.AspNetCore.Components.AI.ReferenceKind -Microsoft.AspNetCore.Components.AI.ReferenceKind.Full = 2 -> Microsoft.AspNetCore.Components.AI.ReferenceKind -Microsoft.AspNetCore.Components.AI.ReferenceKind.Shortcut = 0 -> Microsoft.AspNetCore.Components.AI.ReferenceKind -Microsoft.AspNetCore.Components.AI.RichContentBlock -Microsoft.AspNetCore.Components.AI.RichContentBlock.AppendText(string! text) -> void -Microsoft.AspNetCore.Components.AI.RichContentBlock.Content.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.RichContentBlock.RawText.get -> string! -Microsoft.AspNetCore.Components.AI.RichContentBlock.RichContentBlock() -> void -Microsoft.AspNetCore.Components.AI.RichTextContent -Microsoft.AspNetCore.Components.AI.RichTextContent.Nodes.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.RichTextContent.RichTextContent(string! text, System.Collections.Generic.IReadOnlyList! nodes) -> void -Microsoft.AspNetCore.Components.AI.RichTextContent.Text.get -> string! -Microsoft.AspNetCore.Components.AI.RichTextNode -Microsoft.AspNetCore.Components.AI.RichTextNode.AddChild(Microsoft.AspNetCore.Components.AI.RichTextNode! child) -> void -Microsoft.AspNetCore.Components.AI.RichTextNode.Children.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.RichTextNode.RichTextNode() -> void -Microsoft.AspNetCore.Components.AI.StrikethroughNode -Microsoft.AspNetCore.Components.AI.StrikethroughNode.StrikethroughNode() -> void -Microsoft.AspNetCore.Components.AI.StrongNode -Microsoft.AspNetCore.Components.AI.StrongNode.StrongNode() -> void -Microsoft.AspNetCore.Components.AI.StateMapperContext -Microsoft.AspNetCore.Components.AI.StateMapperContext.MarkHandled(Microsoft.Extensions.AI.AIContent! content) -> void -Microsoft.AspNetCore.Components.AI.StateMapperContext.SetPredictiveState(object! value) -> void -Microsoft.AspNetCore.Components.AI.StateMapperContext.SetState(object! value) -> void -Microsoft.AspNetCore.Components.AI.StateMapperContext.UnhandledContents.get -> System.Collections.Generic.IEnumerable! -Microsoft.AspNetCore.Components.AI.StateMapperContext.Update.get -> Microsoft.Extensions.AI.ChatResponseUpdate! -Microsoft.AspNetCore.Components.AI.TableCellNode -Microsoft.AspNetCore.Components.AI.TableCellNode.TableCellNode() -> void -Microsoft.AspNetCore.Components.AI.TableColumnAlignment -Microsoft.AspNetCore.Components.AI.TableColumnAlignment.Center = 2 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment -Microsoft.AspNetCore.Components.AI.TableColumnAlignment.Left = 1 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment -Microsoft.AspNetCore.Components.AI.TableColumnAlignment.None = 0 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment -Microsoft.AspNetCore.Components.AI.TableColumnAlignment.Right = 3 -> Microsoft.AspNetCore.Components.AI.TableColumnAlignment -Microsoft.AspNetCore.Components.AI.TableNode -Microsoft.AspNetCore.Components.AI.TableNode.Alignment.get -> System.Collections.Generic.IReadOnlyList! -Microsoft.AspNetCore.Components.AI.TableNode.Alignment.set -> void -Microsoft.AspNetCore.Components.AI.TableNode.TableNode() -> void -Microsoft.AspNetCore.Components.AI.TableRowNode -Microsoft.AspNetCore.Components.AI.TableRowNode.TableRowNode() -> void -Microsoft.AspNetCore.Components.AI.TextNode -Microsoft.AspNetCore.Components.AI.TextNode.Text.get -> string! -Microsoft.AspNetCore.Components.AI.TextNode.Text.set -> void -Microsoft.AspNetCore.Components.AI.TextNode.TextNode() -> void -Microsoft.AspNetCore.Components.AI.TextNode.TextNode(string! text) -> void -Microsoft.AspNetCore.Components.AI.ThematicBreakNode -Microsoft.AspNetCore.Components.AI.ThematicBreakNode.ThematicBreakNode() -> void -Microsoft.AspNetCore.Components.AI.ToolBlockAttribute -Microsoft.AspNetCore.Components.AI.ToolBlockAttribute.ToolBlockAttribute(string! toolName) -> void -Microsoft.AspNetCore.Components.AI.ToolBlockAttribute.ToolName.get -> string! -Microsoft.AspNetCore.Components.AI.ToolParameterAttribute -Microsoft.AspNetCore.Components.AI.ToolParameterAttribute.Name.get -> string? -Microsoft.AspNetCore.Components.AI.ToolParameterAttribute.Name.set -> void -Microsoft.AspNetCore.Components.AI.ToolParameterAttribute.ToolParameterAttribute() -> void -Microsoft.AspNetCore.Components.AI.ToolResultAttribute -Microsoft.AspNetCore.Components.AI.ToolResultAttribute.Name.get -> string? -Microsoft.AspNetCore.Components.AI.ToolResultAttribute.Name.set -> void -Microsoft.AspNetCore.Components.AI.ToolResultAttribute.ToolResultAttribute() -> void -Microsoft.AspNetCore.Components.AI.UIAgent -Microsoft.AspNetCore.Components.AI.UIAgent.Dispose() -> void -Microsoft.AspNetCore.Components.AI.UIAgent.RestoreAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task!>! -Microsoft.AspNetCore.Components.AI.UIAgent.SendMessageAsync(Microsoft.Extensions.AI.ChatMessage! message, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IAsyncEnumerable! -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, Microsoft.Extensions.AI.ChatOptions! chatOptions) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, Microsoft.Extensions.AI.ChatOptions! chatOptions, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action? configure) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action? configure, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory) -> void -Microsoft.AspNetCore.Components.AI.UIAgent -Microsoft.AspNetCore.Components.AI.UIAgent.State.get -> Microsoft.AspNetCore.Components.AI.AgentState! -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, Microsoft.Extensions.AI.ChatOptions! chatOptions, TState? initialState = null) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action!>! configure, Microsoft.Extensions.Logging.ILoggerFactory? loggerFactory, TState? initialState = null) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, System.Action!>! configure, TState? initialState = null) -> void -Microsoft.AspNetCore.Components.AI.UIAgent.UIAgent(Microsoft.Extensions.AI.IChatClient! chatClient, TState? initialState = null) -> void -Microsoft.AspNetCore.Components.AI.UIAgentOptions -Microsoft.AspNetCore.Components.AI.UIAgentOptions.AddBlockHandler(Microsoft.AspNetCore.Components.AI.ContentBlockHandler! handler) -> void -Microsoft.AspNetCore.Components.AI.UIAgentOptions.ChatOptions.get -> Microsoft.Extensions.AI.ChatOptions? -Microsoft.AspNetCore.Components.AI.UIAgentOptions.ChatOptions.set -> void -Microsoft.AspNetCore.Components.AI.UIAgentOptions.RegisterUIAction(Microsoft.Extensions.AI.AIFunction! function) -> void -Microsoft.AspNetCore.Components.AI.UIAgentOptions -Microsoft.AspNetCore.Components.AI.UIAgentOptions.State.get -> Microsoft.AspNetCore.Components.AI.AgentState! -Microsoft.AspNetCore.Components.AI.UIAgentOptions.StateMapper.get -> System.Action? -Microsoft.AspNetCore.Components.AI.UIAgentOptions.StateMapper.set -> void -Microsoft.AspNetCore.Components.AI.UIAgentOptions.Thread.get -> Microsoft.AspNetCore.Components.AI.IConversationThread? -Microsoft.AspNetCore.Components.AI.UIAgentOptions.Thread.set -> void -Microsoft.AspNetCore.Components.AI.UIAgentOptions.UIAgentOptions() -> void -Microsoft.AspNetCore.Components.AI.UIActionBlock -Microsoft.AspNetCore.Components.AI.UIActionBlock.Call.get -> Microsoft.Extensions.AI.FunctionCallContent! -Microsoft.AspNetCore.Components.AI.UIActionBlock.GetResultAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.UIActionBlock.InvokeAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! -Microsoft.AspNetCore.Components.AI.UIActionBlock.IsComplete.get -> bool -Microsoft.AspNetCore.Components.AI.UIActionBlock.Result.get -> Microsoft.Extensions.AI.FunctionResultContent? -Microsoft.AspNetCore.Components.AI.UIActionBlock.ToolName.get -> string! -abstract Microsoft.AspNetCore.Components.AI.ContentBlockHandler.Handle(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TState state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult -abstract Microsoft.AspNetCore.Components.AI.ActivityHandler.TryCreateBlock(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TBlock! state) -> bool -abstract Microsoft.AspNetCore.Components.AI.ActivityHandler.TryUpdateBlock(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TBlock! state, out bool isCompleted) -> bool -override sealed Microsoft.AspNetCore.Components.AI.ActivityHandler.Handle(Microsoft.AspNetCore.Components.AI.BlockMappingContext! context, TBlock! state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult -override Microsoft.AspNetCore.Components.AI.AgentBoundary.BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder! builder) -> void -override Microsoft.AspNetCore.Components.AI.AgentBoundary.OnInitialized() -> void -override Microsoft.AspNetCore.Components.AI.AgentBoundary.OnParametersSet() -> void -virtual Microsoft.AspNetCore.Components.AI.ActivityHandler.OnContentUpdated(TBlock! state) -> void -static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Complete() -> Microsoft.AspNetCore.Components.AI.BlockMappingResult -static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Emit(Microsoft.AspNetCore.Components.AI.ContentBlock! block, TState state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult -static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Pass() -> Microsoft.AspNetCore.Components.AI.BlockMappingResult -static Microsoft.AspNetCore.Components.AI.BlockMappingResult.Update(TState state) -> Microsoft.AspNetCore.Components.AI.BlockMappingResult diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/wwwroot/ai-chat.css b/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/wwwroot/ai-chat.css deleted file mode 100644 index 83877fb4d07a..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/wwwroot/ai-chat.css +++ /dev/null @@ -1,457 +0,0 @@ -/* ========================================================================== - Microsoft.AspNetCore.Components.AI — Design Tokens & Default Styles - ========================================================================== */ - -/* ---------- Root scope ---------- */ -.sc-ai-root { - /* ---- Typography ---- */ - --sc-ai-font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; - --sc-ai-font-size: 0.9375rem; - --sc-ai-font-size-sm: 0.8125rem; - --sc-ai-font-size-lg: 1.125rem; - --sc-ai-line-height: 1.5; - --sc-ai-font-weight-normal: 400; - --sc-ai-font-weight-medium: 500; - --sc-ai-font-weight-bold: 600; - - /* ---- Colors — Surface & Background ---- */ - --sc-ai-color-bg: #ffffff; - --sc-ai-color-surface: #ffffff; - --sc-ai-color-surface-hover: #f8f9fa; - --sc-ai-color-text: #212529; - --sc-ai-color-text-secondary: #6c757d; - --sc-ai-color-text-on-accent: #ffffff; - --sc-ai-color-accent: #0d6efd; - --sc-ai-color-accent-hover: #0b5ed7; - --sc-ai-color-border: #dee2e6; - --sc-ai-color-success: #198754; - --sc-ai-color-error: #dc3545; - --sc-ai-color-error-bg: #f8d7da; - - /* ---- Colors — Message Bubbles ---- */ - --sc-ai-color-bubble-user: #e9ecef; - --sc-ai-color-bubble-user-text: #212529; - --sc-ai-color-bubble-assistant: transparent; - --sc-ai-color-bubble-assistant-text: #212529; - - /* ---- Layout & Spacing ---- */ - --sc-ai-spacing-xs: 0.25rem; - --sc-ai-spacing-sm: 0.5rem; - --sc-ai-spacing-md: 1rem; - --sc-ai-spacing-lg: 1.5rem; - --sc-ai-max-width: 48rem; - --sc-ai-border-radius-sm: 0.375rem; - --sc-ai-border-radius-lg: 1.5rem; - --sc-ai-input-height: 3rem; - - /* ---- Transitions ---- */ - --sc-ai-transition-fast: 120ms ease; - - /* ---- Focus & States ---- */ - --sc-ai-focus-ring: 0 0 0 2px var(--sc-ai-color-accent); - --sc-ai-disabled-opacity: 0.5; - - /* Apply base typography */ - font-family: var(--sc-ai-font-family); - font-size: var(--sc-ai-font-size); - line-height: var(--sc-ai-line-height); - color: var(--sc-ai-color-text); - box-sizing: border-box; -} - -.sc-ai-root *, -.sc-ai-root *::before, -.sc-ai-root *::after { - box-sizing: inherit; -} - -/* ---------- Buttons ---------- */ -.sc-ai-btn { - display: inline-flex; - align-items: center; - justify-content: center; - gap: var(--sc-ai-spacing-xs); - padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); - border: 1px solid transparent; - border-radius: var(--sc-ai-border-radius-sm); - font-family: inherit; - font-size: var(--sc-ai-font-size-sm); - font-weight: var(--sc-ai-font-weight-medium); - cursor: pointer; - transition: background var(--sc-ai-transition-fast), - color var(--sc-ai-transition-fast), - border-color var(--sc-ai-transition-fast), - opacity var(--sc-ai-transition-fast); - line-height: 1; -} - -.sc-ai-btn:focus-visible { - outline: none; - box-shadow: var(--sc-ai-focus-ring); -} - -.sc-ai-btn:disabled { - opacity: var(--sc-ai-disabled-opacity); - cursor: not-allowed; -} - -.sc-ai-btn--primary { - background: var(--sc-ai-color-accent); - color: var(--sc-ai-color-text-on-accent); -} - -.sc-ai-btn--primary:hover:not(:disabled) { - background: var(--sc-ai-color-accent-hover); -} - -.sc-ai-btn--secondary { - background: var(--sc-ai-color-surface); - color: var(--sc-ai-color-text); - border-color: var(--sc-ai-color-border); -} - -.sc-ai-btn--secondary:hover:not(:disabled) { - background: var(--sc-ai-color-surface-hover); -} - -/* ---------- Message List ---------- */ -.sc-ai-message-list { - display: flex; - flex-direction: column; - gap: var(--sc-ai-spacing-md); - max-width: var(--sc-ai-max-width); - margin: 0 auto; - padding: var(--sc-ai-spacing-lg); - width: 100%; -} - -.sc-ai-message-list__footer { - min-height: var(--sc-ai-spacing-lg); -} - -/* ---------- Turn ---------- */ -.sc-ai-turn { - display: flex; - flex-direction: column; - gap: var(--sc-ai-spacing-sm); -} - -/* ---------- Message Bubbles ---------- */ -.sc-ai-message { - display: flex; -} - -.sc-ai-message--user { - justify-content: flex-end; -} - -.sc-ai-message--assistant { - justify-content: flex-start; -} - -.sc-ai-message__bubble { - max-width: 85%; - padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); - border-radius: var(--sc-ai-border-radius-lg); - word-break: break-word; -} - -.sc-ai-message--user .sc-ai-message__bubble { - background: var(--sc-ai-color-bubble-user); - color: var(--sc-ai-color-bubble-user-text); - border-bottom-right-radius: var(--sc-ai-border-radius-sm); -} - -.sc-ai-message--assistant .sc-ai-message__bubble { - background: var(--sc-ai-color-bubble-assistant); - color: var(--sc-ai-color-bubble-assistant-text); - border-bottom-left-radius: var(--sc-ai-border-radius-sm); -} - -.sc-ai-message__content { - white-space: pre-wrap; -} - -.sc-ai-rich-text__paragraph, -.sc-ai-rich-text__heading, -.sc-ai-rich-text__quote, -.sc-ai-rich-text__list, -.sc-ai-rich-text__code-block, -.sc-ai-rich-text__table-container { - margin-block: 0 0.75em; -} - -.sc-ai-message__content > :last-child { - margin-bottom: 0; -} - -.sc-ai-rich-text__heading { - line-height: 1.25; -} - -.sc-ai-rich-text__inline-code, -.sc-ai-rich-text__code-block { - font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; - background: var(--sc-ai-color-surface-hover); - border-radius: var(--sc-ai-border-radius-sm); -} - -.sc-ai-rich-text__inline-code { - padding: 0.1em 0.3em; -} - -.sc-ai-rich-text__code-block { - overflow-x: auto; - padding: var(--sc-ai-spacing-sm); -} - -.sc-ai-rich-text__quote { - border-left: 0.25rem solid var(--sc-ai-color-border); - padding-left: var(--sc-ai-spacing-md); -} - -.sc-ai-rich-text__list-item > .sc-ai-rich-text__paragraph { - display: inline; -} - -.sc-ai-rich-text__table-container { - overflow-x: auto; -} - -.sc-ai-rich-text__table { - border-collapse: collapse; - width: 100%; -} - -.sc-ai-rich-text__table td { - border: 1px solid var(--sc-ai-color-border); - padding: var(--sc-ai-spacing-xs) var(--sc-ai-spacing-sm); -} - -.sc-ai-rich-text__table-cell--center { - text-align: center; -} - -.sc-ai-rich-text__table-cell--right { - text-align: right; -} - -/* Streaming cursor */ -.sc-ai-message__content--streaming::after { - content: ""; - display: inline-block; - width: 2px; - height: 1em; - background: currentColor; - margin-left: 1px; - vertical-align: text-bottom; - animation: sc-ai-blink 1s step-end infinite; -} - -@keyframes sc-ai-blink { - 0%, 100% { opacity: 1; } - 50% { opacity: 0; } -} - -/* ---------- Approval ---------- */ -.sc-ai-approval { - border: 1px solid var(--sc-ai-color-border); - border-radius: var(--sc-ai-border-radius-sm); - padding: var(--sc-ai-spacing-md); -} - -.sc-ai-approval__header { - margin-bottom: var(--sc-ai-spacing-sm); - font-weight: var(--sc-ai-font-weight-medium); -} - -.sc-ai-approval__tool-name, -.sc-ai-approval__status { - font-size: var(--sc-ai-font-size-sm); -} - -.sc-ai-approval__tool-name { - color: var(--sc-ai-color-text-secondary); - margin-bottom: var(--sc-ai-spacing-sm); -} - -.sc-ai-approval__arguments { - overflow-x: auto; - padding: var(--sc-ai-spacing-sm); - background: var(--sc-ai-color-surface-hover); - border-radius: var(--sc-ai-border-radius-sm); -} - -.sc-ai-approval__actions { - display: flex; - gap: var(--sc-ai-spacing-sm); -} - -.sc-ai-approval__status { - font-weight: var(--sc-ai-font-weight-medium); -} - -.sc-ai-approval__status--approved { - color: var(--sc-ai-color-success); -} - -.sc-ai-approval__status--rejected { - color: var(--sc-ai-color-error); -} - -/* ---------- Typing Indicator ---------- */ -.sc-ai-typing { - display: inline-flex; - align-items: center; - gap: 4px; - padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); -} - -.sc-ai-typing__dot { - width: 6px; - height: 6px; - border-radius: 50%; - background: var(--sc-ai-color-text-secondary); - animation: sc-ai-bounce 1.4s ease-in-out infinite; -} - -.sc-ai-typing__dot:nth-child(2) { - animation-delay: 0.2s; -} - -.sc-ai-typing__dot:nth-child(3) { - animation-delay: 0.4s; -} - -@keyframes sc-ai-bounce { - 0%, 80%, 100% { transform: translateY(0); } - 40% { transform: translateY(-6px); } -} - -/* ---------- Error Banner ---------- */ -.sc-ai-error { - display: flex; - align-items: center; - gap: var(--sc-ai-spacing-sm); - padding: var(--sc-ai-spacing-sm) var(--sc-ai-spacing-md); - background: var(--sc-ai-color-error-bg); - color: var(--sc-ai-color-error); - border-radius: var(--sc-ai-border-radius-sm); - font-size: var(--sc-ai-font-size-sm); -} - -.sc-ai-error__message { - flex: 1; -} - -/* ---------- Message Input ---------- */ -.sc-ai-input { - display: flex; - align-items: flex-end; - gap: var(--sc-ai-spacing-sm); - padding: var(--sc-ai-spacing-sm); - background: var(--sc-ai-color-surface); - border: 1px solid var(--sc-ai-color-border); - border-radius: var(--sc-ai-border-radius-lg); - transition: border-color var(--sc-ai-transition-fast); -} - -.sc-ai-input:focus-within { - border-color: var(--sc-ai-color-accent); -} - -.sc-ai-input__body { - flex: 1; - display: flex; - flex-direction: column; -} - -.sc-ai-input__textarea { - flex: 1; - border: none; - outline: none; - resize: none; - font-family: inherit; - font-size: inherit; - line-height: var(--sc-ai-line-height); - color: var(--sc-ai-color-text); - background: transparent; - min-height: var(--sc-ai-input-height); - max-height: 10rem; - padding: var(--sc-ai-spacing-sm); -} - -.sc-ai-input__textarea::placeholder { - color: var(--sc-ai-color-text-secondary); -} - -.sc-ai-input__textarea:disabled { - opacity: var(--sc-ai-disabled-opacity); -} - -.sc-ai-input__send { - width: 2.25rem; - height: 2.25rem; - padding: 0; - border: none; - border-radius: 50%; - background: var(--sc-ai-color-accent); - color: var(--sc-ai-color-text-on-accent); - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - flex-shrink: 0; - transition: background var(--sc-ai-transition-fast), - opacity var(--sc-ai-transition-fast); -} - -.sc-ai-input__send:hover:not(:disabled) { - background: var(--sc-ai-color-accent-hover); -} - -.sc-ai-input__send:focus-visible { - outline: none; - box-shadow: var(--sc-ai-focus-ring); -} - -.sc-ai-input__send:disabled { - opacity: var(--sc-ai-disabled-opacity); - cursor: not-allowed; -} - -.sc-ai-input__send svg { - width: 1.125rem; - height: 1.125rem; -} - -/* ---------- Chat Page Shell ---------- */ -.sc-ai-chat-page { - display: flex; - flex-direction: column; - height: 100vh; - height: 100dvh; - background: var(--sc-ai-color-bg); -} - -.sc-ai-chat-page__header { - flex-shrink: 0; -} - -.sc-ai-chat-page__body { - flex: 1; - overflow-y: auto; - -webkit-overflow-scrolling: touch; -} - -.sc-ai-chat-page__footer { - flex-shrink: 0; - border-top: 1px solid var(--sc-ai-color-border); - background: var(--sc-ai-color-surface); - padding: var(--sc-ai-spacing-md); -} - -.sc-ai-chat-page__input-container { - max-width: var(--sc-ai-max-width); - margin: 0 auto; -} diff --git a/eng/skill-evals/review-candidate-verifier/provenance.json b/eng/skill-evals/review-candidate-verifier/provenance.json index baf3719a70b2..ff7c28a3c06f 100644 --- a/eng/skill-evals/review-candidate-verifier/provenance.json +++ b/eng/skill-evals/review-candidate-verifier/provenance.json @@ -60,218 +60,22 @@ "file": "source/baseTip/docs/CrossCuttingGuidance.md", "sha256": "4aac99289d9812ac59c50e5eb702c0226c0afee26ba14d68366a82a55ab0feef" }, - { - "file": "source/head/src/Components/AI/src/Attributes/ToolBlockAttribute.cs", - "sha256": "f1cb40278e1883d3f044a5292b67580638947b6886c23ab5609d3de9ae793318" - }, - { - "file": "source/head/src/Components/AI/src/Attributes/ToolParameterAttribute.cs", - "sha256": "36126cf9ea9e6044e205423706d904ebda948dd45ad261fb2acd92fb47c836b0" - }, - { - "file": "source/head/src/Components/AI/src/Attributes/ToolResultAttribute.cs", - "sha256": "30dd2c43dd178cb80a0bf307c03c579cdad7da3870157bf27f489994793158f2" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/ActivityContentBlock.cs", - "sha256": "045b3483d94b348ecae3f6874a55ffc07c5d716842ffece8ebb80e357875fb43" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/ApprovalStatus.cs", - "sha256": "67ffd303a2a959438dcee7520c48825ab4c267c3f7ad8237d1df71560eebaadc" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/BlockLifecycleState.cs", - "sha256": "653b8ea2c192d31e74e0d35bd8c32b66b8ab5c8e7b2e602047bf2987cbea13cb" - }, { "file": "source/head/src/Components/AI/src/Blocks/ContentBlock.cs", "sha256": "7cab62ac70d7faa70dacbdb4bd36723b4061612ab921b9f7d7d019d3ba905261" }, - { - "file": "source/head/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs", - "sha256": "db8418766c5f51568ff64f531a384c6447b882886fb566f52cc46965db072fae" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs", - "sha256": "3861d6f6db30ad1a3da01d2291abe20d874e1873bbf118232ae17cfab1d43698" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs", - "sha256": "155bccb3735677881e333392d74867a35ff7a42241c8713864813b15f81b0504" - }, { "file": "source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs", "sha256": "0f6c4f9e859a917755b75bcf335273c37461525fc72d7e5564ba2594c99ba90f" }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichContentBlock.cs", - "sha256": "54084f5f145084e86452408d39e7c75a5d948f5986b3f7e2c127ce9055bc75b9" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs", - "sha256": "71d307651982e43a7724696cc4213f590818d7453d7670143a6a86c301ac631f" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs", - "sha256": "1f56939978bf0c37cd897eefcdd76d42cde7456257e595508a57bd6be1f69c3a" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs", - "sha256": "6d5bbd145d541ad60a375e35ec003d27866fc498c7011b7199f4bc40f31fa75d" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs", - "sha256": "46a28b95716f15cf2bee5266d972751debaa0417e78b90fde9fc5aab76b652b7" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs", - "sha256": "bf88a0391d31df6a4719a5b940c22a44ce379358fc4ac63a5a45915168b50cba" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs", - "sha256": "921ba26b82510d648df61f66b93f58a7bb8beefa38c0bc6cc29608662920e6f0" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs", - "sha256": "7924dd754285a4c89af87d20927e225f48b1174ffb1a578ddde39888f5b091e5" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/HeadingNode.cs", - "sha256": "3c5c019ac54d8f752d544c924b3978446d73b67bbd3d52fcff50e454ac4d27dc" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/HtmlNode.cs", - "sha256": "6829bcc853a0ba7d6be31fc9d16ff04c99a1db68793d0cba44fa5f33ba8bbeba" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/ImageNode.cs", - "sha256": "0825486c8473f53d0f20db7b8f52a9c487949a6812cc6945d8bc66a74c325384" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs", - "sha256": "24fe2f8c410480313b80082ebae104f7c07430129ea18929e7367e98ad9ccf03" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs", - "sha256": "f8f00723a4759faec86da90a1af4e8b8bcfb1d58c4369e98bb2f48628d9b7176" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs", - "sha256": "98debdacd45632cefd2771f282a6a4fffbc13ef3e9a8f3835c3d15e0720e90d4" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/LinkNode.cs", - "sha256": "f87fe0d3f3de2c7e4b226dc4220c5f87300bfbcb98445c68d3ac7073997169bb" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs", - "sha256": "320ea107547bbb7c03897515ce525718e4facb0047f21da0d3283e7f7f298f6d" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/ListItemNode.cs", - "sha256": "7f833996a9d0b386722e0d4e0829aa9e7ea88a521c767103d09e7a60130ba18a" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/ListNode.cs", - "sha256": "8f34e045f65106f690b92cd44b243ebab3653474a6cf835736c18715035cd0fb" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs", - "sha256": "03f3650301497e04f74360a5c7929d5e8a3f0d44da4fc6f2df47b2de8c8e2e51" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs", - "sha256": "796c5d0d27544f74749374eeb69761131392063825434bfb3166c900f3e0b47a" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/RichTextContent.cs", - "sha256": "584b50645c92a21a470d8129392380d9e479c33a92c3f2eb9a227367ad93f610" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/RichTextNode.cs", - "sha256": "3c6870d4f61c3c94b084fe0a78e384a3da7dce8dab86a999d0975430de4bfeea" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs", - "sha256": "e4d1a1696ec000209647ff389361f65f4346bb37707d407d26116706c350df46" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/StrongNode.cs", - "sha256": "45712e7dbebc5d3631517182d9d8596f6b244d5c17077e2b8dfd6b44905a1fc5" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/TableCellNode.cs", - "sha256": "767df77d890d1be243c272f75b76186a4812513c612d50808dbe4df5f7438e05" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs", - "sha256": "7cf9b683a0ba9c2ed5355b9af2bc31940935d10f152943608809561b7dad93b0" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/TableNode.cs", - "sha256": "ca387647fa183558a24c20ffb0edaa3c575499bf2099c0284ee28c59706198dd" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/TableRowNode.cs", - "sha256": "f5c0a16960e90b686d54c0aeba5cc495ae900b4679d26a088d0f59413d4c8f13" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/TextNode.cs", - "sha256": "677866abd2c640f862e69129786912b8dafefbbbd3f1b1633bac47778c8cb5a8" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs", - "sha256": "12e11fb9fdc2b250b22818dd8f9664f6a247ab95a83125ebd3ac75ccbd336423" - }, - { - "file": "source/head/src/Components/AI/src/Blocks/UIActionBlock.cs", - "sha256": "b2d7f7f306d359ce1633dd32dd5a8bc7de7120769999230a3828bf5347ca2b3e" - }, - { - "file": "source/head/src/Components/AI/src/Components/AgentBoundary.cs", - "sha256": "5a0ad7c1b8c0ff594d3ae03c9d25a40dfc672ce477f9e5df396ed407fef582d8" - }, - { - "file": "source/head/src/Components/AI/src/Components/BlockContainer.cs", - "sha256": "52a97be2d51ce402a2de5e8b859c81cfaed580d929840c2b9dbdc0aaec5b5c71" - }, - { - "file": "source/head/src/Components/AI/src/Components/BlockRenderer.cs", - "sha256": "0524975d553822256ae5c1b85a356bce3d08f416bfe934625add4b33eac43e51" - }, - { - "file": "source/head/src/Components/AI/src/Components/BlockRendererRegistration.cs", - "sha256": "52912560b6351526ab6190015f6087ee93ec8b53b0a49e67f44633bb57e011ec" - }, - { - "file": "source/head/src/Components/AI/src/Components/ChatPage.cs", - "sha256": "2dc2a16d7f5d00c2e19f695151824fb0c2d1e76fa30b859d89f0a53c6338464b" - }, - { - "file": "source/head/src/Components/AI/src/Components/ConversationTurnRenderer.cs", - "sha256": "eaf2d4a5f947e751c3b6cfacd6c5e532d172417ee10c289bf9f5c400535cac3d" - }, { "file": "source/head/src/Components/AI/src/Components/MessageInput.cs", "sha256": "d0ddd1d72a79945463c3ddf92b2861b4e2b05d47fb4bebcbc7feef5685397091" }, - { - "file": "source/head/src/Components/AI/src/Components/MessageList.cs", - "sha256": "b7006ea1165874ab2c1d162da6c95ca966679a5af6088ab230794c05dcd0cd62" - }, - { - "file": "source/head/src/Components/AI/src/Components/MessageListContext.cs", - "sha256": "98bbe96c5ff3a39af9e9b7acc231ec141dc799dbfb0d7f3e23ee4ada057afbc5" - }, { "file": "source/head/src/Components/AI/src/Engine/AgentContext.cs", "sha256": "cbabd18763571b3ad936002d1d54ea35d6f2c537f7df131655bca0334f2c3ccd" }, - { - "file": "source/head/src/Components/AI/src/Engine/AgentState.cs", - "sha256": "b885933998219a8100bfcaabf7e23b6eceb5abaa291f37d82597d4484d8bbd3c" - }, { "file": "source/head/src/Components/AI/src/Engine/ConversationStatus.cs", "sha256": "b44fd1f2cbb45c401f14a695f3ef8c7dac6f1d2a66f6e9622f15a2c2099546f9" @@ -280,10 +84,6 @@ "file": "source/head/src/Components/AI/src/Engine/ConversationTurn.cs", "sha256": "3a5dbc73c955c5dec1fa04e195c35387477287a0b5e78013b2c91d65477295ea" }, - { - "file": "source/head/src/Components/AI/src/Engine/IConversationThread.cs", - "sha256": "3c4314b600c5c87b52ffeede6ea22ed2fa584899f6438c24510044cea1e02930" - }, { "file": "source/head/src/Components/AI/src/Engine/UIAgent.cs", "sha256": "15f260ac18c35efde79d4822641961f0ea002bfe398d366b123ad5887b1ea919" @@ -292,310 +92,30 @@ "file": "source/head/src/Components/AI/src/Engine/UIAgentLog.cs", "sha256": "8f20da705a199ebf56ece8f9e073107a9a7ec8404884c69e4c748fd5f1224061" }, - { - "file": "source/head/src/Components/AI/src/Engine/UIAgentOfT.cs", - "sha256": "0855d67e41020e645a6b5852c02a64103f4c1513c23e1a7292439829e0b52040" - }, - { - "file": "source/head/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj", - "sha256": "5a7d5fd6755234d24e24df43a1c3eac89b0d611bc6055d309c5916287e3123e4" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/ActivityHandler.cs", - "sha256": "c72db965d47185f450d5f797051125b9955bd9132ea4a5d84d369ce64a8d4a85" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/BlockMappingContext.cs", - "sha256": "91d8ed84a46c3b2e82d11bed099d14a216c95bee3cb7bf8039b6611af3223a82" - }, { "file": "source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs", "sha256": "3efb30f16570e2754c38b579e3fdb4dc4d5b9d750b3a9408c7fa1238c11258ee" }, - { - "file": "source/head/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs", - "sha256": "18a23af9bd27c95959d0917294f6ee96e9c7873d4a2067bc6502ef654ad01644" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/BlockMappingResult.cs", - "sha256": "3bb7afa62fae00d6b7116f28c2c44b2d62e870c32cce22bfe202ece60e3fb144" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/ContentBlockHandler.cs", - "sha256": "3ca4bf65c9c707e58facec456ae06fb155b514f5e2498872160b99e5a3dd70e9" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs", - "sha256": "c48f3920b80b23886fe47bb9156e92d39dab8fd7f699c4113fa8b17fe272217f" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs", - "sha256": "420e7b798cf15e7f987b9106177002815cb41288bf7f9e1c29613cf7bca2d8cd" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/HandlerEntry.cs", - "sha256": "c3e250713a61f37bd3f37dc42a74bf3c5e0689a0b0e31b16fcf8d09f04839c00" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/HandleResult.cs", - "sha256": "e052511e82662de87979323e6f5699a94c56d4e1d719dfd38dafe852fb733cd3" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/IActiveEntry.cs", - "sha256": "2faffc0f2c4e47dec85d89eb56a086c39f52c8d4a87957e985e3d79770aac2f8" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/IHandlerEntry.cs", - "sha256": "4af13fd202275f8189ce060d88e8f1b6266115a24a60474d7376969432319dd4" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/RichTextContentHandler.cs", - "sha256": "c7bd4d6b7f4f5f6698ecaa71aebcecce67292fe0f1a8ccbbee64a90883efa9c3" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/StateMapperContext.cs", - "sha256": "8500c1f1fcd34fb8a55bc986e56ee42161bdda751ff2b97fba1b1ed29122836a" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/TextBlockHandler.cs", - "sha256": "28c8e506a5a6e3f51d1c4516f66a2b8492538340418b4fd2b03b3f0219b965f5" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/UIActionHandler.cs", - "sha256": "f33e60159c8d801d9ae2c289822315d6a52a78cf33e9c384d35b48de0d7a56df" - }, - { - "file": "source/head/src/Components/AI/src/Pipeline/UIAgentOptions.cs", - "sha256": "f4181e9108cec5ee9bc1d13cc8c83a58f5519f6e91567fd0a170f877b1021327" - }, - { - "file": "source/head/src/Components/AI/src/PublicAPI.Shipped.txt", - "sha256": "3c3b422dddb1efeb0fc5b228608fd8682452b2a9507d4031894bce3c4dedadbd" - }, - { - "file": "source/head/src/Components/AI/src/PublicAPI.Unshipped.txt", - "sha256": "b36a49c1d91321adb5412e3f3c9d932c8acef4636fb7e040b9c0410971505719" - }, - { - "file": "source/head/src/Components/AI/src/wwwroot/ai-chat.css", - "sha256": "29d0497cdca03d412edd3ece98cb923edf2834e6054c4fb0a03d30a31251832c" - }, { "file": "source/head/src/Engine/Conversation.mjs", "sha256": "13e383993dd60d8548089196ada34afcf791c7995ffda48104bbe23bf15cff11" }, - { - "file": "source/mergeBase/src/Components/AI/src/Attributes/ToolBlockAttribute.cs", - "sha256": "f1cb40278e1883d3f044a5292b67580638947b6886c23ab5609d3de9ae793318" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Attributes/ToolParameterAttribute.cs", - "sha256": "36126cf9ea9e6044e205423706d904ebda948dd45ad261fb2acd92fb47c836b0" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Attributes/ToolResultAttribute.cs", - "sha256": "30dd2c43dd178cb80a0bf307c03c579cdad7da3870157bf27f489994793158f2" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/ActivityContentBlock.cs", - "sha256": "045b3483d94b348ecae3f6874a55ffc07c5d716842ffece8ebb80e357875fb43" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/ApprovalStatus.cs", - "sha256": "67ffd303a2a959438dcee7520c48825ab4c267c3f7ad8237d1df71560eebaadc" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/BlockLifecycleState.cs", - "sha256": "653b8ea2c192d31e74e0d35bd8c32b66b8ab5c8e7b2e602047bf2987cbea13cb" - }, { "file": "source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs", "sha256": "7cab62ac70d7faa70dacbdb4bd36723b4061612ab921b9f7d7d019d3ba905261" }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/ContentBlockChangedSubscription.cs", - "sha256": "db8418766c5f51568ff64f531a384c6447b882886fb566f52cc46965db072fae" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/FunctionApprovalBlock.cs", - "sha256": "3861d6f6db30ad1a3da01d2291abe20d874e1873bbf118232ae17cfab1d43698" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/FunctionInvocationContentBlock.cs", - "sha256": "155bccb3735677881e333392d74867a35ff7a42241c8713864813b15f81b0504" - }, { "file": "source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs", "sha256": "0f6c4f9e859a917755b75bcf335273c37461525fc72d7e5564ba2594c99ba90f" }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichContentBlock.cs", - "sha256": "54084f5f145084e86452408d39e7c75a5d948f5986b3f7e2c127ce9055bc75b9" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/BlockQuoteNode.cs", - "sha256": "71d307651982e43a7724696cc4213f590818d7453d7670143a6a86c301ac631f" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/CodeBlockNode.cs", - "sha256": "1f56939978bf0c37cd897eefcdd76d42cde7456257e595508a57bd6be1f69c3a" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/DefinitionNode.cs", - "sha256": "6d5bbd145d541ad60a375e35ec003d27866fc498c7011b7199f4bc40f31fa75d" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/EmphasisNode.cs", - "sha256": "46a28b95716f15cf2bee5266d972751debaa0417e78b90fde9fc5aab76b652b7" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteDefinitionNode.cs", - "sha256": "bf88a0391d31df6a4719a5b940c22a44ce379358fc4ac63a5a45915168b50cba" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteNode.cs", - "sha256": "921ba26b82510d648df61f66b93f58a7bb8beefa38c0bc6cc29608662920e6f0" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/FootnoteReferenceNode.cs", - "sha256": "7924dd754285a4c89af87d20927e225f48b1174ffb1a578ddde39888f5b091e5" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/HeadingNode.cs", - "sha256": "3c5c019ac54d8f752d544c924b3978446d73b67bbd3d52fcff50e454ac4d27dc" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/HtmlNode.cs", - "sha256": "6829bcc853a0ba7d6be31fc9d16ff04c99a1db68793d0cba44fa5f33ba8bbeba" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageNode.cs", - "sha256": "0825486c8473f53d0f20db7b8f52a9c487949a6812cc6945d8bc66a74c325384" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ImageReferenceNode.cs", - "sha256": "24fe2f8c410480313b80082ebae104f7c07430129ea18929e7367e98ad9ccf03" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/InlineCodeNode.cs", - "sha256": "f8f00723a4759faec86da90a1af4e8b8bcfb1d58c4369e98bb2f48628d9b7176" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/LineBreakNode.cs", - "sha256": "98debdacd45632cefd2771f282a6a4fffbc13ef3e9a8f3835c3d15e0720e90d4" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkNode.cs", - "sha256": "f87fe0d3f3de2c7e4b226dc4220c5f87300bfbcb98445c68d3ac7073997169bb" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/LinkReferenceNode.cs", - "sha256": "320ea107547bbb7c03897515ce525718e4facb0047f21da0d3283e7f7f298f6d" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ListItemNode.cs", - "sha256": "7f833996a9d0b386722e0d4e0829aa9e7ea88a521c767103d09e7a60130ba18a" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ListNode.cs", - "sha256": "8f34e045f65106f690b92cd44b243ebab3653474a6cf835736c18715035cd0fb" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ParagraphNode.cs", - "sha256": "03f3650301497e04f74360a5c7929d5e8a3f0d44da4fc6f2df47b2de8c8e2e51" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ReferenceKind.cs", - "sha256": "796c5d0d27544f74749374eeb69761131392063825434bfb3166c900f3e0b47a" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextContent.cs", - "sha256": "584b50645c92a21a470d8129392380d9e479c33a92c3f2eb9a227367ad93f610" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/RichTextNode.cs", - "sha256": "3c6870d4f61c3c94b084fe0a78e384a3da7dce8dab86a999d0975430de4bfeea" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/StrikethroughNode.cs", - "sha256": "e4d1a1696ec000209647ff389361f65f4346bb37707d407d26116706c350df46" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/StrongNode.cs", - "sha256": "45712e7dbebc5d3631517182d9d8596f6b244d5c17077e2b8dfd6b44905a1fc5" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/TableCellNode.cs", - "sha256": "767df77d890d1be243c272f75b76186a4812513c612d50808dbe4df5f7438e05" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/TableColumnAlignment.cs", - "sha256": "7cf9b683a0ba9c2ed5355b9af2bc31940935d10f152943608809561b7dad93b0" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/TableNode.cs", - "sha256": "ca387647fa183558a24c20ffb0edaa3c575499bf2099c0284ee28c59706198dd" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/TableRowNode.cs", - "sha256": "f5c0a16960e90b686d54c0aeba5cc495ae900b4679d26a088d0f59413d4c8f13" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/TextNode.cs", - "sha256": "677866abd2c640f862e69129786912b8dafefbbbd3f1b1633bac47778c8cb5a8" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/RichText/ThematicBreakNode.cs", - "sha256": "12e11fb9fdc2b250b22818dd8f9664f6a247ab95a83125ebd3ac75ccbd336423" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Blocks/UIActionBlock.cs", - "sha256": "b2d7f7f306d359ce1633dd32dd5a8bc7de7120769999230a3828bf5347ca2b3e" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Components/AgentBoundary.cs", - "sha256": "5a0ad7c1b8c0ff594d3ae03c9d25a40dfc672ce477f9e5df396ed407fef582d8" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Components/BlockContainer.cs", - "sha256": "52a97be2d51ce402a2de5e8b859c81cfaed580d929840c2b9dbdc0aaec5b5c71" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Components/BlockRenderer.cs", - "sha256": "0524975d553822256ae5c1b85a356bce3d08f416bfe934625add4b33eac43e51" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Components/BlockRendererRegistration.cs", - "sha256": "52912560b6351526ab6190015f6087ee93ec8b53b0a49e67f44633bb57e011ec" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Components/ChatPage.cs", - "sha256": "2dc2a16d7f5d00c2e19f695151824fb0c2d1e76fa30b859d89f0a53c6338464b" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Components/ConversationTurnRenderer.cs", - "sha256": "eaf2d4a5f947e751c3b6cfacd6c5e532d172417ee10c289bf9f5c400535cac3d" - }, { "file": "source/mergeBase/src/Components/AI/src/Components/MessageInput.cs", "sha256": "d0ddd1d72a79945463c3ddf92b2861b4e2b05d47fb4bebcbc7feef5685397091" }, - { - "file": "source/mergeBase/src/Components/AI/src/Components/MessageList.cs", - "sha256": "b7006ea1165874ab2c1d162da6c95ca966679a5af6088ab230794c05dcd0cd62" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Components/MessageListContext.cs", - "sha256": "98bbe96c5ff3a39af9e9b7acc231ec141dc799dbfb0d7f3e23ee4ada057afbc5" - }, { "file": "source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs", "sha256": "61ca1e7434f6046328435ec8df5bd069c3198af8bb6b2db9912ff4c66cf7b084" }, - { - "file": "source/mergeBase/src/Components/AI/src/Engine/AgentState.cs", - "sha256": "b885933998219a8100bfcaabf7e23b6eceb5abaa291f37d82597d4484d8bbd3c" - }, { "file": "source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs", "sha256": "b44fd1f2cbb45c401f14a695f3ef8c7dac6f1d2a66f6e9622f15a2c2099546f9" @@ -604,10 +124,6 @@ "file": "source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs", "sha256": "3a5dbc73c955c5dec1fa04e195c35387477287a0b5e78013b2c91d65477295ea" }, - { - "file": "source/mergeBase/src/Components/AI/src/Engine/IConversationThread.cs", - "sha256": "3c4314b600c5c87b52ffeede6ea22ed2fa584899f6438c24510044cea1e02930" - }, { "file": "source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs", "sha256": "63783e5da3d7b6fbf0c339d2e3a2298498b2b455a587e79f5f25431bf9812943" @@ -616,94 +132,10 @@ "file": "source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs", "sha256": "f7eb199a984d4b163a972c13e709de02e203789b8e0e834793b94487344e2df7" }, - { - "file": "source/mergeBase/src/Components/AI/src/Engine/UIAgentOfT.cs", - "sha256": "0855d67e41020e645a6b5852c02a64103f4c1513c23e1a7292439829e0b52040" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Microsoft.AspNetCore.Components.AI.csproj", - "sha256": "5a7d5fd6755234d24e24df43a1c3eac89b0d611bc6055d309c5916287e3123e4" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/ActivityHandler.cs", - "sha256": "c72db965d47185f450d5f797051125b9955bd9132ea4a5d84d369ce64a8d4a85" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingContext.cs", - "sha256": "91d8ed84a46c3b2e82d11bed099d14a216c95bee3cb7bf8039b6611af3223a82" - }, { "file": "source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs", "sha256": "3efb30f16570e2754c38b579e3fdb4dc4d5b9d750b3a9408c7fa1238c11258ee" }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipelineLog.cs", - "sha256": "18a23af9bd27c95959d0917294f6ee96e9c7873d4a2067bc6502ef654ad01644" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingResult.cs", - "sha256": "3bb7afa62fae00d6b7116f28c2c44b2d62e870c32cce22bfe202ece60e3fb144" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/ContentBlockHandler.cs", - "sha256": "3ca4bf65c9c707e58facec456ae06fb155b514f5e2498872160b99e5a3dd70e9" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/FunctionApprovalHandler.cs", - "sha256": "c48f3920b80b23886fe47bb9156e92d39dab8fd7f699c4113fa8b17fe272217f" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/FunctionInvocationHandler.cs", - "sha256": "420e7b798cf15e7f987b9106177002815cb41288bf7f9e1c29613cf7bca2d8cd" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/HandlerEntry.cs", - "sha256": "c3e250713a61f37bd3f37dc42a74bf3c5e0689a0b0e31b16fcf8d09f04839c00" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/HandleResult.cs", - "sha256": "e052511e82662de87979323e6f5699a94c56d4e1d719dfd38dafe852fb733cd3" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/IActiveEntry.cs", - "sha256": "2faffc0f2c4e47dec85d89eb56a086c39f52c8d4a87957e985e3d79770aac2f8" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/IHandlerEntry.cs", - "sha256": "4af13fd202275f8189ce060d88e8f1b6266115a24a60474d7376969432319dd4" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/RichTextContentHandler.cs", - "sha256": "c7bd4d6b7f4f5f6698ecaa71aebcecce67292fe0f1a8ccbbee64a90883efa9c3" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/StateMapperContext.cs", - "sha256": "8500c1f1fcd34fb8a55bc986e56ee42161bdda751ff2b97fba1b1ed29122836a" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/TextBlockHandler.cs", - "sha256": "28c8e506a5a6e3f51d1c4516f66a2b8492538340418b4fd2b03b3f0219b965f5" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/UIActionHandler.cs", - "sha256": "f33e60159c8d801d9ae2c289822315d6a52a78cf33e9c384d35b48de0d7a56df" - }, - { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/UIAgentOptions.cs", - "sha256": "f4181e9108cec5ee9bc1d13cc8c83a58f5519f6e91567fd0a170f877b1021327" - }, - { - "file": "source/mergeBase/src/Components/AI/src/PublicAPI.Shipped.txt", - "sha256": "3c3b422dddb1efeb0fc5b228608fd8682452b2a9507d4031894bce3c4dedadbd" - }, - { - "file": "source/mergeBase/src/Components/AI/src/PublicAPI.Unshipped.txt", - "sha256": "b36a49c1d91321adb5412e3f3c9d932c8acef4636fb7e040b9c0410971505719" - }, - { - "file": "source/mergeBase/src/Components/AI/src/wwwroot/ai-chat.css", - "sha256": "29d0497cdca03d412edd3ece98cb923edf2834e6054c4fb0a03d30a31251832c" - }, { "file": "source/mergeBase/src/Engine/Conversation.mjs", "sha256": "2c59edf3be93947a250c4c0a2787d103775265058fe3dbc533014932e2012deb" From ed6827dca7338874deb7065c3c6603b274867eaf Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Thu, 12 Nov 2026 10:55:13 -0600 Subject: [PATCH 05/23] Address PR #70318 review follow-ups and harden L1/L2 skill-eval gating Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/skill-evals.yml | 4 +- eng/skill-evals/README.md | 12 +- eng/skill-evals/assert_results.ps1 | 17 +- eng/skill-evals/grade_disposition.mjs | 92 ++++++-- .../fixtures/package-c/changed-files.json | 5 - .../review-candidate-verifier/provenance.json | 2 +- .../review-pull-request/eval.vally.yaml | 144 ++++++++---- .../fixtures/case-06/provenance.json | 2 +- eng/skill-evals/run.ps1 | 2 +- eng/skill-evals/test_assert_results.ps1 | 208 +++++++++++++++++- eng/skill-evals/test_disposition.mjs | 44 ++++ eng/skill-evals/test_workflow.ps1 | 15 ++ .../tests/test_review_fixtures.ps1 | 10 +- 13 files changed, 467 insertions(+), 90 deletions(-) diff --git a/.github/workflows/skill-evals.yml b/.github/workflows/skill-evals.yml index 286b7d946682..36b758c9ab2d 100644 --- a/.github/workflows/skill-evals.yml +++ b/.github/workflows/skill-evals.yml @@ -112,10 +112,10 @@ jobs: SKILL_EVAL_VALLY: ${{ runner.temp }}/evaluation-tools/node_modules/.bin/vally run: ./eng/skill-evals/run.ps1 -Action $env:ACTION - - name: Test trusted staging boundary + - name: Run skill eval self-tests if: github.event_name != 'workflow_dispatch' || inputs.action == 'Validate' shell: pwsh - run: ./eng/skill-evals/test_stage_run.ps1 + run: ./eng/skill-evals/run.ps1 -Action Test gate: name: Resolve PR evaluation diff --git a/eng/skill-evals/README.md b/eng/skill-evals/README.md index a4a09297a981..a7c8e0e490d5 100644 --- a/eng/skill-evals/README.md +++ b/eng/skill-evals/README.md @@ -125,8 +125,10 @@ Without a suite or explicit experiment, `Run` dispatches each standard suite int its own output subdirectory. This includes reviewer comparison and the direct verifier component suite. `assert_results.ps1` checks that combined output recursively. A direct component run writes a plan beside Vally's timestamped -`results.jsonl`; it does not invent an experiment variant directory. Smoke selects -one repeat per case and cannot establish the full component 4/5 gate. +`results.jsonl`; it does not invent an experiment variant directory. For the +reviewer and verifier suites, smoke selects one repeat per case and checks trial +completion, grader scores, and read-integrity receipts without enforcing the +multi-trial per-stimulus disposition threshold. ## Hosted entry point @@ -194,8 +196,10 @@ execute from that staged tree, so candidate changes to `run.ps1`, execution in the PAT-backed step. Both baseline and skilled variants must produce the exact planned result count, successful trial statuses, and grader scores; only the skilled score is threshold-gated. The final status and PR -comment link to the retained artifacts. Smoke results validate execution and -the skilled threshold, but Full runs remain the quality-evidence path. +comment link to the retained artifacts. Smoke results validate execution, +read-integrity receipts, and generic aggregate thresholds, while Full runs +enforce per-stimulus review and verifier thresholds and remain the +quality-evidence path. Vally and Copilot still interpret the staged candidate skill and eval stimuli as agent instructions inside the token-bearing execution step. The staging boundary diff --git a/eng/skill-evals/assert_results.ps1 b/eng/skill-evals/assert_results.ps1 index 80bd054c3243..e9aac5b0eaa2 100644 --- a/eng/skill-evals/assert_results.ps1 +++ b/eng/skill-evals/assert_results.ps1 @@ -85,6 +85,8 @@ foreach ($variant in $variants) { throw "The '$variant' variant has $($incomplete.Count) incomplete or failed trial(s)." } + $isReview = $plan.PSObject.Properties['evalName'] -and $plan.evalName -eq 'review-pull-request' + $isPerStimulusSuite = ($variant -eq 'current') -or $isReview $scores = [Collections.Generic.List[double]]::new() $scoresByStimulus = @{} $identities = [Collections.Generic.HashSet[string]]::new() @@ -132,8 +134,7 @@ foreach ($variant in $variants) { $scoresByStimulus[$result.stimulus] = [Collections.Generic.List[double]]::new() } $scoresByStimulus[$result.stimulus].Add($score) - $isReview = $plan.PSObject.Properties['evalName'] -and $plan.evalName -eq 'review-pull-request' - if ($variant -eq 'current' -or $isReview) { + if ($isPerStimulusSuite) { $requiredReceipts = @("evidence-reads-$($result.stimulus)") if ($isReview) { $requiredReceipts += "guidance-reads-$($result.stimulus)" @@ -145,13 +146,14 @@ foreach ($variant in $variants) { throw "The '$variant' trial lacks read-integrity results." } $dispositions = @($gradeResultProperty.Value.details | - Where-Object configuredName -eq "disposition-$($result.stimulus)") + Where-Object { $_.PSObject.Properties['configuredName'] -and $_.configuredName -eq "disposition-$($result.stimulus)" }) if ($dispositions.Count -ne 1 -or $dispositions[0].score -ne $score -or ($dispositions[0].PSObject.Properties['status'] -and $dispositions[0].status -eq 'error')) { throw "The '$variant' trial lacks a valid primary disposition result." } foreach ($receipt in $requiredReceipts) { - $details = @($gradeResultProperty.Value.details | Where-Object configuredName -eq $receipt) + $details = @($gradeResultProperty.Value.details | + Where-Object { $_.PSObject.Properties['configuredName'] -and $_.configuredName -eq $receipt }) if ($details.Count -ne 1 -or $details[0].passed -isnot [bool] -or -not $details[0].passed -or $details[0].score -is [string] -or $details[0].score -ne 1) { throw "The '$variant' trial '$($result.stimulus):$trialIndex' failed read integrity: $receipt." @@ -167,11 +169,16 @@ foreach ($variant in $variants) { throw "The '$variant' stimulus '$name' has incomplete trial coverage." } $caseScore = ($scoresByStimulus[$name] | Measure-Object -Average).Average - if ($variant -ne 'baseline' -and $caseScore -lt [double]$plan.threshold) { + if ($isPerStimulusSuite -and [int]$plan.runs -gt 1 -and + $variant -ne 'baseline' -and $caseScore -lt [double]$plan.threshold) { throw "The '$variant' stimulus '$name' score $caseScore is below threshold $($plan.threshold)." } Write-Host "$variant/$name score: $caseScore ($($plan.runs) complete trials)." } + if (-not $isPerStimulusSuite -and $variant -ne 'baseline' -and + $scoresByVariant[$variant] -lt [double]$plan.threshold) { + throw "The '$variant' score $($scoresByVariant[$variant]) is below threshold $($plan.threshold)." + } } Write-Host 'All planned trials completed. Every gated stimulus met its own threshold.' diff --git a/eng/skill-evals/grade_disposition.mjs b/eng/skill-evals/grade_disposition.mjs index 0f8d5095d284..c1ef79e2ca79 100644 --- a/eng/skill-evals/grade_disposition.mjs +++ b/eng/skill-evals/grade_disposition.mjs @@ -65,6 +65,57 @@ function gradeComponent(name, output) .every(key => actual[key] == null || ['', 'none', 'n/a'].includes(normalized(key))); } +const targetSections = ['NEW_FINDINGS', 'EXISTING_FEEDBACK_COVERAGE', 'UNRESOLVED', 'DISCARDED']; +const topLevelFields = [ + 'TEST_BOUNDARY', + 'LIMITATIONS', + 'PR', + 'HEAD_SHA', + 'MERGE_BASE_SHA', + 'BASE_TIP_SHA', + 'GUIDANCE_SOURCE', + 'GUIDES', + 'UNCOVERED', + 'PATH', +]; + +function stripMarkdown(text) +{ + return text.replace(/(?:\*\*|__|`|\*)/g, ''); +} + +function normalizeHeading(line) +{ + return stripMarkdown(line.trim()) + .replace(/^#{1,6}\s+/, '') + .replace(/^(?:[-*+]|\d+[.)])\s+/, '') + .replace(/^#{1,6}\s+/, '') + .replace(/^[*_]+|[*_:\s]+$/g, '') + .trim(); +} + +function isNegativeC1Line(line) +{ + const clean = stripMarkdown(line) + .trim() + .replace(/^(?:[-*+]|\d+[.)])\s+/, '') + .trim(); + if (!clean || /^(?:none|no|n\/a)\b/i.test(clean)) + { + return true; + } + const afterC1 = clean.replace(/^C1\b\s*(?:[-:—–]|\s)*/i, ''); + return afterC1 !== clean && + /^(?:none|no|n\/a|not\s+(?:covered|unresolved|discarded|applicable)|omitted)\b/i.test(afterC1); +} + +function hasPositiveC1(sectionText) +{ + return sectionText + .split(/\r?\n/) + .some(line => /\bC1\b/.test(line) && !isNegativeC1Line(line)); +} + function gradeReview(name, output) { const expected = reviewCases[name]; @@ -73,7 +124,8 @@ function gradeReview(name, output) throw new Error(`Unknown review case: ${name}`); } const lines = output.trim().split(/\r?\n/); - if (!/^STATUS: (FINDINGS|NO_FINDINGS)$/.test(lines[0])) + const statusLine = lines[0].trim(); + if (!/^STATUS: (FINDINGS|NO_FINDINGS)$/.test(statusLine)) { return false; } @@ -81,8 +133,9 @@ function gradeReview(name, output) let section; for (const line of lines.slice(1)) { - const heading = line.trim().replace(/^#{1,6}\s+/, '').replace(/^\*\*|\*\*$/g, '').replace(/:$/, ''); - if (['NEW_FINDINGS', 'EXISTING_FEEDBACK_COVERAGE', 'UNRESOLVED', 'DISCARDED'].includes(heading)) + const heading = normalizeHeading(line); + const fieldName = heading.split(':')[0].replace(/^[*_]+|[*_\s]+$/g, '').trim(); + if (targetSections.includes(heading)) { if (sections.has(heading)) { @@ -91,6 +144,10 @@ function gradeReview(name, output) section = heading; sections.set(section, ''); } + else if (/^#{1,6}\s+/.test(line.trim()) || topLevelFields.includes(fieldName)) + { + section = undefined; + } else if (section) { sections.set(section, sections.get(section) + '\n' + line); @@ -104,7 +161,7 @@ function gradeReview(name, output) { return false; } - const hasCandidate = key => /\bC1\b/.test(sections.get(key)); + const hasCandidate = key => hasPositiveC1(sections.get(key)); if (!hasCandidate(expected.section)) { return false; @@ -116,7 +173,7 @@ function gradeReview(name, output) hasCandidate('UNRESOLVED') && sections.get(expected.section).includes(expected.thread) && sections.get('UNRESOLVED').includes(expected.thread) && - lines[0] === 'STATUS: NO_FINDINGS'; + statusLine === 'STATUS: NO_FINDINGS'; } if (expected.section !== 'UNRESOLVED' && hasCandidate('UNRESOLVED') || expected.section !== 'DISCARDED' && hasCandidate('DISCARDED') || @@ -124,28 +181,19 @@ function gradeReview(name, output) { return false; } - const inline = sections.get('NEW_FINDINGS'); - const hasInline = hasCandidate('NEW_FINDINGS'); - if (!hasInline) + if (!hasCandidate('NEW_FINDINGS') || statusLine !== 'STATUS: FINDINGS') { return false; } - if (hasInline) + const inline = stripMarkdown(sections.get('NEW_FINDINGS')); + const confidences = [...inline.matchAll(/\bconfidence\s*:\s*([a-z]+)/gi)].map(match => match[1].toLowerCase()); + if (confidences.length !== 1 || confidences[0] !== expected.confidence) { - const confidences = [...inline.matchAll(/\bconfidence\s*:\s*([a-z]+)/gi)].map(match => match[1].toLowerCase()); - if (confidences.length !== 1 || confidences[0] !== expected.confidence || - lines[0] !== 'STATUS: FINDINGS') - { - return false; - } - if (expected.confidence !== 'verified' && - (!inline.includes(`[${expected.confidence.toUpperCase()}]`) || - !new RegExp(`Why ${expected.confidence}:`, 'i').test(inline))) - { - return false; - } + return false; } - return hasInline || lines[0] === 'STATUS: NO_FINDINGS'; + return expected.confidence === 'verified' || + (inline.includes(`[${expected.confidence.toUpperCase()}]`) && + new RegExp(`Why ${expected.confidence}\\s*:`, 'i').test(inline)); } export function grade(input) diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/package-c/changed-files.json b/eng/skill-evals/review-candidate-verifier/fixtures/package-c/changed-files.json index eb1616665d90..97d3833666fe 100644 --- a/eng/skill-evals/review-candidate-verifier/fixtures/package-c/changed-files.json +++ b/eng/skill-evals/review-candidate-verifier/fixtures/package-c/changed-files.json @@ -3,11 +3,6 @@ "path": "src/Engine/Conversation.mjs", "status": "modified", "rightChangedLines": [ - 29, - 30, - 31, - 32, - 33, 35, 36, 37 diff --git a/eng/skill-evals/review-candidate-verifier/provenance.json b/eng/skill-evals/review-candidate-verifier/provenance.json index ff7c28a3c06f..8482e88b7136 100644 --- a/eng/skill-evals/review-candidate-verifier/provenance.json +++ b/eng/skill-evals/review-candidate-verifier/provenance.json @@ -50,7 +50,7 @@ }, { "file": "package-c/changed-files.json", - "sha256": "1e1c3cda2d4c9ece470ce955cb9f296799b7f83754bf20f5fbfcc98c6316a165" + "sha256": "93dd39cc3699523242cc571bd40bd96727e15a071dfb64e5fd8f92b1cf25deea" }, { "file": "package-c/changes.diff", diff --git a/eng/skill-evals/review-pull-request/eval.vally.yaml b/eng/skill-evals/review-pull-request/eval.vally.yaml index fc674a29b19d..a7eb2f589161 100644 --- a/eng/skill-evals/review-pull-request/eval.vally.yaml +++ b/eng/skill-evals/review-pull-request/eval.vally.yaml @@ -30,9 +30,12 @@ stimuli: Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. These are reviewer criteria, not contracts on the older target branch. - If review-pull-request is available, acquire it and read its installed SKILL.md - through the native skill tool or the supplied installed skill path. - Use the verifier and guide-worker instructions referenced by the loaded skill. + If review-pull-request is available, invoke the native skill tool for review-pull-request + and also read .github/agents/review-guide-worker.agent.md, + .github/agents/review-candidate-verifier.agent.md, and the installed review-pull-request + SKILL.md path with view in full; those .agent.md files define subordinate worker/verifier + contracts, so adjudicate as the SKILL.md coordinator (mapping verifier external downgrades + and unestablished drops to UNRESOLVED and only source-contradicted drops to DISCARDED). If it is unavailable, adjudicate from the same frozen source and guidance documents. Page truncated input reads through EOF. @@ -47,10 +50,17 @@ stimuli: Give Before and After for C1's exact input and observable outcome after the status line. The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED - as separate headings. Identify C1 explicitly in each applicable section. - Use confidence: verified, question, unresolved, or discarded for an inline entry. - Prefix unresolved or discarded inline entries with [UNRESOLVED] or [DISCARDED] - and include Why unresolved: or Why discarded:. + as separate headings. Identify C1 explicitly in each applicable section, and write + only None. in any section that does not apply to C1. + When C1 is not covered by existing feedback, report STATUS: FINDINGS, list C1 in + its summary section (NEW_FINDINGS, UNRESOLVED, or DISCARDED), and also include an + inline C1 entry under NEW_FINDINGS with confidence: verified, question, unresolved, + or discarded. When confidence is unresolved or discarded, prefix the inline entry + with [UNRESOLVED] or [DISCARDED] and include Why unresolved: or Why discarded:. + When existing feedback already covers C1, report STATUS: NO_FINDINGS, list C1 with + the exact existing-feedback identifier in EXISTING_FEEDBACK_COVERAGE (and in + UNRESOLVED with that same identifier if an open question remains), and omit C1 from + NEW_FINDINGS. Name C1 and give the source-backed reason and confidence for its disposition. Preserve the claim as written. Do not substitute another effect or remedy. Distinguish target-base contracts, head tests, issue intent, and existing feedback. @@ -163,9 +173,12 @@ stimuli: Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. These are reviewer criteria, not contracts on the older target branch. - If review-pull-request is available, acquire it and read its installed SKILL.md - through the native skill tool or the supplied installed skill path. - Use the verifier and guide-worker instructions referenced by the loaded skill. + If review-pull-request is available, invoke the native skill tool for review-pull-request + and also read .github/agents/review-guide-worker.agent.md, + .github/agents/review-candidate-verifier.agent.md, and the installed review-pull-request + SKILL.md path with view in full; those .agent.md files define subordinate worker/verifier + contracts, so adjudicate as the SKILL.md coordinator (mapping verifier external downgrades + and unestablished drops to UNRESOLVED and only source-contradicted drops to DISCARDED). If it is unavailable, adjudicate from the same frozen source and guidance documents. Page truncated input reads through EOF. @@ -180,10 +193,17 @@ stimuli: Give Before and After for C1's exact input and observable outcome after the status line. The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED - as separate headings. Identify C1 explicitly in each applicable section. - Use confidence: verified, question, unresolved, or discarded for an inline entry. - Prefix unresolved or discarded inline entries with [UNRESOLVED] or [DISCARDED] - and include Why unresolved: or Why discarded:. + as separate headings. Identify C1 explicitly in each applicable section, and write + only None. in any section that does not apply to C1. + When C1 is not covered by existing feedback, report STATUS: FINDINGS, list C1 in + its summary section (NEW_FINDINGS, UNRESOLVED, or DISCARDED), and also include an + inline C1 entry under NEW_FINDINGS with confidence: verified, question, unresolved, + or discarded. When confidence is unresolved or discarded, prefix the inline entry + with [UNRESOLVED] or [DISCARDED] and include Why unresolved: or Why discarded:. + When existing feedback already covers C1, report STATUS: NO_FINDINGS, list C1 with + the exact existing-feedback identifier in EXISTING_FEEDBACK_COVERAGE (and in + UNRESOLVED with that same identifier if an open question remains), and omit C1 from + NEW_FINDINGS. Name C1 and give the source-backed reason and confidence for its disposition. Preserve the claim as written. Do not substitute another effect or remedy. Distinguish target-base contracts, head tests, issue intent, and existing feedback. @@ -285,9 +305,12 @@ stimuli: Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. These are reviewer criteria, not contracts on the older target branch. - If review-pull-request is available, acquire it and read its installed SKILL.md - through the native skill tool or the supplied installed skill path. - Use the verifier and guide-worker instructions referenced by the loaded skill. + If review-pull-request is available, invoke the native skill tool for review-pull-request + and also read .github/agents/review-guide-worker.agent.md, + .github/agents/review-candidate-verifier.agent.md, and the installed review-pull-request + SKILL.md path with view in full; those .agent.md files define subordinate worker/verifier + contracts, so adjudicate as the SKILL.md coordinator (mapping verifier external downgrades + and unestablished drops to UNRESOLVED and only source-contradicted drops to DISCARDED). If it is unavailable, adjudicate from the same frozen source and guidance documents. Page truncated input reads through EOF. @@ -302,10 +325,17 @@ stimuli: Give Before and After for C1's exact input and observable outcome after the status line. The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED - as separate headings. Identify C1 explicitly in each applicable section. - Use confidence: verified, question, unresolved, or discarded for an inline entry. - Prefix unresolved or discarded inline entries with [UNRESOLVED] or [DISCARDED] - and include Why unresolved: or Why discarded:. + as separate headings. Identify C1 explicitly in each applicable section, and write + only None. in any section that does not apply to C1. + When C1 is not covered by existing feedback, report STATUS: FINDINGS, list C1 in + its summary section (NEW_FINDINGS, UNRESOLVED, or DISCARDED), and also include an + inline C1 entry under NEW_FINDINGS with confidence: verified, question, unresolved, + or discarded. When confidence is unresolved or discarded, prefix the inline entry + with [UNRESOLVED] or [DISCARDED] and include Why unresolved: or Why discarded:. + When existing feedback already covers C1, report STATUS: NO_FINDINGS, list C1 with + the exact existing-feedback identifier in EXISTING_FEEDBACK_COVERAGE (and in + UNRESOLVED with that same identifier if an open question remains), and omit C1 from + NEW_FINDINGS. Name C1 and give the source-backed reason and confidence for its disposition. Preserve the claim as written. Do not substitute another effect or remedy. Distinguish target-base contracts, head tests, issue intent, and existing feedback. @@ -406,9 +436,12 @@ stimuli: Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. These are reviewer criteria, not contracts on the older target branch. - If review-pull-request is available, acquire it and read its installed SKILL.md - through the native skill tool or the supplied installed skill path. - Use the verifier and guide-worker instructions referenced by the loaded skill. + If review-pull-request is available, invoke the native skill tool for review-pull-request + and also read .github/agents/review-guide-worker.agent.md, + .github/agents/review-candidate-verifier.agent.md, and the installed review-pull-request + SKILL.md path with view in full; those .agent.md files define subordinate worker/verifier + contracts, so adjudicate as the SKILL.md coordinator (mapping verifier external downgrades + and unestablished drops to UNRESOLVED and only source-contradicted drops to DISCARDED). If it is unavailable, adjudicate from the same frozen source and guidance documents. Page truncated input reads through EOF. @@ -423,10 +456,17 @@ stimuli: Give Before and After for C1's exact input and observable outcome after the status line. The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED - as separate headings. Identify C1 explicitly in each applicable section. - Use confidence: verified, question, unresolved, or discarded for an inline entry. - Prefix unresolved or discarded inline entries with [UNRESOLVED] or [DISCARDED] - and include Why unresolved: or Why discarded:. + as separate headings. Identify C1 explicitly in each applicable section, and write + only None. in any section that does not apply to C1. + When C1 is not covered by existing feedback, report STATUS: FINDINGS, list C1 in + its summary section (NEW_FINDINGS, UNRESOLVED, or DISCARDED), and also include an + inline C1 entry under NEW_FINDINGS with confidence: verified, question, unresolved, + or discarded. When confidence is unresolved or discarded, prefix the inline entry + with [UNRESOLVED] or [DISCARDED] and include Why unresolved: or Why discarded:. + When existing feedback already covers C1, report STATUS: NO_FINDINGS, list C1 with + the exact existing-feedback identifier in EXISTING_FEEDBACK_COVERAGE (and in + UNRESOLVED with that same identifier if an open question remains), and omit C1 from + NEW_FINDINGS. Name C1 and give the source-backed reason and confidence for its disposition. Preserve the claim as written. Do not substitute another effect or remedy. Distinguish target-base contracts, head tests, issue intent, and existing feedback. @@ -529,9 +569,12 @@ stimuli: Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. These are reviewer criteria, not contracts on the older target branch. - If review-pull-request is available, acquire it and read its installed SKILL.md - through the native skill tool or the supplied installed skill path. - Use the verifier and guide-worker instructions referenced by the loaded skill. + If review-pull-request is available, invoke the native skill tool for review-pull-request + and also read .github/agents/review-guide-worker.agent.md, + .github/agents/review-candidate-verifier.agent.md, and the installed review-pull-request + SKILL.md path with view in full; those .agent.md files define subordinate worker/verifier + contracts, so adjudicate as the SKILL.md coordinator (mapping verifier external downgrades + and unestablished drops to UNRESOLVED and only source-contradicted drops to DISCARDED). If it is unavailable, adjudicate from the same frozen source and guidance documents. Page truncated input reads through EOF. @@ -546,10 +589,17 @@ stimuli: Give Before and After for C1's exact input and observable outcome after the status line. The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED - as separate headings. Identify C1 explicitly in each applicable section. - Use confidence: verified, question, unresolved, or discarded for an inline entry. - Prefix unresolved or discarded inline entries with [UNRESOLVED] or [DISCARDED] - and include Why unresolved: or Why discarded:. + as separate headings. Identify C1 explicitly in each applicable section, and write + only None. in any section that does not apply to C1. + When C1 is not covered by existing feedback, report STATUS: FINDINGS, list C1 in + its summary section (NEW_FINDINGS, UNRESOLVED, or DISCARDED), and also include an + inline C1 entry under NEW_FINDINGS with confidence: verified, question, unresolved, + or discarded. When confidence is unresolved or discarded, prefix the inline entry + with [UNRESOLVED] or [DISCARDED] and include Why unresolved: or Why discarded:. + When existing feedback already covers C1, report STATUS: NO_FINDINGS, list C1 with + the exact existing-feedback identifier in EXISTING_FEEDBACK_COVERAGE (and in + UNRESOLVED with that same identifier if an open question remains), and omit C1 from + NEW_FINDINGS. Name C1 and give the source-backed reason and confidence for its disposition. Preserve the claim as written. Do not substitute another effect or remedy. Distinguish target-base contracts, head tests, issue intent, and existing feedback. @@ -652,9 +702,12 @@ stimuli: Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. These are reviewer criteria, not contracts on the older target branch. - If review-pull-request is available, acquire it and read its installed SKILL.md - through the native skill tool or the supplied installed skill path. - Use the verifier and guide-worker instructions referenced by the loaded skill. + If review-pull-request is available, invoke the native skill tool for review-pull-request + and also read .github/agents/review-guide-worker.agent.md, + .github/agents/review-candidate-verifier.agent.md, and the installed review-pull-request + SKILL.md path with view in full; those .agent.md files define subordinate worker/verifier + contracts, so adjudicate as the SKILL.md coordinator (mapping verifier external downgrades + and unestablished drops to UNRESOLVED and only source-contradicted drops to DISCARDED). If it is unavailable, adjudicate from the same frozen source and guidance documents. Page truncated input reads through EOF. @@ -669,10 +722,17 @@ stimuli: Give Before and After for C1's exact input and observable outcome after the status line. The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED - as separate headings. Identify C1 explicitly in each applicable section. - Use confidence: verified, question, unresolved, or discarded for an inline entry. - Prefix unresolved or discarded inline entries with [UNRESOLVED] or [DISCARDED] - and include Why unresolved: or Why discarded:. + as separate headings. Identify C1 explicitly in each applicable section, and write + only None. in any section that does not apply to C1. + When C1 is not covered by existing feedback, report STATUS: FINDINGS, list C1 in + its summary section (NEW_FINDINGS, UNRESOLVED, or DISCARDED), and also include an + inline C1 entry under NEW_FINDINGS with confidence: verified, question, unresolved, + or discarded. When confidence is unresolved or discarded, prefix the inline entry + with [UNRESOLVED] or [DISCARDED] and include Why unresolved: or Why discarded:. + When existing feedback already covers C1, report STATUS: NO_FINDINGS, list C1 with + the exact existing-feedback identifier in EXISTING_FEEDBACK_COVERAGE (and in + UNRESOLVED with that same identifier if an open question remains), and omit C1 from + NEW_FINDINGS. Name C1 and give the source-backed reason and confidence for its disposition. Preserve the claim as written. Do not substitute another effect or remedy. Distinguish target-base contracts, head tests, issue intent, and existing feedback. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-06/provenance.json b/eng/skill-evals/review-pull-request/fixtures/case-06/provenance.json index 2fddc4ea662d..11065f8ff1be 100644 --- a/eng/skill-evals/review-pull-request/fixtures/case-06/provenance.json +++ b/eng/skill-evals/review-pull-request/fixtures/case-06/provenance.json @@ -4,7 +4,7 @@ "fixtureKind": "synthetic public catch-policy example, not framework production source", "revision": "4bb1a49fbbf7c217286f289cf975019491c83f16", "transformations": [ - "Remove explicit suppression-policy absence hints.", + "Normalize scenario prompt to the single-candidate format.", "Combine scenario and head test as context." ], "files": [ diff --git a/eng/skill-evals/run.ps1 b/eng/skill-evals/run.ps1 index 9ca709f96e19..d359390f1462 100644 --- a/eng/skill-evals/run.ps1 +++ b/eng/skill-evals/run.ps1 @@ -328,7 +328,7 @@ switch ($Action) { & (Join-Path $PSScriptRoot 'test_assert_results.ps1') & (Join-Path $PSScriptRoot 'test_stage_run.ps1') & (Join-Path $PSScriptRoot 'test_workflow.ps1') - if (-not $Suite -or $Suite -eq 'review-pull-request') { + if (-not $Suite -or $Suite -in @('review-pull-request', 'review-candidate-verifier')) { & (Join-Path $PSScriptRoot 'tests/test_review_fixtures.ps1') } if (Test-Path (Join-Path $PSScriptRoot 'test_disposition.mjs')) { diff --git a/eng/skill-evals/test_assert_results.ps1 b/eng/skill-evals/test_assert_results.ps1 index 74155c044603..fda97889f56f 100644 --- a/eng/skill-evals/test_assert_results.ps1 +++ b/eng/skill-evals/test_assert_results.ps1 @@ -122,7 +122,96 @@ try { Write-Results -Variant skilled -Score 0.5 Assert-Throws { & $assertResults -OutputDirectory $output - } "'skilled' stimulus 'case-01' score 0.5 is below" 'A below-threshold skilled result was accepted.' + } "'skilled' score 0.5 is below" 'A below-threshold skilled result was accepted.' + + @{ + type = 'experiment-plan-snapshot' + evals = @( + @{ + evalName = 'port-components-platform-api' + variant = 'baseline' + plannedStimulusCount = 2 + plannedStimulusNames = @('case-01', 'case-02') + runs = 1 + threshold = 0.6 + }, + @{ + evalName = 'port-components-platform-api' + variant = 'skilled' + plannedStimulusCount = 2 + plannedStimulusNames = @('case-01', 'case-02') + runs = 1 + threshold = 0.6 + } + ) + } | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $run 'plan-snapshot.json') + + Reset-Results + foreach ($variant in 'baseline', 'skilled') { + $variantDirectory = Join-Path $run $variant + New-Item -ItemType Directory -Path $variantDirectory -Force | Out-Null + @( + @{ + type = 'trial-result' + variant = $variant + stimulus = 'case-01' + status = 'success' + gradeResult = @{ score = $(if ($variant -eq 'skilled') { 0.4 } else { 0.1 }) } + }, + @{ + type = 'trial-result' + variant = $variant + stimulus = 'case-02' + status = 'success' + gradeResult = @{ score = $(if ($variant -eq 'skilled') { 1.0 } else { 0.1 }) } + } + ) | ForEach-Object { $_ | ConvertTo-Json -Depth 10 -Compress } | + Set-Content (Join-Path $variantDirectory 'results.jsonl') + } + & $assertResults -OutputDirectory $output + + @( + @{ + type = 'trial-result' + variant = 'skilled' + stimulus = 'case-01' + status = 'success' + gradeResult = @{ score = 0.2 } + }, + @{ + type = 'trial-result' + variant = 'skilled' + stimulus = 'case-02' + status = 'success' + gradeResult = @{ score = 0.8 } + } + ) | ForEach-Object { $_ | ConvertTo-Json -Depth 10 -Compress } | + Set-Content (Join-Path $run 'skilled/results.jsonl') + Assert-Throws { + & $assertResults -OutputDirectory $output + } "'skilled' score 0.5 is below threshold 0.6" ( + 'A multi-stimulus generic suite below its aggregate threshold was accepted.' + ) + + @{ + type = 'experiment-plan-snapshot' + evals = @( + @{ + variant = 'baseline' + plannedStimulusCount = 1 + plannedStimulusNames = @('case-01') + runs = 1 + threshold = 0.6 + }, + @{ + variant = 'skilled' + plannedStimulusCount = 1 + plannedStimulusNames = @('case-01') + runs = 1 + threshold = 0.6 + } + ) + } | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $run 'plan-snapshot.json') Reset-Results Write-Results -Variant baseline -Score 0.1 @@ -323,6 +412,16 @@ try { passed = $true score = 1 } + @{ + graderType = 'skill-invocation' + passed = $variant -eq 'skilled' + score = $(if ($variant -eq 'skilled') { 1 } else { 0 }) + } + @{ + graderType = 'prompt' + passed = $true + score = 1 + } ) & $Mutation $variant $receipts Write-Results -Variant $variant -Score 1 -Details $receipts @@ -336,7 +435,7 @@ try { Write-ReviewResults { param($variant, $receipts) if ($variant -eq $variantToFail) { - ($receipts | Where-Object configuredName -eq "$receiptToFail-case-01").passed = $false + ($receipts | Where-Object { $_['configuredName'] -eq "$receiptToFail-case-01" }).passed = $false } } Assert-Throws { & $assertResults -OutputDirectory $output } 'failed read integrity' ( @@ -347,13 +446,116 @@ try { Write-ReviewResults { param($variant, $receipts) if ($variant -eq 'skilled') { - ($receipts | Where-Object configuredName -eq 'treatment-reads-case-01').passed = $false + ($receipts | Where-Object { $_['configuredName'] -eq 'treatment-reads-case-01' }).passed = $false } } Assert-Throws { & $assertResults -OutputDirectory $output } 'treatment-reads-case-01' ( 'Skilled accepted missing treatment integrity.' ) + # 1-run review smoke allows disposition 0 when read integrity passes + Write-ReviewResults { + param($variant, $receipts) + if ($variant -eq 'skilled') { + ($receipts | Where-Object { $_['configuredName'] -eq 'disposition-case-01' }).passed = $false + ($receipts | Where-Object { $_['configuredName'] -eq 'disposition-case-01' }).score = 0 + } + } + Write-Results -Variant skilled -Score 0 -Details @( + @{ configuredName = 'evidence-reads-case-01'; passed = $true; score = 1 }, + @{ configuredName = 'guidance-reads-case-01'; passed = $true; score = 1 }, + @{ configuredName = 'treatment-reads-case-01'; passed = $true; score = 1 }, + @{ configuredName = 'disposition-case-01'; passed = $false; score = 0 } + ) + & $assertResults -OutputDirectory $output + + # Multi-run review enforces per-stimulus threshold independently + @{ + evals = @( + foreach ($variant in 'baseline', 'skilled') { + @{ + evalName = 'review-pull-request' + variant = $variant + plannedStimulusNames = @('case-01', 'case-02') + plannedStimulusCount = 2 + runs = 2 + threshold = 1 + } + } + ) + } | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $run 'plan-snapshot.json') + foreach ($variant in 'baseline', 'skilled') { + $rows = [Collections.Generic.List[object]]::new() + foreach ($stimulus in 'case-01', 'case-02') { + foreach ($trial in 0..1) { + $score = if ($variant -eq 'skilled' -and $stimulus -eq 'case-02' -and $trial -eq 1) { 0 } else { 1 } + $rows.Add(@{ + type = 'trial-result' + variant = $variant + stimulus = $stimulus + trialIndex = $trial + status = 'success' + gradeResult = @{ + score = $score + details = @( + @{ configuredName = "evidence-reads-$stimulus"; passed = $true; score = 1 }, + @{ configuredName = "guidance-reads-$stimulus"; passed = $true; score = 1 }, + @{ + configuredName = "treatment-reads-$stimulus" + passed = $variant -eq 'skilled' + score = $(if ($variant -eq 'skilled') { 1 } else { 0 }) + }, + @{ configuredName = "disposition-$stimulus"; passed = $score -eq 1; score = $score } + ) + } + }) + } + } + $rows | ForEach-Object { $_ | ConvertTo-Json -Depth 10 -Compress } | + Set-Content (Join-Path $run "$variant/results.jsonl") + } + Assert-Throws { & $assertResults -OutputDirectory $output } "'skilled' stimulus 'case-02' score 0.5 is below threshold 1" ( + 'A multi-run review suite with a below-threshold stimulus was accepted.' + ) + + # 1-run verifier component smoke enforces read integrity without multi-trial 4/5 floor + Reset-Results + @{ + evals = @(@{ + variant = 'current' + plannedStimulusNames = @('a', 'b', 'c') + plannedStimulusCount = 3 + runs = 1 + threshold = 0.8 + }) + } | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $run 'plan-snapshot.json') + $smokeComponentRows = [Collections.Generic.List[object]]::new() + foreach ($name in 'a', 'b', 'c') { + $score = if ($name -eq 'a') { 0 } else { 1 } + $smokeComponentRows.Add(@{ + type = 'trial-result' + runId = 'component-smoke' + stimulus = $name + trialIndex = 0 + status = 'success' + gradeResult = @{ + score = $score + details = @( + @{ configuredName = "evidence-reads-$name"; passed = $true; score = 1 }, + @{ configuredName = "disposition-$name"; passed = $score -eq 1; score = $score } + ) + } + }) + } + $smokeComponentRows.Add(@{ + type = 'run-summary' + runId = 'component-smoke' + hadExecutionErrors = $false + }) + $smokeComponentRows | ForEach-Object { $_ | ConvertTo-Json -Depth 10 -Compress } | + Set-Content (Join-Path $run 'results.jsonl') + & $assertResults -OutputDirectory $output + Write-ReviewResults $combinedOutput = Join-Path $testRoot 'combined' New-Item -ItemType Directory -Path $combinedOutput | Out-Null diff --git a/eng/skill-evals/test_disposition.mjs b/eng/skill-evals/test_disposition.mjs index ab07ef22910c..37bcf46620c3 100644 --- a/eng/skill-evals/test_disposition.mjs +++ b/eng/skill-evals/test_disposition.mjs @@ -39,6 +39,50 @@ test('ReviewDispositionAcceptsExpectedSections', () => } }); +test('ReviewDispositionToleratesMarkdownFormattingAndTrailingTopLevelFields', () => +{ + assert.equal(score('case-02', `STATUS: FINDINGS +__NEW_FINDINGS__ +- C1 confidence: \`verified\` +1. **EXISTING_FEEDBACK_COVERAGE**: +None. +2) \`UNRESOLVED\`: +None. +### __DISCARDED__: +None. +TEST_BOUNDARY: Single-reviewer offline source-only evaluation of C1. +**LIMITATIONS:** C1 was evaluated against frozen excerpts only.`), 1); + + assert.equal(score('case-02', `STATUS: FINDINGS +## **NEW_FINDINGS** +C1 **confidence:** verified +## EXISTING_FEEDBACK_COVERAGE +None. +## UNRESOLVED +None. +## DISCARDED +None. +## TEST_BOUNDARY +C1 was evaluated without running target tests. +## LIMITATIONS +C1 uses frozen excerpts.`), 1); + + assert.equal(score('case-06', 'STATUS: FINDINGS \n' + `- __NEW_FINDINGS__: +- **C1 — [UNRESOLVED] Suppressing the diagnostic sink exception changes caller propagation.** + - **Confidence:** unresolved + - **Why unresolved:** missing target-base policy contract. +- **EXISTING_FEEDBACK_COVERAGE**: +- **C1:** Not covered by any existing feedback in the supplied frozen evidence. +- \`UNRESOLVED\`: +**C1:** Missing target-base policy contract. +- __DISCARDED__: +None. **C1 is unresolved rather than discarded.** +TEST_BOUNDARY +Offline review of C1 only. +LIMITATIONS +C1 has no runtime repro.`), 1); +}); + test('ReviewDispositionRejectsWrongStatusSectionConfidenceAndOmission', () => { const good = review('UNRESOLVED', 'unresolved'); diff --git a/eng/skill-evals/test_workflow.ps1 b/eng/skill-evals/test_workflow.ps1 index 8e085cc79105..c1dbc0b2fc7a 100644 --- a/eng/skill-evals/test_workflow.ps1 +++ b/eng/skill-evals/test_workflow.ps1 @@ -73,6 +73,21 @@ if ($workflow -notmatch [regex]::Escape( throw 'The credentialed job does not install the trusted evaluation tool manifest.' } +$validateJob = [regex]::Match( + $workflow, + '(?ms)^ validate:\r?\n(?.*?)(?=^ \S|\z)' +) +if (-not $validateJob.Success) { + throw 'The workflow does not contain the validate job.' +} +$validateJobText = $validateJob.Groups['job'].Value +if ($validateJobText -notmatch '(?ms)if:\s*github\.event_name != ''workflow_dispatch'' \|\| inputs\.action == ''Validate''\r?\n\s*shell:\s*pwsh\r?\n\s*run:\s*\./eng/skill-evals/run\.ps1 -Action Test') { + throw 'The validate job does not run ./eng/skill-evals/run.ps1 -Action Test under the Validate condition.' +} +if ($workflow -match 'test_stage_run\.ps1') { + throw 'The workflow still contains a standalone test_stage_run.ps1 step.' +} + $evaluationToolsRoot = Join-Path $PSScriptRoot 'evaluation-tools' $evaluationToolsManifest = Get-Content ( Join-Path $evaluationToolsRoot 'package.json' diff --git a/eng/skill-evals/tests/test_review_fixtures.ps1 b/eng/skill-evals/tests/test_review_fixtures.ps1 index 2f9ab4ee325f..b89a0257d643 100644 --- a/eng/skill-evals/tests/test_review_fixtures.ps1 +++ b/eng/skill-evals/tests/test_review_fixtures.ps1 @@ -62,10 +62,12 @@ foreach ($stimulus in $spec.stimuli) { ) 'A frozen source role is missing.' } else { Assert-True ($provenance.fixtureKind -like 'synthetic public*') 'The catch example is misrepresented as production source.' - $context = Get-Content (Join-Path $caseRoot 'context.source') -Raw - Assert-True ($context -notmatch 'No target-base policy|No additional primary contract|unspecified\.txt') ( - 'The catch case includes an answer hint.' - ) + foreach ($caseFile in Get-ChildItem $caseRoot -File) { + $text = Get-Content $caseFile.FullName -Raw + Assert-True ( + $text -notmatch 'No target-base policy|No additional primary contract|unspecified\.txt|suppression-policy absence' + ) "The catch case file $($caseFile.Name) includes an answer hint." + } } foreach ($file in $provenance.files) { From 4da1cd735d90d8aacaaafe26d6468fa1854de28d Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Thu, 12 Nov 2026 13:13:07 -0600 Subject: [PATCH 06/23] Update case-04 to DISCARDED and fix subheading grading and component output dir discovery Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/README.md | 5 +++-- eng/skill-evals/grade_disposition.mjs | 4 ++-- .../review-pull-request/eval.vally.yaml | 21 ++++++++++--------- eng/skill-evals/run.ps1 | 11 +++++++++- eng/skill-evals/test_disposition.mjs | 15 +++++++++++-- eng/skill-evals/test_run.ps1 | 1 + 6 files changed, 40 insertions(+), 17 deletions(-) diff --git a/eng/skill-evals/README.md b/eng/skill-evals/README.md index a7c8e0e490d5..f79207fc4654 100644 --- a/eng/skill-evals/README.md +++ b/eng/skill-evals/README.md @@ -25,8 +25,9 @@ directories. A runtime skill may use a `fixtures` directory for non-eval assets. The standard `review-pull-request` suite uses frozen source and diff excerpts from ASP.NET Core PRs #70106, #69782, #70304, #69721, and #70299. These cover exact-input old/head comparison, constructor mapping versus a lower-layer head test, renderer -disposal and issue intent, an unproven external browser-test path, and existing -feedback on render-mode-dependent navigation. Each case carries its source roles, +disposal and issue intent, a browser-test wrapper ordering that contradicts a +claimed token-exchange dependency, and existing feedback on render-mode-dependent +navigation. Each case carries its source roles, Git blob identities, original line ranges, and fixture SHA-256 hashes in `provenance.json`. Issue and feedback excerpts identify their captured public revision metadata. Neutral stimulus names and destination paths do not encode diff --git a/eng/skill-evals/grade_disposition.mjs b/eng/skill-evals/grade_disposition.mjs index c1ef79e2ca79..ff2e680f0c7a 100644 --- a/eng/skill-evals/grade_disposition.mjs +++ b/eng/skill-evals/grade_disposition.mjs @@ -8,7 +8,7 @@ const reviewCases = { 'case-01': { section: 'DISCARDED', confidence: 'discarded' }, 'case-02': { section: 'NEW_FINDINGS', confidence: 'verified' }, 'case-03': { section: 'DISCARDED', confidence: 'discarded' }, - 'case-04': { section: 'UNRESOLVED', confidence: 'unresolved' }, + 'case-04': { section: 'DISCARDED', confidence: 'discarded' }, 'case-05': { section: 'EXISTING_FEEDBACK_COVERAGE', thread: 'discussion_r4487936812' }, 'case-06': { section: 'UNRESOLVED', confidence: 'unresolved' }, }; @@ -144,7 +144,7 @@ function gradeReview(name, output) section = heading; sections.set(section, ''); } - else if (/^#{1,6}\s+/.test(line.trim()) || topLevelFields.includes(fieldName)) + else if (topLevelFields.includes(fieldName) || (/^#{1,6}\s+/.test(line.trim()) && !/\bC1\b/.test(heading))) { section = undefined; } diff --git a/eng/skill-evals/review-pull-request/eval.vally.yaml b/eng/skill-evals/review-pull-request/eval.vally.yaml index a7eb2f589161..0234140909b0 100644 --- a/eng/skill-evals/review-pull-request/eval.vally.yaml +++ b/eng/skill-evals/review-pull-request/eval.vally.yaml @@ -547,17 +547,18 @@ stimuli: result: Keep diagnostics actionable but not noisy rubric: - All criteria are mandatory. C1 asserts that the new test server token endpoint changes the browser regression's - observable success. Do not treat a directly callable endpoint as evidence that this browser scenario calls it. + observable success because the scenario completes a token exchange through that endpoint before its assertions. + Do not treat a directly callable endpoint as evidence that this browser scenario calls it before asserting. - Inspect the copied token endpoint at mergeBase and head, the MSAL app configuration, the real signIn wrapper, - and NavigateDirectlyToLoginCallbackRestartsLoginWithoutInteropFailure. The browser test checks the signIn flag - and absence of an interop error, not a token response or code-rejection outcome. - - Trace the in-repository boundary into @azure/msal-browser and name the missing version-specific - redirect/discovery/token-exchange implementation or recorded request trace needed to establish that this - endpoint is reached before the test asserts. - - Keep the asserted browser effect UNRESOLVED with that precise missing evidence. A well-formed inline - [UNRESOLVED] entry is allowed. Do not promote an endpoint-local observation into a proven regression-test - failure, invent external requests, or claim that copied code alone proves identical behavior for the newly - configured app. + and NavigateDirectlyToLoginCallbackRestartsLoginWithoutInteropFailure. + - Trace the exact test execution order across RemoteMsalAuthenticationTest.cs and + RemoteMsalAuthenticationApp.razor. Direct navigation to /subdir/msal-authentication/login-callback carries no + authorization code, and the wrapper in RemoteMsalAuthenticationApp.razor sets window.__msalSignInCalled = true + before delegating to AuthenticationService.signIn(state). + - Because the test assertions run as soon as window.__msalSignInCalled is true and only check the browser log for + the interop failure without awaiting any token exchange, C1's causal premise is contradicted by the frozen + source. Place C1 in DISCARDED and surface it inline under NEW_FINDINGS with [DISCARDED], confidence discarded, + and Why discarded. - Do not substitute a different endpoint correctness claim or remedy for C1's asserted browser effect. - name: case-05 prompt: | diff --git a/eng/skill-evals/run.ps1 b/eng/skill-evals/run.ps1 index d359390f1462..0b2eabf72255 100644 --- a/eng/skill-evals/run.ps1 +++ b/eng/skill-evals/run.ps1 @@ -408,13 +408,22 @@ switch ($Action) { } $vallyArguments += $Arguments + $existingRunDirectoryNames = [Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal) + if ($selectedSuite -eq 'review-candidate-verifier' -and (Test-Path $output -PathType Container)) { + foreach ($directory in Get-ChildItem $output -Directory -ErrorAction SilentlyContinue) { + [void]$existingRunDirectoryNames.Add($directory.Name) + } + } $invocationCompleted = $false try { Invoke-VallyIsolated $vallyArguments $invocationCompleted = $true } finally { if ($selectedSuite -eq 'review-candidate-verifier') { - $runDirectories = @(Get-ChildItem $output -Directory -ErrorAction SilentlyContinue) + $runDirectories = @( + Get-ChildItem $output -Directory -ErrorAction SilentlyContinue | + Where-Object { -not $existingRunDirectoryNames.Contains($_.Name) } + ) if ($runDirectories.Count -eq 1 -and (Test-Path (Join-Path $runDirectories[0].FullName 'results.jsonl'))) { @{ diff --git a/eng/skill-evals/test_disposition.mjs b/eng/skill-evals/test_disposition.mjs index 37bcf46620c3..17d079462e88 100644 --- a/eng/skill-evals/test_disposition.mjs +++ b/eng/skill-evals/test_disposition.mjs @@ -27,13 +27,13 @@ test('ReviewDispositionAcceptsExpectedSections', () => ['case-01', 'DISCARDED', 'discarded'], ['case-02', 'NEW_FINDINGS', 'verified'], ['case-03', 'DISCARDED', 'discarded'], - ['case-04', 'UNRESOLVED', 'unresolved'], + ['case-04', 'DISCARDED', 'discarded'], ['case-06', 'UNRESOLVED', 'unresolved'], ]) { assert.equal(score(name, review(section, confidence)), 1, name); } - for (const name of ['case-01', 'case-03']) + for (const name of ['case-01', 'case-03', 'case-04']) { assert.equal(score(name, review('DISCARDED', 'discarded', false)), 0, name); } @@ -67,6 +67,17 @@ C1 was evaluated without running target tests. ## LIMITATIONS C1 uses frozen excerpts.`), 1); + assert.equal(score('case-02', `STATUS: FINDINGS +## NEW_FINDINGS +### C1: Request body is read without cancellation +confidence: verified +## EXISTING_FEEDBACK_COVERAGE +None. +## UNRESOLVED +None. +## DISCARDED +None.`), 1); + assert.equal(score('case-06', 'STATUS: FINDINGS \n' + `- __NEW_FINDINGS__: - **C1 — [UNRESOLVED] Suppressing the diagnostic sink exception changes caller propagation.** - **Confidence:** unresolved diff --git a/eng/skill-evals/test_run.ps1 b/eng/skill-evals/test_run.ps1 index 09608820a591..e14853568c4d 100644 --- a/eng/skill-evals/test_run.ps1 +++ b/eng/skill-evals/test_run.ps1 @@ -216,6 +216,7 @@ if ($args[0] -eq 'eval' -and ($args -join ' ') -like '*review-candidate-verifier foreach ($smoke in @($false, $true)) { $componentOutput = Join-Path $testRoot "component-$smoke" + New-Item -ItemType Directory -Path (Join-Path $componentOutput '2025-12-31T00-00-00') -Force | Out-Null $options = @{ Suite = 'review-candidate-verifier'; Vally = $fakeVally; VallyPrefix = @(); OutputDirectory = $componentOutput } if ($smoke) { $options.Experiment = 'eng/skill-evals/skills-smoke.experiment.yaml' From edf19115a81134220659c99a5edaa965f08a95e9 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Thu, 12 Nov 2026 15:30:02 -0600 Subject: [PATCH 07/23] Document review fixture purpose and scope Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/README.md | 93 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/eng/skill-evals/README.md b/eng/skill-evals/README.md index 671246e47344..e835006bf7e5 100644 --- a/eng/skill-evals/README.md +++ b/eng/skill-evals/README.md @@ -103,6 +103,99 @@ The component suite has 15 trials. The dotnet/skills quality gate uses five tria which a clean sweep can support a one-sided sign test at 5%; enforcing a trial-count policy here remains a documented follow-up. +## Fixture purpose and file scope + +These fixtures are curated slices, not output from the production bundle builder. +Production supplies full SHA-keyed source trees and the complete PR diff. +Verifier cases a and b supply nine C# files at each of head and merge base, +plus base-tip docs, rather than full trees. +Their diff covers only `AgentContext.cs`, although the snapshots also contain +changes to `UIAgent.cs` and `UIAgentLog.cs`. +L1 `case-02` supplies the `FileConverter.cs` diff from a six-file PR. +The results provide regression evidence for these supplied slices. +They do not establish production-bundle fidelity or end-to-end review quality. + +### Verifier cases + +Paths in this table are relative to +`review-candidate-verifier\fixtures`. Cases a and b share the C# slice. +Case b adds one synthetic contract. Case c uses separate JavaScript evidence. +The eval stages each case's index, candidate, diff, and changed-file list under +the same destination names. A file at the fixture root is not necessarily shared. + +| Case | Purpose | Expected answer | +|---|---|---| +| `a` | Catch-policy claim without an established secondary-failure propagation rule. | `DROP(unestablished)`, `links.contract: null` | +| `b` | Same claim with an assigned synthetic propagation rule. | `KEEP` | +| `c` | Swallowed callback failure leaves status in `Running` and skips notification. | `KEEP` | + +| Fixture file or path | Cases | Purpose | +|---|---|---| +| `.gitattributes` | a, b, c (checkout only) | Preserve frozen bytes and line endings. | +| `candidate.json` | a, b | Shared catch-policy candidate. | +| `changes.diff` | a, b | Shared `AgentContext.cs` change. | +| `changed-files.json` | a, b | Metadata for that one-file diff. | +| `package-a\bundle-index.json` | a | Source roots, revision IDs, and assigned evidence paths. | +| `package-b\bundle-index.json` | b | Same index scope, plus the synthetic propagation contract. | +| `contracts\api-behavior.txt` | b only | Synthetic rule requiring secondary failures to propagate. | +| `package-c\bundle-index.json` | c | Synthetic source hashes, evidence paths, and observation hash. | +| `package-c\candidate.json` | c | Callback-failure candidate. | +| `package-c\changes.diff` | c | Synthetic JavaScript change. | +| `package-c\changed-files.json` | c | Metadata for that JavaScript diff. | +| `observations.json` | c only | Immutable callback-failure observation. | +| `source\baseTip\docs\CrossCuttingGuidance.md` | a, b, c | Frozen base-tip catch guidance. | +| `source\head\src\Engine\Conversation.mjs` | c | Synthetic head implementation. | +| `source\mergeBase\src\Engine\Conversation.mjs` | c | Synthetic earlier implementation. | + +The following nine files appear under +`source\head\src\Components\AI\src` and +`source\mergeBase\src\Components\AI\src`. +Both cases a and b receive all nine files at both revisions. + +| C# file relative to either source directory | Cases | Purpose | +|---|---|---| +| `Engine\AgentContext.cs` | a, b | Primary catch site, streaming, and status callbacks. | +| `Engine\UIAgent.cs` | a, b | Message producer and logging call forwarded by the catch site. | +| `Engine\UIAgentLog.cs` | a, b | Logger-generated method declarations. | +| `Pipeline\BlockMappingPipeline.cs` | a, b | Streaming block processing and finalization. | +| `Blocks\ContentBlock.cs` | a, b | Block base type and change subscriptions. | +| `Blocks\IInteractiveBlock.cs` | a, b | Interactive-block contract. | +| `Components\MessageInput.cs` | a, b | UI submission caller context. | +| `Engine\ConversationStatus.cs` | a, b | Status values used by the stream and callbacks. | +| `Engine\ConversationTurn.cs` | a, b | Request and response block storage. | + +### Reviewer cases + +Each folder under `review-pull-request\fixtures` contains the same seven filenames. +The eval stages only the selected folder for each trial. +All expected answers below remain provisional, pending an independent two-reviewer audit. + +| Folder and stimulus | Purpose | Provisional expected answer | +|---|---|---| +| `case-01` | Stale-token claim during an authentication-state change. | `DISCARDED` | +| `case-02` | Unmatched constructor file parameter compared with a lower-layer head test. | Verified finding | +| `case-03` | ErrorBoundary delivery after renderer disposal, with issue intent. | `DISCARDED` | +| `case-04` | Browser-test dependency on token exchange before assertions. | `DISCARDED` (disputed) | +| `case-05` | Navigation-ordering question already raised in existing feedback. | `EXISTING_FEEDBACK_COVERAGE` with an unresolved thread reference | +| `case-06` | Unestablished secondary-failure policy after status notification. | `UNRESOLVED` (fixture-confound corrected) | + +| File relative to each case folder | Cases | Purpose | +|---|---|---| +| `case.source` | case-01 through case-06 | Candidate claim and saved PR rationale. | +| `change.diff` | case-01 through case-06 | Selected change to adjudicate. | +| `mergeBase.source` | case-01 through case-06 | Earlier source for comparison. | +| `head.source` | case-01 through case-06 | Proposed source. | +| `baseTip.source` | case-01 through case-06 | Base-tip source context. | +| `context.source` | case-01 through case-06 | Supporting head tests, issue intent, or feedback for that case. | +| `provenance.json` | case-01 through case-06 | Source roles, revisions, line ranges, and fixture hashes. | + +The reviewer fixture root's `.gitattributes` preserves frozen bytes for all six cases. +The `.source` extension marks inert, role-tagged excerpts, which can concatenate +non-compilable snippets. The production exporter also uses `.source` for frozen files. +Both reviewer arms receive the repository's two guidance documents. +Only the skilled arm receives the skill and worker/verifier profiles. +These shared instructions sit outside the per-case fixture folders. + ## Local entry point Run these commands from any directory: From 2d4129cb2566ffcd586a60ddcc8d0666d2a1546b Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Thu, 12 Nov 2026 17:10:44 -0600 Subject: [PATCH 08/23] Move the reviewer L1 suite to a follow-up PR Keep the reviewer behavior changes, the shared evaluation harness, and the review-candidate-verifier component suite in this PR. Move the standard review-pull-request suite, its six case fixtures, and the reviewer experiments to a stacked follow-up PR. Restore the specialized catch-policy suite and fixtures from main. The follow-up PR retires them again when it adds case-06. Remove the review-pull-request dispatch option and the L1-only self-test assertions. The L2 execution-path files are byte-identical to the previous head. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/skill-evals.yml | 1 - eng/skill-evals/README.md | 123 +- .../catch-policy.vally.yaml | 152 ++ .../review-pull-request/eval.vally.yaml | 867 ---------- .../fixtures/.gitattributes | 5 - .../fixtures/case-01/baseTip.source | 137 -- .../fixtures/case-01/case.source | 8 - .../fixtures/case-01/change.diff | 61 - .../fixtures/case-01/context.source | 66 - .../fixtures/case-01/head.source | 150 -- .../fixtures/case-01/mergeBase.source | 137 -- .../fixtures/case-01/provenance.json | 103 -- .../fixtures/case-02/baseTip.source | 1538 ----------------- .../fixtures/case-02/case.source | 8 - .../fixtures/case-02/change.diff | 34 - .../fixtures/case-02/context.source | 19 - .../fixtures/case-02/head.source | 91 - .../fixtures/case-02/mergeBase.source | 88 - .../fixtures/case-02/provenance.json | 151 -- .../fixtures/case-03/baseTip.source | 127 -- .../fixtures/case-03/case.source | 8 - .../fixtures/case-03/change.diff | 20 - .../fixtures/case-03/context.source | 116 -- .../fixtures/case-03/head.source | 182 -- .../fixtures/case-03/mergeBase.source | 175 -- .../fixtures/case-03/provenance.json | 131 -- .../fixtures/case-04/baseTip.source | 517 ------ .../fixtures/case-04/case.source | 8 - .../fixtures/case-04/change.diff | 108 -- .../fixtures/case-04/context.source | 164 -- .../fixtures/case-04/head.source | 104 -- .../fixtures/case-04/mergeBase.source | 109 -- .../fixtures/case-04/provenance.json | 131 -- .../fixtures/case-05/baseTip.source | 160 -- .../fixtures/case-05/case.source | 8 - .../fixtures/case-05/change.diff | 83 - .../fixtures/case-05/context.source | 87 - .../fixtures/case-05/head.source | 122 -- .../fixtures/case-05/mergeBase.source | 83 - .../fixtures/case-05/provenance.json | 145 -- .../fixtures/case-06/case.source | 1 - .../fixtures/case-06/context.source | 40 - .../fixtures/case-06/provenance.json | 36 - .../ConversationEngine.diff} | 2 +- .../ConversationEngineTests.cs.source | 21 + .../Dependencies.cs.source} | 0 .../fixtures/catch-policy/best-effort.txt | 20 + .../catch-policy/existing-question.txt | 23 + .../head/ConversationEngine.cs.source} | 2 +- .../fixtures/catch-policy/nonthrowing.txt | 24 + .../old/ConversationEngine.cs.source} | 0 .../fixtures/catch-policy/propagation.txt | 21 + .../fixtures/catch-policy/unspecified.txt | 20 + eng/skill-evals/review-smoke.experiment.yaml | 25 - .../review-vs-baseline.experiment.yaml | 23 - eng/skill-evals/test_run.ps1 | 59 +- .../tests/test_review_fixtures.ps1 | 235 +-- 57 files changed, 313 insertions(+), 6566 deletions(-) create mode 100644 eng/skill-evals/review-pull-request/catch-policy.vally.yaml delete mode 100644 eng/skill-evals/review-pull-request/eval.vally.yaml delete mode 100644 eng/skill-evals/review-pull-request/fixtures/.gitattributes delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/baseTip.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/case.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/change.diff delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/context.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/head.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/mergeBase.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-01/provenance.json delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/baseTip.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/case.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/change.diff delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/context.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/head.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/mergeBase.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-02/provenance.json delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/baseTip.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/case.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/change.diff delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/context.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/head.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/mergeBase.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-03/provenance.json delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/baseTip.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/case.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/change.diff delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/context.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/head.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/mergeBase.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-04/provenance.json delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/baseTip.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/case.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/change.diff delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/context.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/head.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/mergeBase.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-05/provenance.json delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-06/case.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-06/context.source delete mode 100644 eng/skill-evals/review-pull-request/fixtures/case-06/provenance.json rename eng/skill-evals/review-pull-request/fixtures/{case-06/change.diff => catch-policy/ConversationEngine.diff} (100%) create mode 100644 eng/skill-evals/review-pull-request/fixtures/catch-policy/ConversationEngineTests.cs.source rename eng/skill-evals/review-pull-request/fixtures/{case-06/baseTip.source => catch-policy/Dependencies.cs.source} (100%) create mode 100644 eng/skill-evals/review-pull-request/fixtures/catch-policy/best-effort.txt create mode 100644 eng/skill-evals/review-pull-request/fixtures/catch-policy/existing-question.txt rename eng/skill-evals/review-pull-request/fixtures/{case-06/head.source => catch-policy/head/ConversationEngine.cs.source} (100%) create mode 100644 eng/skill-evals/review-pull-request/fixtures/catch-policy/nonthrowing.txt rename eng/skill-evals/review-pull-request/fixtures/{case-06/mergeBase.source => catch-policy/old/ConversationEngine.cs.source} (100%) create mode 100644 eng/skill-evals/review-pull-request/fixtures/catch-policy/propagation.txt create mode 100644 eng/skill-evals/review-pull-request/fixtures/catch-policy/unspecified.txt delete mode 100644 eng/skill-evals/review-smoke.experiment.yaml delete mode 100644 eng/skill-evals/review-vs-baseline.experiment.yaml diff --git a/.github/workflows/skill-evals.yml b/.github/workflows/skill-evals.yml index 04b3c6e1daa8..036d55ce0d3d 100644 --- a/.github/workflows/skill-evals.yml +++ b/.github/workflows/skill-evals.yml @@ -42,7 +42,6 @@ on: - port-components-platform-api - pr-attention-queue - review-public-api - - review-pull-request - review-candidate-verifier - validate-blazor-feature run_type: diff --git a/eng/skill-evals/README.md b/eng/skill-evals/README.md index e835006bf7e5..999570f5fba9 100644 --- a/eng/skill-evals/README.md +++ b/eng/skill-evals/README.md @@ -12,8 +12,7 @@ auto-discovered by this repository's experiment and runner. `skills-vs-baseline.experiment.yaml` runs the generic skill specs twice with the same stimuli: once without a skill and once with exactly `.github/skills/` loaded. The experiment owns `environment.skills`; -standard specs must not set it themselves. Reviewer diagnostic-control runs use -`review-vs-baseline.experiment.yaml` and `review-smoke.experiment.yaml` instead. +standard specs must not set it themselves. The verifier component suite has no skill arm and runs directly. Any other `*.vally.yaml` file is a specialized suite. Specialized suites are not @@ -22,54 +21,24 @@ beside the spec that consumes them, normally under a `fixtures` directory. Do not place eval specs, `evals` directories, or eval runners in runtime skill directories. A runtime skill may use a `fixtures` directory for non-eval assets. -The standard `review-pull-request` suite uses frozen source and diff excerpts from -ASP.NET Core PRs #70106, #69782, #70304, #69721, and #70299. These cover exact-input -old/head comparison, constructor mapping versus a lower-layer head test, renderer -disposal and issue intent, browser-test wrapper ordering in a disputed -token-exchange dependency claim, and existing feedback on render-mode-dependent -navigation. Each case carries its source roles, -Git blob identities, original line ranges, and fixture SHA-256 hashes in -`provenance.json`. Issue and feedback excerpts identify their captured public -revision metadata. Neutral stimulus names and destination paths do not encode -expected dispositions. A sixth case integrates the synthetic public catch-policy -example from #70312. It omits the explicit missing-policy hints and the redundant -existing-question case. It does not represent production framework source. -It replaces the retired standalone catch-policy suite and its duplicate fixtures. -Fixture attributes retain LF and upstream whitespace so Git checkout preserves -the frozen hashes on Windows and Unix. - -These are offline single-context candidate exercises, not full bundle preparation, -guide-worker dispatch, verifier integration, live PR review, or browser tests. -L1 is frozen-evidence adjudication regression, not a measurement of skill lift. -Its baseline is a diagnostic control, not a competitor. Skill lift requires -end-to-end evidence. -All six L1 oracles (`case-01`, `case-02`, `case-03`, `case-04`, `case-05`, and -`case-06`) are provisional pending an independent two-reviewer audit. -The agent-relabelled `DISCARDED` oracle for `case-04` remains disputed, not -independently proven. The `case-06` notification-order confound is corrected, -its `UNRESOLVED` oracle is retained, and cold GPT-5.6 and Opus-5.5 adjudications -agree. That model agreement is not a human audit. -Both arms share frozen source and both guidance documents. Only the skilled arm -receives the skill and verifier/worker instructions. Baseline does not receive -`SKILL.md` or either agent profile. `tool-calls.required` matches both read arguments and -returned bytes, including actual skill text from native acquisition or an installed -file read. A success acknowledgement or a filename citation does not satisfy those -checks. Content signatures prove the specified bytes appeared in a tool result, -not that every possible review path ran. - -Only the deterministic program grader contributes to disposition scores. It checks -the status line, C1's section placement, inline confidence, and existing-thread -deduplication. Skill acquisition, read receipts, and LLM rubrics have zero weight. -The result gate checks evidence/guidance receipts for both arms and skill/profile -receipts for skilled only. A missing baseline skill cannot lower its disposition -score. Each skilled stimulus must independently meet its threshold. Baseline -disposition scores are reported, not threshold-gated. - -The zero-weight LLM rubrics remain secondary diagnostics, not semantic quality -gates. They still incur judge calls during a model-bearing run. The subject and -judge both use `gpt-5.6-sol`; the judge is not independent-model corroboration. -These public development cases are not held-out evidence. Five repeats do not -create five independent PR lineages. +`review-pull-request/catch-policy.vally.yaml` is a specialized, offline policy +exercise. It stages the current reviewer skill, cross-cutting guide, diff, old/head source, +dependency implementations, and one selected scenario into each trial workspace. +Five independent stimuli cover unspecified policy, existing feedback, propagation, +best-effort reporting, and a nonthrowing producer control. The agent must derive the +effect from source rather than receive the expected behavior in its prompt. +Static tool-result checks require the relevant guidance and source to be read; +binary judging checks the reasoning separately. These checks do not prove every +line was read or replace the semantic judge. Five trials per stimulus must all pass. +Platform-required native skill acquisition is allowed, but does not replace reading +the staged guidance or authorize coordinator execution. +The executor and judge models are both pinned to the reviewer skill's supported +`gpt-5.6-sol`. Because they share a model identity, the judge is not independent- +model corroboration. Overrides are separate model-compatibility results, not +evidence that the default reviewer improved. +This does not invoke live PR review or measure baseline-versus-skilled improvement. +Run it explicitly with +`./eng/skill-evals/run.ps1 Run -Eval eng/skill-evals/review-pull-request/catch-policy.vally.yaml --require-pass`. The `review-candidate-verifier` component suite checks normalized `decision` and applicable `downgradeKind`, `dropBasis`, and `contradictedLink` fields. It tolerates @@ -87,10 +56,6 @@ policy-only head-test scenario (close to @maraf's 3/10 `DROP(unestablished)` / 7/10 `DOWNGRADE(intent)` synthetic fixture) was omitted from the component gate; `SKILL.md` retains the coordinator backstop mapping `DOWNGRADE(intent)` with `contract: "n/a"` to `UNRESOLVED`, which has not been measured end to end. -The fresh 30-trial-per-arm L1 regression scored 27/30 for the diagnostic baseline -and 29/30 for skilled. Skilled `case-04` scored 4/5, below its configured 5/5 -gate. Every other skilled case scored 5/5. These results are against the -provisional oracles and do not establish skill lift. Model-free validation checks layout, schema, source hashes, read-guard coverage, and experiment selection. It does not establish adjudication quality. A @@ -98,9 +63,8 @@ model-bearing `Run` and inspection of every trial's actual read receipts and semantic result remain necessary before making a behavioral claim. The experiment deliberately does not override `runs`. A standard spec owns its -trial count through `defaults.runs`. The reviewer suite has 30 trials per arm. -The component suite has 15 trials. The dotnet/skills quality gate uses five trials as the minimum at -which a clean sweep can support a one-sided sign test at 5%; enforcing a +trial count through `defaults.runs`. The component suite has 15 trials. +The dotnet/skills quality gate uses five trials as the minimum at which a clean sweep can support a one-sided sign test at 5%; enforcing a trial-count policy here remains a documented follow-up. ## Fixture purpose and file scope @@ -111,7 +75,6 @@ Verifier cases a and b supply nine C# files at each of head and merge base, plus base-tip docs, rather than full trees. Their diff covers only `AgentContext.cs`, although the snapshots also contain changes to `UIAgent.cs` and `UIAgentLog.cs`. -L1 `case-02` supplies the `FileConverter.cs` diff from a six-file PR. The results provide regression evidence for these supplied slices. They do not establish production-bundle fidelity or end-to-end review quality. @@ -164,38 +127,6 @@ Both cases a and b receive all nine files at both revisions. | `Engine\ConversationStatus.cs` | a, b | Status values used by the stream and callbacks. | | `Engine\ConversationTurn.cs` | a, b | Request and response block storage. | -### Reviewer cases - -Each folder under `review-pull-request\fixtures` contains the same seven filenames. -The eval stages only the selected folder for each trial. -All expected answers below remain provisional, pending an independent two-reviewer audit. - -| Folder and stimulus | Purpose | Provisional expected answer | -|---|---|---| -| `case-01` | Stale-token claim during an authentication-state change. | `DISCARDED` | -| `case-02` | Unmatched constructor file parameter compared with a lower-layer head test. | Verified finding | -| `case-03` | ErrorBoundary delivery after renderer disposal, with issue intent. | `DISCARDED` | -| `case-04` | Browser-test dependency on token exchange before assertions. | `DISCARDED` (disputed) | -| `case-05` | Navigation-ordering question already raised in existing feedback. | `EXISTING_FEEDBACK_COVERAGE` with an unresolved thread reference | -| `case-06` | Unestablished secondary-failure policy after status notification. | `UNRESOLVED` (fixture-confound corrected) | - -| File relative to each case folder | Cases | Purpose | -|---|---|---| -| `case.source` | case-01 through case-06 | Candidate claim and saved PR rationale. | -| `change.diff` | case-01 through case-06 | Selected change to adjudicate. | -| `mergeBase.source` | case-01 through case-06 | Earlier source for comparison. | -| `head.source` | case-01 through case-06 | Proposed source. | -| `baseTip.source` | case-01 through case-06 | Base-tip source context. | -| `context.source` | case-01 through case-06 | Supporting head tests, issue intent, or feedback for that case. | -| `provenance.json` | case-01 through case-06 | Source roles, revisions, line ranges, and fixture hashes. | - -The reviewer fixture root's `.gitattributes` preserves frozen bytes for all six cases. -The `.source` extension marks inert, role-tagged excerpts, which can concatenate -non-compilable snippets. The production exporter also uses `.source` for frozen files. -Both reviewer arms receive the repository's two guidance documents. -Only the skilled arm receives the skill and worker/verifier profiles. -These shared instructions sit outside the per-case fixture folders. - ## Local entry point Run these commands from any directory: @@ -207,11 +138,10 @@ Run these commands from any directory: # Prove every validator rule and runner isolation with self-tests ./eng/skill-evals/run.ps1 Test -# Select this suite for layout, lint, and both experiment dry-runs. -./eng/skill-evals/run.ps1 Validate -Suite review-pull-request +# Select one suite for layout and lint. ./eng/skill-evals/run.ps1 Validate -Suite review-candidate-verifier # Run infrastructure self-tests plus the selected suite's fixture checks. -./eng/skill-evals/run.ps1 Test -Suite review-pull-request +./eng/skill-evals/run.ps1 Test -Suite review-candidate-verifier # The original staging self-test also has this forwarding entry point. ./eng/skill-evals/tests/test_stage_run.ps1 @@ -227,13 +157,12 @@ Run these commands from any directory: ``` Without a suite or explicit experiment, `Run` dispatches each standard suite into -its own output subdirectory. This includes the reviewer diagnostic control and the direct -verifier component suite. `assert_results.ps1` checks that combined output -recursively. An exit code of 1 does not stop dispatch when the complete primary +its own output subdirectory. This includes the direct verifier component suite. +`assert_results.ps1` checks that combined output recursively. An exit code of 1 does not stop dispatch when the complete primary results pass those checks. A direct component run writes a plan beside Vally's timestamped `results.jsonl`; it does not invent an experiment variant directory. That plan reflects the selected YAML and CLI runs/threshold overrides. For the -reviewer and verifier suites, smoke selects one repeat per case and checks trial +verifier suite, smoke selects one repeat per case and checks trial completion, grader scores, and read-integrity receipts without enforcing the multi-trial per-stimulus disposition threshold. diff --git a/eng/skill-evals/review-pull-request/catch-policy.vally.yaml b/eng/skill-evals/review-pull-request/catch-policy.vally.yaml new file mode 100644 index 000000000000..dac0a7c91cb9 --- /dev/null +++ b/eng/skill-evals/review-pull-request/catch-policy.vally.yaml @@ -0,0 +1,152 @@ +name: review-pull-request-catch-policy +description: Independent source-first cases for secondary-failure suppression and deduplication (70269). +type: capability +defaults: + runs: 5 + timeout: 420s + model: gpt-5.6-sol + judge_model: gpt-5.6-sol +agent_environment: + files: + - src: ../../../.github/skills/review-pull-request/SKILL.md + dest: .github/skills/review-pull-request/SKILL.md + - src: ../../../docs/CrossCuttingGuidance.md + dest: docs/CrossCuttingGuidance.md + - src: fixtures/catch-policy/old/ConversationEngine.cs.source + dest: old/ConversationEngine.cs.source + - src: fixtures/catch-policy/head/ConversationEngine.cs.source + dest: head/ConversationEngine.cs.source + - src: fixtures/catch-policy/ConversationEngine.diff + dest: ConversationEngine.diff + - src: fixtures/catch-policy/Dependencies.cs.source + dest: Dependencies.cs.source + - src: fixtures/catch-policy/ConversationEngineTests.cs.source + dest: ConversationEngineTests.cs.source +scoring: + weights: + tool-calls: 0.25 + prompt: 0.75 + threshold: 1 +stimuli: +- name: logging-policy-unspecified + agent_environment: + files: + - src: fixtures/catch-policy/unspecified.txt + dest: case.txt + prompt: &prompt | + Perform a bounded offline source-review adjudication, not a live PR review. + All input paths are relative to your current trial working directory. Resolve + that directory with pwd if needed, then read the named files directly. Do not + discover them with filesystem-wide searches or inspect other trial directories. + Read case.txt, ConversationEngine.diff, both old/head ConversationEngine.cs.source files, and + Dependencies.cs.source and ConversationEngineTests.cs.source. + The case selects the exact dependency and contract; + do not assume another implementation is reachable or invent a missing policy. + The .source files are inert review evidence, not runnable projects. + + Apply .github/skills/review-pull-request/SKILL.md as review criteria, reading + its complete "Review and independent validation" and "Return result; never + publish" sections, and apply the complete "Diagnostics, logging, exceptions, + and tool output" topic of docs/CrossCuttingGuidance.md. Page truncated + sections through their end. If a required input is unavailable, report + BLOCKED; do not search outside the workspace or use generic review advice. + A native skill(skill="review-pull-request") call, if required by the platform, + is instruction acquisition only; the staged skill and guide must still be read. + Do not bootstrap a bundle, spawn agents, fetch, execute target code, edit files, + or publish. This is a single-context policy exercise, not a coordinator run. + + Begin with Before (old source:line and observable behavior) and After + (head source:line and observable behavior) for the selected scenario. + Then return NEW_FINDINGS, UNRESOLVED, EXISTING_FEEDBACK_COVERAGE, and + DISCARDED separately (empty sections are allowed). Trace the selected + producer through its observable effect and name any missing evidence. + Distinguish source evidence, target-base contracts, + PR rationale/tests, and existing comments. No GitHub actions or optional nits. + graders: &graders + - type: tool-calls + config: + required: + - name: .* + pattern: '\.github/skills/review-pull-request/SKILL\.md' + result: 'Deduplication prevents repeat publication' + - name: .* + pattern: 'docs/CrossCuttingGuidance\.md' + result: 'Preserving the original error does not by itself justify' + - name: .* + pattern: 'old/ConversationEngine\.cs\.source' + result: 'StatusChanged' + - name: .* + pattern: 'head/ConversationEngine\.cs\.source' + result: '_sink\.Write' + - name: .* + pattern: 'ConversationEngine\.diff' + result: '\+\s+_sink\.Write' + - name: .* + pattern: 'Dependencies\.cs\.source' + result: 'sealed class RecordingDiagnosticSink' + - name: .* + pattern: 'case\.txt' + result: 'Target-base contract' + - name: .* + pattern: 'ConversationEngineTests\.cs\.source' + result: 'Assert\.Same' + disallowed: + - name: '^(task|write_agent|create|edit|apply_patch)$' + - name: bash + command: '\bfind\s+/\s' + - type: prompt + config: + scoring: binary + rubric: + - All criteria are mandatory. Required staged criteria and source must actually be read; BLOCKED, unavailable-input, generic-advice, or invented-evidence responses fail. Source citations must support the claimed behavior, not merely list filenames. + - Trace FailingClient.ProcessAsync throwing the primary failure, then ThrowingDiagnosticSink.Write throwing a distinct secondary failure into the new inner catch. Explain that the head task completes successfully with Error holding the primary failure and observers notified, while the old code never invoked the sink and therefore did not propagate a sink failure at this seam. + - Retain the concrete changed catch and missing sink-failure handling contract in UNRESOLVED. Do not report a verified defect or intent question. If the unresolved candidate is surfaced inline in NEW_FINDINGS, mark it with unresolved confidence, prefix its claim with [UNRESOLVED], and state the exact missing contract in its Why unresolved field; this preserves the uncertainty without declaring a proven defect. The PR-added test and preservation rationale are implementation intent, not independent policy authority. + - Do not assume every empty catch is a defect or that primary-error preservation justifies losing secondary failures. Do not propose nits, posting, replying, resolving, approving, or requesting changes. +- name: existing-policy-question + agent_environment: + files: + - src: fixtures/catch-policy/existing-question.txt + dest: case.txt + prompt: *prompt + graders: *graders + rubric: + - All criteria are mandatory. Required staged criteria and source must actually be read; BLOCKED, unavailable-input, generic-advice, or invented-evidence responses fail. Source citations must support the claimed behavior, not merely list filenames. + - Trace the selected FailingClient and ThrowingDiagnosticSink through the newly added catch, identifying the distinct primary and secondary failures and the caller-visible successful task completion. Do not claim the old code propagated the secondary failure; the sink call did not exist. + - UNRESOLVED explicitly retains the suppression concern, missing sink-failure contract, and existing thread reference feedback-17, and EXISTING_FEEDBACK_COVERAGE records feedback-17 as already raising this concern. Do not report a verified defect or intent question. Because feedback-17's text raises the same sink-failure suppression, NEW_FINDINGS must not contain that concern under any confidence label, including an [UNRESOLVED] or [DISCARDED] inline entry; any such entry fails even when UNRESOLVED and EXISTING_FEEDBACK_COVERAGE are otherwise correct. Merely putting the thread in EXISTING_FEEDBACK_COVERAGE or deferring to it without retaining the missing contract in UNRESOLVED fails. + - Neither the existing question nor the PR rationale/test is contract authority or proof of resolution. Deduplication prevents repeat publication but does not settle the concern. Do not propose nits, posting, replying, resolving, approving, or requesting changes. +- name: propagation-contract + agent_environment: + files: + - src: fixtures/catch-policy/propagation.txt + dest: case.txt + prompt: *prompt + graders: *graders + rubric: + - All criteria are mandatory. Required staged criteria and source must actually be read; BLOCKED, unavailable-input, generic-advice, or invented-evidence responses fail. Source citations must support the claimed behavior, not merely list filenames. + - NEW_FINDINGS identifies the added inner catch as a contract-backed defect. Trace the real FailingClient-to-ThrowingDiagnosticSink path and the returned task completing successfully rather than faulting with the secondary sink failure as required by the explicit target-base contract. + - Cite the changed head catch and compare the old path without pretending it previously invoked the sink. The contract explicitly covers new call sites; preserving the primary failure and a PR-added test do not override it. + - Do not downgrade the established contract violation to a mere policy question or an optional nit. Do not propose posting, replying, resolving, approving, or requesting changes. +- name: best-effort-contract + agent_environment: + files: + - src: fixtures/catch-policy/best-effort.txt + dest: case.txt + prompt: *prompt + graders: *graders + rubric: + - All criteria are mandatory. Required staged criteria and source must actually be read; BLOCKED, unavailable-input, generic-advice, or invented-evidence responses fail. Source citations must support the claimed behavior, not merely list filenames. + - UNRESOLVED is empty for this suppression concern. DISCARDED explains that the explicit target-base best-effort contract authorizes the changed catch, with the primary error retained and status observers notified when the selected sink throws. Do not report a verified defect, intent question, or unresolved entry. If the discarded candidate is surfaced inline in NEW_FINDINGS, mark it with discarded confidence, prefix its claim with [DISCARDED], and cite the contract in its Why discarded field. + - Distinguish the two failures, trace old/head behavior, and use the explicit contract rather than the PR rationale, primary-error preservation alone, or the new test as authority. Do not demand a second logging call to report a failed logger. + - Do not invent a defect, missing contract, or optional nit merely because the catch is empty. Do not propose posting, replying, resolving, approving, or requesting changes. +- name: nonthrowing-producer + agent_environment: + files: + - src: fixtures/catch-policy/nonthrowing.txt + dest: case.txt + prompt: *prompt + graders: *graders + rubric: + - All criteria are mandatory. Required staged criteria and source must actually be read; BLOCKED, unavailable-input, generic-advice, or invented-evidence responses fail. Source citations must support the claimed behavior, not merely list filenames. + - UNRESOLVED is empty for sink-failure suppression in the bounded scenario. DISCARDED traces RecordingDiagnosticSink.Write, which records the primary exception and returns, so the inner catch is not entered and no secondary sink failure is established. Do not report a verified defect, intent question, or unresolved entry. If this disproven candidate is surfaced inline in NEW_FINDINGS, mark it with discarded confidence, prefix its claim with [DISCARDED], and cite the source line that rules out the secondary failure in its Why discarded field. + - Recognize that ThrowingDiagnosticSink exists in the source but is not selected by this case and cannot be substituted into the producer path. The propagation contract does not create an exception producer. Do not invent unprovided failures such as out-of-memory. + - Compare the old behavior to the head's added diagnostic record while retaining the primary error and notifying observers; do not report the lack of a record on the old side as a new head defect. Do not propose nits or GitHub actions. diff --git a/eng/skill-evals/review-pull-request/eval.vally.yaml b/eng/skill-evals/review-pull-request/eval.vally.yaml deleted file mode 100644 index 156800ea419c..000000000000 --- a/eng/skill-evals/review-pull-request/eval.vally.yaml +++ /dev/null @@ -1,867 +0,0 @@ -name: review-pull-request -description: Frozen ASP.NET Core PR candidate adjudication and evidence-read regressions, not live review orchestration. -type: capability -defaults: - runs: 5 - timeout: 600s - model: gpt-5.6-sol - judge_model: gpt-5.6-sol -agent_environment: - files: - - src: ../../../docs/CrossCuttingGuidance.md - dest: docs/CrossCuttingGuidance.md - - src: ../../../docs/BlazorComponentsGuidance.md - dest: docs/BlazorComponentsGuidance.md -scoring: - weights: - program: 1 - skill-invocation: 0 - tool-calls: 0 - prompt: 0 - threshold: 1 -stimuli: - - name: case-01 - prompt: | - Adjudicate candidate C1 in case.source using only the supplied frozen PR evidence. - Read case.source, provenance.json, change.diff, mergeBase.source, head.source, - baseTip.source, and context.source directly from this trial working directory. - Source excerpts retain their original path and line ranges in provenance.json. - Read every excerpt and the complete diff. Cite original paths, roles, and lines. - - Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. - These are reviewer criteria, not contracts on the older target branch. - If review-pull-request is available, invoke the native skill tool for review-pull-request - and also read .github/agents/review-guide-worker.agent.md, - .github/agents/review-candidate-verifier.agent.md, and the installed review-pull-request - SKILL.md path with view in full; those .agent.md files define subordinate worker/verifier - contracts, so apply SKILL.md's coordinator disposition rules rather than raw subordinate - worker/verifier outputs. - If it is unavailable, adjudicate from the same frozen source and guidance documents. - Page truncated input reads through EOF. - - This is an explicitly configured offline one-pass candidate exercise. - Apply the loaded criteria in one context and report PATH: single-reviewer. - Do not run bundle bootstrap or coordinator/worker orchestration. - The .source and .diff files are inert evidence, not executable projects. - Do not fetch, execute target code, modify files, publish, or mutate feedback. - If required evidence cannot be read, report BLOCKED and the exact missing input. - Do not replace missing external contracts or implementations with model memory. - - Disposition label meanings: - verified: a real defect established by the supplied evidence. - EXISTING_FEEDBACK_COVERAGE: the claim is already raised in existing feedback. - UNRESOLVED: the claim is not resolved by the supplied evidence. - DISCARDED: the claim is ruled out as a material defect by the supplied evidence. - - Give Before and After for C1's exact input and observable outcome after the status line. - The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. - Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED - as separate headings. Identify C1 explicitly in each applicable section, and write - only None. in any section that does not apply to C1. - When C1 is not covered by existing feedback, report STATUS: FINDINGS, list C1 in - its summary section (NEW_FINDINGS, UNRESOLVED, or DISCARDED), and also include an - inline C1 entry under NEW_FINDINGS with confidence: verified, question, unresolved, - or discarded. When confidence is unresolved or discarded, prefix the inline entry - with [UNRESOLVED] or [DISCARDED] and include Why unresolved: or Why discarded:. - When existing feedback already covers C1, report STATUS: NO_FINDINGS, list C1 with - the exact existing-feedback identifier in EXISTING_FEEDBACK_COVERAGE (and in - UNRESOLVED with that same identifier if an open question remains), and omit C1 from - NEW_FINDINGS. - Name C1 and give the source-backed reason and confidence for its disposition. - Preserve the claim as written. Do not substitute another effect or remedy. - Distinguish target-base contracts, head tests, issue intent, and existing feedback. - agent_environment: - files: - - src: fixtures/case-01/case.source - dest: case.source - - src: fixtures/case-01/provenance.json - dest: provenance.json - - src: fixtures/case-01/change.diff - dest: change.diff - - src: fixtures/case-01/mergeBase.source - dest: mergeBase.source - - src: fixtures/case-01/head.source - dest: head.source - - src: fixtures/case-01/baseTip.source - dest: baseTip.source - - src: fixtures/case-01/context.source - dest: context.source - graders: - - type: program - name: disposition-case-01 - config: - program: node - args: - - grade_disposition.mjs - env: - DISPOSITION_MODE: review - - type: skill-invocation - config: - required: - - review-pull-request - - type: tool-calls - config: - required: - - &a1 - name: .* - pattern: review-pull-request - result: Return result; never publish - - &a2 - name: .* - pattern: "[/\\\\]+review-candidate-verifier\\.agent\\.md" - result: validationEvidence - - &a3 - name: .* - pattern: "[/\\\\]+review-guide-worker\\.agent\\.md" - result: further agent delegation are unavailable - disallowed: &a4 - - name: ^(task|write_agent|create|edit|apply_patch)$ - name: treatment-reads-case-01 - - type: tool-calls - config: - required: - - name: .* - pattern: case\.source - result: "C1:" - - name: .* - pattern: provenance\.json - result: sha256 - - name: .* - pattern: change\.diff - result: \+\s+request\.Headers\.Authorization = header; - - name: .* - pattern: mergeBase\.source - result: "Dispose\\(disposing: true\\)" - - name: .* - pattern: head\.source - result: "Dispose\\(disposing: true\\)" - - name: .* - pattern: baseTip\.source - result: "Dispose\\(disposing: true\\)" - - name: .* - pattern: context\.source - result: _response\.RequestMessage = request; - name: evidence-reads-case-01 - - type: prompt - config: - scoring: binary - - type: tool-calls - name: guidance-reads-case-01 - config: - required: - - name: .* - pattern: docs[/\\]+CrossCuttingGuidance\.md - result: Test infrastructure should use shared helpers - - name: .* - pattern: docs[/\\]+BlazorComponentsGuidance\.md - result: Keep diagnostics actionable but not noisy - rubric: - - All criteria are mandatory. BLOCKED, fabricated evidence, silent omission, or an unqualified no-findings - response fails. Citations must support the exact claim. - - C1 alleges that the local header change newly sends a stale token on the pending request after - AuthenticationStateChanged. Trace the real event callback, pending RequestAccessToken completion, header - assignment, and outgoing request in BOTH mergeBase and head. - - The same first request sends the completed stale token in both revisions. Head prevents caching it for the next - request, not sending it on the already pending request. Do not replace C1 with a different caching or - concurrency finding. - - Record C1 in DISCARDED because oldVsNew is contradicted. Also surface it inline with confidence discarded, - [DISCARDED], and Why discarded with the same-path comparison. Do not accept it as verified, question, or - externally unresolved. - - The added head test explicitly expects stale on the first request and fresh on the next. Use source comparison - for the rejection, not the test alone as target contract authority. - - name: case-02 - prompt: | - Adjudicate candidate C1 in case.source using only the supplied frozen PR evidence. - Read case.source, provenance.json, change.diff, mergeBase.source, head.source, - baseTip.source, and context.source directly from this trial working directory. - Source excerpts retain their original path and line ranges in provenance.json. - Read every excerpt and the complete diff. Cite original paths, roles, and lines. - - Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. - These are reviewer criteria, not contracts on the older target branch. - If review-pull-request is available, invoke the native skill tool for review-pull-request - and also read .github/agents/review-guide-worker.agent.md, - .github/agents/review-candidate-verifier.agent.md, and the installed review-pull-request - SKILL.md path with view in full; those .agent.md files define subordinate worker/verifier - contracts, so apply SKILL.md's coordinator disposition rules rather than raw subordinate - worker/verifier outputs. - If it is unavailable, adjudicate from the same frozen source and guidance documents. - Page truncated input reads through EOF. - - This is an explicitly configured offline one-pass candidate exercise. - Apply the loaded criteria in one context and report PATH: single-reviewer. - Do not run bundle bootstrap or coordinator/worker orchestration. - The .source and .diff files are inert evidence, not executable projects. - Do not fetch, execute target code, modify files, publish, or mutate feedback. - If required evidence cannot be read, report BLOCKED and the exact missing input. - Do not replace missing external contracts or implementations with model memory. - - Disposition label meanings: - verified: a real defect established by the supplied evidence. - EXISTING_FEEDBACK_COVERAGE: the claim is already raised in existing feedback. - UNRESOLVED: the claim is not resolved by the supplied evidence. - DISCARDED: the claim is ruled out as a material defect by the supplied evidence. - - Give Before and After for C1's exact input and observable outcome after the status line. - The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. - Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED - as separate headings. Identify C1 explicitly in each applicable section, and write - only None. in any section that does not apply to C1. - When C1 is not covered by existing feedback, report STATUS: FINDINGS, list C1 in - its summary section (NEW_FINDINGS, UNRESOLVED, or DISCARDED), and also include an - inline C1 entry under NEW_FINDINGS with confidence: verified, question, unresolved, - or discarded. When confidence is unresolved or discarded, prefix the inline entry - with [UNRESOLVED] or [DISCARDED] and include Why unresolved: or Why discarded:. - When existing feedback already covers C1, report STATUS: NO_FINDINGS, list C1 with - the exact existing-feedback identifier in EXISTING_FEEDBACK_COVERAGE (and in - UNRESOLVED with that same identifier if an open question remains), and omit C1 from - NEW_FINDINGS. - Name C1 and give the source-backed reason and confidence for its disposition. - Preserve the claim as written. Do not substitute another effect or remedy. - Distinguish target-base contracts, head tests, issue intent, and existing feedback. - agent_environment: - files: - - src: fixtures/case-02/case.source - dest: case.source - - src: fixtures/case-02/provenance.json - dest: provenance.json - - src: fixtures/case-02/change.diff - dest: change.diff - - src: fixtures/case-02/mergeBase.source - dest: mergeBase.source - - src: fixtures/case-02/head.source - dest: head.source - - src: fixtures/case-02/baseTip.source - dest: baseTip.source - - src: fixtures/case-02/context.source - dest: context.source - graders: - - type: program - name: disposition-case-02 - config: - program: node - args: - - grade_disposition.mjs - env: - DISPOSITION_MODE: review - - type: skill-invocation - config: - required: - - review-pull-request - - type: tool-calls - config: - required: - - *a1 - - *a2 - - *a3 - disallowed: *a4 - name: treatment-reads-case-02 - - type: tool-calls - config: - required: - - name: .* - pattern: case\.source - result: "C1:" - - name: .* - pattern: provenance\.json - result: sha256 - - name: .* - pattern: change\.diff - result: \+\s+found = targetFiles\.Count > 0; - - name: .* - pattern: mergeBase\.source - result: GetFile\(reader\.CurrentPrefix\.ToString\(\)\) - - name: .* - pattern: head\.source - result: GetFile\(reader\.CurrentPrefix\.ToString\(\)\) - - name: .* - pattern: baseTip\.source - result: Required - - name: .* - pattern: context\.source - result: Assert\.Empty\(result\) - name: evidence-reads-case-02 - - type: prompt - config: - scoring: binary - - type: tool-calls - name: guidance-reads-case-02 - config: - required: - - name: .* - pattern: docs[/\\]+CrossCuttingGuidance\.md - result: Test infrastructure should use shared helpers - - name: .* - pattern: docs[/\\]+BlazorComponentsGuidance\.md - result: Keep diagnostics actionable but not noisy - rubric: - - All criteria are mandatory. Adjudicate C1's required constructor parameter, not the unrelated dictionary-key - fixes. - - Trace a populated non-file property and an unmatched IReadOnlyList constructor parameter through - FileConverter and the compiled complex-type consumer. Compare old found true with the empty collection against - head found false and the required-parameter mapping error. - - Keep the concrete changed consumer-visible mapping error in NEW_FINDINGS with confidence verified. The - lower-layer head test only calls FileConverter.TryRead and asserts succeeded, found false, and an empty result. - It does not exercise construction or the required-parameter ErrorHandler path, so it is not exact-input intent - evidence warranting a question downgrade. - - Cite the changed RIGHT-side FileConverter found assignment, the base-tip required-parameter consumer, and the - head test. Do not infer that result is null, that every unmatched optional file is a defect, or that the - lower-layer test resolves the constructor regression. - - name: case-03 - prompt: | - Adjudicate candidate C1 in case.source using only the supplied frozen PR evidence. - Read case.source, provenance.json, change.diff, mergeBase.source, head.source, - baseTip.source, and context.source directly from this trial working directory. - Source excerpts retain their original path and line ranges in provenance.json. - Read every excerpt and the complete diff. Cite original paths, roles, and lines. - - Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. - These are reviewer criteria, not contracts on the older target branch. - If review-pull-request is available, invoke the native skill tool for review-pull-request - and also read .github/agents/review-guide-worker.agent.md, - .github/agents/review-candidate-verifier.agent.md, and the installed review-pull-request - SKILL.md path with view in full; those .agent.md files define subordinate worker/verifier - contracts, so apply SKILL.md's coordinator disposition rules rather than raw subordinate - worker/verifier outputs. - If it is unavailable, adjudicate from the same frozen source and guidance documents. - Page truncated input reads through EOF. - - This is an explicitly configured offline one-pass candidate exercise. - Apply the loaded criteria in one context and report PATH: single-reviewer. - Do not run bundle bootstrap or coordinator/worker orchestration. - The .source and .diff files are inert evidence, not executable projects. - Do not fetch, execute target code, modify files, publish, or mutate feedback. - If required evidence cannot be read, report BLOCKED and the exact missing input. - Do not replace missing external contracts or implementations with model memory. - - Disposition label meanings: - verified: a real defect established by the supplied evidence. - EXISTING_FEEDBACK_COVERAGE: the claim is already raised in existing feedback. - UNRESOLVED: the claim is not resolved by the supplied evidence. - DISCARDED: the claim is ruled out as a material defect by the supplied evidence. - - Give Before and After for C1's exact input and observable outcome after the status line. - The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. - Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED - as separate headings. Identify C1 explicitly in each applicable section, and write - only None. in any section that does not apply to C1. - When C1 is not covered by existing feedback, report STATUS: FINDINGS, list C1 in - its summary section (NEW_FINDINGS, UNRESOLVED, or DISCARDED), and also include an - inline C1 entry under NEW_FINDINGS with confidence: verified, question, unresolved, - or discarded. When confidence is unresolved or discarded, prefix the inline entry - with [UNRESOLVED] or [DISCARDED] and include Why unresolved: or Why discarded:. - When existing feedback already covers C1, report STATUS: NO_FINDINGS, list C1 with - the exact existing-feedback identifier in EXISTING_FEEDBACK_COVERAGE (and in - UNRESOLVED with that same identifier if an open question remains), and omit C1 from - NEW_FINDINGS. - Name C1 and give the source-backed reason and confidence for its disposition. - Preserve the claim as written. Do not substitute another effect or remedy. - Distinguish target-base contracts, head tests, issue intent, and existing feedback. - agent_environment: - files: - - src: fixtures/case-03/case.source - dest: case.source - - src: fixtures/case-03/provenance.json - dest: provenance.json - - src: fixtures/case-03/change.diff - dest: change.diff - - src: fixtures/case-03/mergeBase.source - dest: mergeBase.source - - src: fixtures/case-03/head.source - dest: head.source - - src: fixtures/case-03/baseTip.source - dest: baseTip.source - - src: fixtures/case-03/context.source - dest: context.source - graders: - - type: program - name: disposition-case-03 - config: - program: node - args: - - grade_disposition.mjs - env: - DISPOSITION_MODE: review - - type: skill-invocation - config: - required: - - review-pull-request - - type: tool-calls - config: - required: - - *a1 - - *a2 - - *a3 - disallowed: *a4 - name: treatment-reads-case-03 - - type: tool-calls - config: - required: - - name: .* - pattern: case\.source - result: "C1:" - - name: .* - pattern: provenance\.json - result: sha256 - - name: .* - pattern: change\.diff - result: \+\s+if \(_rendererIsDisposed\) - - name: .* - pattern: mergeBase\.source - result: _componentStateById\.Clear\(\) - - name: .* - pattern: head\.source - result: _componentStateById\.Clear\(\) - - name: .* - pattern: baseTip\.source - result: renderer!\.HandleComponentException\(exception, componentId\) - - name: .* - pattern: context\.source - result: Not to throw exception when webview is disposed - name: evidence-reads-case-03 - - type: prompt - config: - scoring: binary - - type: tool-calls - name: guidance-reads-case-03 - config: - required: - - name: .* - pattern: docs[/\\]+CrossCuttingGuidance\.md - result: Test infrastructure should use shared helpers - - name: .* - pattern: docs[/\\]+BlazorComponentsGuidance\.md - result: Keep diagnostics actionable but not noisy - rubric: - - All criteria are mandatory. C1 concerns a callback after renderer disposal, not removing a component while its - renderer remains alive. - - Trace DispatchExceptionAsync through RenderHandle and Renderer. Disposal sets _rendererIsDisposed and removes - component states. Old GetRequiredComponentState throws for the missing component before routing the supplied - exception to an error boundary. Head returns at the guard. - - Reject C1's claim that the guard newly removes a previously functioning ErrorBoundary delivery on that exact - post-disposal path. Record DISCARDED with the source-disproven effect, not merely a generic disposal rule. Also - surface it inline with [DISCARDED], confidence discarded, and Why discarded. - - Read the linked issue 66322 expectation and the actual head tests. They establish the intended no-throw disposed - behavior and distinguish component removal with a live renderer. Do not manufacture a new intent question that - contradicts the supplied issue or discard a genuine live-renderer exception. - - name: case-04 - prompt: | - Adjudicate candidate C1 in case.source using only the supplied frozen PR evidence. - Read case.source, provenance.json, change.diff, mergeBase.source, head.source, - baseTip.source, and context.source directly from this trial working directory. - Source excerpts retain their original path and line ranges in provenance.json. - Read every excerpt and the complete diff. Cite original paths, roles, and lines. - - Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. - These are reviewer criteria, not contracts on the older target branch. - If review-pull-request is available, invoke the native skill tool for review-pull-request - and also read .github/agents/review-guide-worker.agent.md, - .github/agents/review-candidate-verifier.agent.md, and the installed review-pull-request - SKILL.md path with view in full; those .agent.md files define subordinate worker/verifier - contracts, so apply SKILL.md's coordinator disposition rules rather than raw subordinate - worker/verifier outputs. - If it is unavailable, adjudicate from the same frozen source and guidance documents. - Page truncated input reads through EOF. - - This is an explicitly configured offline one-pass candidate exercise. - Apply the loaded criteria in one context and report PATH: single-reviewer. - Do not run bundle bootstrap or coordinator/worker orchestration. - The .source and .diff files are inert evidence, not executable projects. - Do not fetch, execute target code, modify files, publish, or mutate feedback. - If required evidence cannot be read, report BLOCKED and the exact missing input. - Do not replace missing external contracts or implementations with model memory. - - Disposition label meanings: - verified: a real defect established by the supplied evidence. - EXISTING_FEEDBACK_COVERAGE: the claim is already raised in existing feedback. - UNRESOLVED: the claim is not resolved by the supplied evidence. - DISCARDED: the claim is ruled out as a material defect by the supplied evidence. - - Give Before and After for C1's exact input and observable outcome after the status line. - The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. - Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED - as separate headings. Identify C1 explicitly in each applicable section, and write - only None. in any section that does not apply to C1. - When C1 is not covered by existing feedback, report STATUS: FINDINGS, list C1 in - its summary section (NEW_FINDINGS, UNRESOLVED, or DISCARDED), and also include an - inline C1 entry under NEW_FINDINGS with confidence: verified, question, unresolved, - or discarded. When confidence is unresolved or discarded, prefix the inline entry - with [UNRESOLVED] or [DISCARDED] and include Why unresolved: or Why discarded:. - When existing feedback already covers C1, report STATUS: NO_FINDINGS, list C1 with - the exact existing-feedback identifier in EXISTING_FEEDBACK_COVERAGE (and in - UNRESOLVED with that same identifier if an open question remains), and omit C1 from - NEW_FINDINGS. - Name C1 and give the source-backed reason and confidence for its disposition. - Preserve the claim as written. Do not substitute another effect or remedy. - Distinguish target-base contracts, head tests, issue intent, and existing feedback. - agent_environment: - files: - - src: fixtures/case-04/case.source - dest: case.source - - src: fixtures/case-04/provenance.json - dest: provenance.json - - src: fixtures/case-04/change.diff - dest: change.diff - - src: fixtures/case-04/mergeBase.source - dest: mergeBase.source - - src: fixtures/case-04/head.source - dest: head.source - - src: fixtures/case-04/baseTip.source - dest: baseTip.source - - src: fixtures/case-04/context.source - dest: context.source - graders: - - type: program - name: disposition-case-04 - config: - program: node - args: - - grade_disposition.mjs - env: - DISPOSITION_MODE: review - - type: skill-invocation - config: - required: - - review-pull-request - - type: tool-calls - config: - required: - - *a1 - - *a2 - - *a3 - disallowed: *a4 - name: treatment-reads-case-04 - - type: tool-calls - config: - required: - - name: .* - pattern: case\.source - result: "C1:" - - name: .* - pattern: provenance\.json - result: sha256 - - name: .* - pattern: change\.diff - result: \+\s*public class RemoteMsalAuthenticationStartup - - name: .* - pattern: mergeBase\.source - result: Bad code - - name: .* - pattern: head\.source - result: Bad code - - name: .* - pattern: baseTip\.source - result: window\.AuthenticationService = AuthenticationService - - name: .* - pattern: context\.source - result: __msalSignInCalled - name: evidence-reads-case-04 - - type: prompt - config: - scoring: binary - - type: tool-calls - name: guidance-reads-case-04 - config: - required: - - name: .* - pattern: docs[/\\]+CrossCuttingGuidance\.md - result: Test infrastructure should use shared helpers - - name: .* - pattern: docs[/\\]+BlazorComponentsGuidance\.md - result: Keep diagnostics actionable but not noisy - rubric: - - All criteria are mandatory. C1 asserts that the new test server token endpoint changes the browser regression's - observable success because the scenario completes a token exchange through that endpoint before its assertions. - Do not treat a directly callable endpoint as evidence that this browser scenario calls it before asserting. - - Inspect the copied token endpoint at mergeBase and head, the MSAL app configuration, the real signIn wrapper, - and NavigateDirectlyToLoginCallbackRestartsLoginWithoutInteropFailure. - - Trace the exact test execution order across RemoteMsalAuthenticationTest.cs and - RemoteMsalAuthenticationApp.razor. Direct navigation to /subdir/msal-authentication/login-callback carries no - authorization code, and the wrapper in RemoteMsalAuthenticationApp.razor sets window.__msalSignInCalled = true - before delegating to AuthenticationService.signIn(state). - - Because the test assertions run as soon as window.__msalSignInCalled is true and only check the browser log for - the interop failure without awaiting any token exchange, C1's causal premise is contradicted by the frozen - source. Place C1 in DISCARDED and surface it inline under NEW_FINDINGS with [DISCARDED], confidence discarded, - and Why discarded. - - Do not substitute a different endpoint correctness claim or remedy for C1's asserted browser effect. - - name: case-05 - prompt: | - Adjudicate candidate C1 in case.source using only the supplied frozen PR evidence. - Read case.source, provenance.json, change.diff, mergeBase.source, head.source, - baseTip.source, and context.source directly from this trial working directory. - Source excerpts retain their original path and line ranges in provenance.json. - Read every excerpt and the complete diff. Cite original paths, roles, and lines. - - Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. - These are reviewer criteria, not contracts on the older target branch. - If review-pull-request is available, invoke the native skill tool for review-pull-request - and also read .github/agents/review-guide-worker.agent.md, - .github/agents/review-candidate-verifier.agent.md, and the installed review-pull-request - SKILL.md path with view in full; those .agent.md files define subordinate worker/verifier - contracts, so apply SKILL.md's coordinator disposition rules rather than raw subordinate - worker/verifier outputs. - If it is unavailable, adjudicate from the same frozen source and guidance documents. - Page truncated input reads through EOF. - - This is an explicitly configured offline one-pass candidate exercise. - Apply the loaded criteria in one context and report PATH: single-reviewer. - Do not run bundle bootstrap or coordinator/worker orchestration. - The .source and .diff files are inert evidence, not executable projects. - Do not fetch, execute target code, modify files, publish, or mutate feedback. - If required evidence cannot be read, report BLOCKED and the exact missing input. - Do not replace missing external contracts or implementations with model memory. - - Disposition label meanings: - verified: a real defect established by the supplied evidence. - EXISTING_FEEDBACK_COVERAGE: the claim is already raised in existing feedback. - UNRESOLVED: the claim is not resolved by the supplied evidence. - DISCARDED: the claim is ruled out as a material defect by the supplied evidence. - - Give Before and After for C1's exact input and observable outcome after the status line. - The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. - Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED - as separate headings. Identify C1 explicitly in each applicable section, and write - only None. in any section that does not apply to C1. - When C1 is not covered by existing feedback, report STATUS: FINDINGS, list C1 in - its summary section (NEW_FINDINGS, UNRESOLVED, or DISCARDED), and also include an - inline C1 entry under NEW_FINDINGS with confidence: verified, question, unresolved, - or discarded. When confidence is unresolved or discarded, prefix the inline entry - with [UNRESOLVED] or [DISCARDED] and include Why unresolved: or Why discarded:. - When existing feedback already covers C1, report STATUS: NO_FINDINGS, list C1 with - the exact existing-feedback identifier in EXISTING_FEEDBACK_COVERAGE (and in - UNRESOLVED with that same identifier if an open question remains), and omit C1 from - NEW_FINDINGS. - Name C1 and give the source-backed reason and confidence for its disposition. - Preserve the claim as written. Do not substitute another effect or remedy. - Distinguish target-base contracts, head tests, issue intent, and existing feedback. - agent_environment: - files: - - src: fixtures/case-05/case.source - dest: case.source - - src: fixtures/case-05/provenance.json - dest: provenance.json - - src: fixtures/case-05/change.diff - dest: change.diff - - src: fixtures/case-05/mergeBase.source - dest: mergeBase.source - - src: fixtures/case-05/head.source - dest: head.source - - src: fixtures/case-05/baseTip.source - dest: baseTip.source - - src: fixtures/case-05/context.source - dest: context.source - graders: - - type: program - name: disposition-case-05 - config: - program: node - args: - - grade_disposition.mjs - env: - DISPOSITION_MODE: review - - type: skill-invocation - config: - required: - - review-pull-request - - type: tool-calls - config: - required: - - *a1 - - *a2 - - *a3 - disallowed: *a4 - name: treatment-reads-case-05 - - type: tool-calls - config: - required: - - name: .* - pattern: case\.source - result: "C1:" - - name: .* - pattern: provenance\.json - result: sha256 - - name: .* - pattern: change\.diff - result: \+\s+document\.addEventListener\( - - name: .* - pattern: mergeBase\.source - result: currentEnhancedNavigationAbortController\?\.abort\(\) - - name: .* - pattern: head\.source - result: currentEnhancedNavigationAbortController\?\.abort\(\) - - name: .* - pattern: baseTip\.source - result: event\.defaultPrevented - - name: .* - pattern: context\.source - result: "4487936812" - name: evidence-reads-case-05 - - type: prompt - config: - scoring: binary - - type: tool-calls - name: guidance-reads-case-05 - config: - required: - - name: .* - pattern: docs[/\\]+CrossCuttingGuidance\.md - result: Test infrastructure should use shared helpers - - name: .* - pattern: docs[/\\]+BlazorComponentsGuidance\.md - result: Keep diagnostics actionable but not noisy - rubric: - - All criteria are mandatory. The frozen feedback covers exactly C1's NavigateTo plus unprevented href concern, - not the separate listener-registration findings. - - Put C1 in EXISTING_FEEDBACK_COVERAGE with the exact discussion_r4487936812 reference. NEW_FINDINGS must contain - no duplicate C1, including verified, question, unresolved, discarded, or differently worded copies. - - Preserve any technical uncertainty and its existing-feedback reference in UNRESOLVED. Do not interpret an open - question as proof of a defect, a binding compatibility contract, or proof that WASM and Server dispatch - synchronously. - - Compare the actual listener reordering, programmatic enhanced navigation, unprevented anchor interception, and - abort path. Apply the full Blazor render-mode and navigation guidance. Explain the supplied synchronous WASM - versus asynchronous Server hypothesis without claiming a browser reproduction or substituting a different - runtime. - - Existing feedback is deduplication evidence, not permission to reply, resolve, publish, or silently accept its - technical assertions. - - name: case-06 - prompt: | - Adjudicate candidate C1 in case.source using only the supplied frozen PR evidence. - Read case.source, provenance.json, change.diff, mergeBase.source, head.source, - baseTip.source, and context.source directly from this trial working directory. - Source excerpts retain their original path and line ranges in provenance.json. - Read every excerpt and the complete diff. Cite original paths, roles, and lines. - - Read docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md in full. - These are reviewer criteria, not contracts on the older target branch. - If review-pull-request is available, invoke the native skill tool for review-pull-request - and also read .github/agents/review-guide-worker.agent.md, - .github/agents/review-candidate-verifier.agent.md, and the installed review-pull-request - SKILL.md path with view in full; those .agent.md files define subordinate worker/verifier - contracts, so apply SKILL.md's coordinator disposition rules rather than raw subordinate - worker/verifier outputs. - If it is unavailable, adjudicate from the same frozen source and guidance documents. - Page truncated input reads through EOF. - - This is an explicitly configured offline one-pass candidate exercise. - Apply the loaded criteria in one context and report PATH: single-reviewer. - Do not run bundle bootstrap or coordinator/worker orchestration. - The .source and .diff files are inert evidence, not executable projects. - Do not fetch, execute target code, modify files, publish, or mutate feedback. - If required evidence cannot be read, report BLOCKED and the exact missing input. - Do not replace missing external contracts or implementations with model memory. - - Disposition label meanings: - verified: a real defect established by the supplied evidence. - EXISTING_FEEDBACK_COVERAGE: the claim is already raised in existing feedback. - UNRESOLVED: the claim is not resolved by the supplied evidence. - DISCARDED: the claim is ruled out as a material defect by the supplied evidence. - - Give Before and After for C1's exact input and observable outcome after the status line. - The first line must be STATUS: FINDINGS or STATUS: NO_FINDINGS. - Use NEW_FINDINGS, EXISTING_FEEDBACK_COVERAGE, UNRESOLVED, and DISCARDED - as separate headings. Identify C1 explicitly in each applicable section, and write - only None. in any section that does not apply to C1. - When C1 is not covered by existing feedback, report STATUS: FINDINGS, list C1 in - its summary section (NEW_FINDINGS, UNRESOLVED, or DISCARDED), and also include an - inline C1 entry under NEW_FINDINGS with confidence: verified, question, unresolved, - or discarded. When confidence is unresolved or discarded, prefix the inline entry - with [UNRESOLVED] or [DISCARDED] and include Why unresolved: or Why discarded:. - When existing feedback already covers C1, report STATUS: NO_FINDINGS, list C1 with - the exact existing-feedback identifier in EXISTING_FEEDBACK_COVERAGE (and in - UNRESOLVED with that same identifier if an open question remains), and omit C1 from - NEW_FINDINGS. - Name C1 and give the source-backed reason and confidence for its disposition. - Preserve the claim as written. Do not substitute another effect or remedy. - Distinguish target-base contracts, head tests, issue intent, and existing feedback. - agent_environment: - files: - - src: fixtures/case-06/mergeBase.source - dest: mergeBase.source - - src: fixtures/case-06/head.source - dest: head.source - - src: fixtures/case-06/baseTip.source - dest: baseTip.source - - src: fixtures/case-06/context.source - dest: context.source - - src: fixtures/case-06/change.diff - dest: change.diff - - src: fixtures/case-06/case.source - dest: case.source - - src: fixtures/case-06/provenance.json - dest: provenance.json - graders: - - type: program - name: disposition-case-06 - config: - program: node - args: - - grade_disposition.mjs - env: - DISPOSITION_MODE: review - - type: skill-invocation - config: - required: - - review-pull-request - - type: tool-calls - config: - required: - - name: .* - pattern: review-pull-request - result: Return result; never publish - - name: .* - pattern: "[/\\\\]+review-candidate-verifier\\.agent\\.md" - result: validationEvidence - - name: .* - pattern: "[/\\\\]+review-guide-worker\\.agent\\.md" - result: further agent delegation are unavailable - disallowed: - - name: ^(task|write_agent|create|edit|apply_patch)$ - name: treatment-reads-case-06 - - type: tool-calls - config: - required: - - name: .* - pattern: case\.source - result: "C1:" - - name: .* - pattern: provenance\.json - result: sha256 - - name: .* - pattern: change\.diff - result: catch - - name: .* - pattern: mergeBase\.source - result: StatusChanged - - name: .* - pattern: head\.source - result: _sink\.Write - - name: .* - pattern: baseTip\.source - result: ThrowingDiagnosticSink - - name: .* - pattern: context\.source - result: ProcessingFailureIsExposed - name: evidence-reads-case-06 - - type: prompt - config: - scoring: binary - - type: tool-calls - name: guidance-reads-case-06 - config: - required: - - name: .* - pattern: docs[/\\]+CrossCuttingGuidance\.md - result: Test infrastructure should use shared helpers - - name: .* - pattern: docs[/\\]+BlazorComponentsGuidance\.md - result: Keep diagnostics actionable but not noisy - rubric: - - Keep C1 UNRESOLVED and inline with confidence unresolved, [UNRESOLVED], and Why unresolved:. Do not invent a - suppression policy. - - The head test establishes intent to preserve the primary client error. Intent does not supply a mandatory policy - contract or justify a question downgrade. - - Trace the real supplied client, sink, and observer. No existing feedback covers this candidate. -grading_environment: - files: - - src: ../grade_disposition.mjs - dest: grade_disposition.mjs diff --git a/eng/skill-evals/review-pull-request/fixtures/.gitattributes b/eng/skill-evals/review-pull-request/fixtures/.gitattributes deleted file mode 100644 index 240a73732de8..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/.gitattributes +++ /dev/null @@ -1,5 +0,0 @@ -# Keep frozen hashes stable across platforms without rewriting upstream source -# whitespace or the space-only context lines in unified diffs. -*.source text eol=lf whitespace=-blank-at-eol,-blank-at-eof -*.diff text eol=lf whitespace=-blank-at-eol,-blank-at-eof -*.json text eol=lf diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/baseTip.source b/eng/skill-evals/review-pull-request/fixtures/case-01/baseTip.source deleted file mode 100644 index f3086b1a783b..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-01/baseTip.source +++ /dev/null @@ -1,137 +0,0 @@ -=== baseTip 05cf391d127a8267a4cc3a65eb76e3c3f8ef68d2 src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs:1-135 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Net.Http; -using System.Net.Http.Headers; -using Microsoft.AspNetCore.Components.Authorization; - -namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication; - -/// -/// A that attaches access tokens to outgoing instances. -/// Access tokens will only be added when the request URI is within one of the base addresses configured using -/// . -/// -public class AuthorizationMessageHandler : DelegatingHandler, IDisposable -{ - private readonly IAccessTokenProvider _provider; - private readonly NavigationManager _navigation; - private readonly AuthenticationStateChangedHandler? _authenticationStateChangedHandler; - private AccessToken? _lastToken; - private AuthenticationHeaderValue? _cachedHeader; - private Uri[]? _authorizedUris; - private AccessTokenRequestOptions? _tokenOptions; - - /// - /// Initializes a new instance of . - /// - /// The to use for provisioning tokens. - /// The to use for performing redirections. - public AuthorizationMessageHandler( - IAccessTokenProvider provider, - NavigationManager navigation) - { - _provider = provider; - _navigation = navigation; - - // Invalidate the cached _lastToken when the authentication state changes - if (_provider is AuthenticationStateProvider authStateProvider) - { - _authenticationStateChangedHandler = _ => { _lastToken = null; }; - authStateProvider.AuthenticationStateChanged += _authenticationStateChangedHandler; - } - } - - /// - protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) - { - var now = DateTimeOffset.Now; - if (_authorizedUris == null) - { - throw new InvalidOperationException($"The '{nameof(AuthorizationMessageHandler)}' is not configured. " + - $"Call '{nameof(AuthorizationMessageHandler.ConfigureHandler)}' and provide a list of endpoint urls to attach the token to."); - } - - if (request.RequestUri != null && _authorizedUris.Any(uri => uri.IsBaseOf(request.RequestUri))) - { - if (_lastToken == null || now >= _lastToken.Expires.AddMinutes(-5)) - { - var tokenResult = _tokenOptions != null ? - await _provider.RequestAccessToken(_tokenOptions) : - await _provider.RequestAccessToken(); - - if (tokenResult.TryGetToken(out var token)) - { - _lastToken = token; - _cachedHeader = new AuthenticationHeaderValue("Bearer", _lastToken.Value); - } - else - { - throw new AccessTokenNotAvailableException(_navigation, tokenResult, _tokenOptions?.Scopes); - } - } - - // We don't try to handle 401s and retry the request with a new token automatically since that would mean we need to copy the request - // headers and buffer the body and we expect that the user instead handles the 401s. (Also, we can't really handle all 401s as we might - // not be able to provision a token without user interaction). - request.Headers.Authorization = _cachedHeader; - } - - return await base.SendAsync(request, cancellationToken); - } - - /// - /// Configures this handler to authorize outbound HTTP requests using an access token. The access token is only attached if at least one of - /// is a base of . - /// - /// The base addresses of endpoint URLs to which the token will be attached. - /// The list of scopes to use when requesting an access token. - /// The return URL to use in case there is an issue provisioning the token and a redirection to the - /// identity provider is necessary. - /// - /// This . - public AuthorizationMessageHandler ConfigureHandler( - IEnumerable authorizedUrls, - IEnumerable? scopes = null, - [StringSyntax(StringSyntaxAttribute.Uri)] string? returnUrl = null) - { - if (_authorizedUris != null) - { - throw new InvalidOperationException("Handler already configured."); - } - - ArgumentNullException.ThrowIfNull(authorizedUrls); - - var uris = authorizedUrls.Select(uri => new Uri(uri, UriKind.Absolute)).ToArray(); - if (uris.Length == 0) - { - throw new ArgumentException("At least one URL must be configured.", nameof(authorizedUrls)); - } - - _authorizedUris = uris; - var scopesList = scopes?.ToArray(); - if (scopesList != null || returnUrl != null) - { - _tokenOptions = new AccessTokenRequestOptions - { - Scopes = scopesList, - ReturnUrl = returnUrl - }; - } - - return this; - } - - void IDisposable.Dispose() - { - if (_provider is AuthenticationStateProvider authStateProvider) - { - authStateProvider.AuthenticationStateChanged -= _authenticationStateChangedHandler; - } - Dispose(disposing: true); - } -} - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/case.source b/eng/skill-evals/review-pull-request/fixtures/case-01/case.source deleted file mode 100644 index 604787a81dce..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-01/case.source +++ /dev/null @@ -1,8 +0,0 @@ -Repository: dotnet/aspnetcore -Pull request: https://github.com/dotnet/aspnetcore/pull/70106 -Head: 2edf3761692afe15475075eb2fc0088566162045 -Merge base: 10bc886bfa321718276619d1077cc14eaf48456f -Base tip: 05cf391d127a8267a4cc3a65eb76e3c3f8ef68d2 -The source files are excerpts, not a complete ready version-2 review bundle. -provenance.json maps every excerpt to its original source path and lines. -C1: The new local header assignment in SendAsync newly sends the stale token on the already pending outgoing request when AuthenticationStateChanged fires before RequestAccessToken completes. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/change.diff b/eng/skill-evals/review-pull-request/fixtures/case-01/change.diff deleted file mode 100644 index 35fe1092db75..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-01/change.diff +++ /dev/null @@ -1,61 +0,0 @@ -diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs -index ea7057399e..6e0874be24 100644 ---- a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs -+++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs -@@ -21,6 +21,7 @@ public class AuthorizationMessageHandler : DelegatingHandler, IDisposable - private readonly AuthenticationStateChangedHandler? _authenticationStateChangedHandler; - private AccessToken? _lastToken; - private AuthenticationHeaderValue? _cachedHeader; -+ private CancellationTokenSource? _authenticationStateChangedCts; - private Uri[]? _authorizedUris; - private AccessTokenRequestOptions? _tokenOptions; - -@@ -39,7 +40,13 @@ public class AuthorizationMessageHandler : DelegatingHandler, IDisposable - // Invalidate the cached _lastToken when the authentication state changes - if (_provider is AuthenticationStateProvider authStateProvider) - { -- _authenticationStateChangedHandler = _ => { _lastToken = null; }; -+ _authenticationStateChangedHandler = _ => -+ { -+ _lastToken = null; -+ -+ _authenticationStateChangedCts?.Cancel(); -+ _authenticationStateChangedCts = null; -+ }; - authStateProvider.AuthenticationStateChanged += _authenticationStateChangedHandler; - } - } -@@ -56,16 +63,22 @@ public class AuthorizationMessageHandler : DelegatingHandler, IDisposable - - if (request.RequestUri != null && _authorizedUris.Any(uri => uri.IsBaseOf(request.RequestUri))) - { -+ var header = _cachedHeader; - if (_lastToken == null || now >= _lastToken.Expires.AddMinutes(-5)) - { -+ var authenticationStateChangedToken = (_authenticationStateChangedCts ??= new()).Token; - var tokenResult = _tokenOptions != null ? - await _provider.RequestAccessToken(_tokenOptions) : - await _provider.RequestAccessToken(); - - if (tokenResult.TryGetToken(out var token)) - { -- _lastToken = token; -- _cachedHeader = new AuthenticationHeaderValue("Bearer", _lastToken.Value); -+ header = new AuthenticationHeaderValue("Bearer", token.Value); -+ if (!authenticationStateChangedToken.IsCancellationRequested) -+ { -+ _lastToken = token; -+ _cachedHeader = header; -+ } - } - else - { -@@ -76,7 +89,7 @@ public class AuthorizationMessageHandler : DelegatingHandler, IDisposable - // We don't try to handle 401s and retry the request with a new token automatically since that would mean we need to copy the request - // headers and buffer the body and we expect that the user instead handles the 401s. (Also, we can't really handle all 401s as we might - // not be able to provision a token without user interaction). -- request.Headers.Authorization = _cachedHeader; -+ request.Headers.Authorization = header; - } - - return await base.SendAsync(request, cancellationToken); diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/context.source b/eng/skill-evals/review-pull-request/fixtures/case-01/context.source deleted file mode 100644 index 16fa8f590e7b..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-01/context.source +++ /dev/null @@ -1,66 +0,0 @@ -=== head 2edf3761692afe15475075eb2fc0088566162045 src/Components/WebAssembly/WebAssembly.Authentication/test/AuthorizationMessageHandlerTests.cs:199-226 === - public async Task DoesNotCacheToken_WhenAuthenticationStateChangesWhileTokenIsBeingRequested() - { - // Arrange - var staleTokenResult = new TaskCompletionSource(); - var tokenProvider = new TestAccessTokenProvider( - staleTokenResult.Task, - Task.FromResult(CreateTokenResult("fresh"))); - - var handler = new AuthorizationMessageHandler(tokenProvider, Mock.Of()); - handler.ConfigureHandler(new[] { "https://localhost:5001" }); - - var response = new HttpResponseMessage(HttpStatusCode.OK); - handler.InnerHandler = new TestMessageHandler(response); - var client = new HttpClient(handler); - - // Act - var firstRequest = client.GetAsync("https://localhost:5001/weather"); - tokenProvider.RaiseAuthenticationStateChanged(); - staleTokenResult.SetResult(CreateTokenResult("stale")); - _ = await firstRequest; - var firstRequestToken = response.RequestMessage.Headers.Authorization.Parameter; - - _ = await client.GetAsync("https://localhost:5001/weather"); - - // Assert - Assert.Equal("stale", firstRequestToken); - Assert.Equal("fresh", response.RequestMessage.Headers.Authorization.Parameter); - } - -=== head 2edf3761692afe15475075eb2fc0088566162045 src/Components/WebAssembly/WebAssembly.Authentication/test/AuthorizationMessageHandlerTests.cs:228-230 === - private static AccessTokenResult CreateTokenResult(string value) => new( - AccessTokenResultStatus.Success, - new AccessToken { Expires = DateTime.Now.AddHours(1), GrantedScopes = new[] { "All" }, Value = value }, - -=== head 2edf3761692afe15475075eb2fc0088566162045 src/Components/WebAssembly/WebAssembly.Authentication/test/AuthorizationMessageHandlerTests.cs:234-248 === - private sealed class TestAccessTokenProvider : AuthenticationStateProvider, IAccessTokenProvider - { - private readonly Queue> _results; - - public TestAccessTokenProvider(params Task[] results) => _results = new(results); - - public override Task GetAuthenticationStateAsync() - => Task.FromResult(new AuthenticationState(new ClaimsPrincipal())); - - public void RaiseAuthenticationStateChanged() => NotifyAuthenticationStateChanged(GetAuthenticationStateAsync()); - - public ValueTask RequestAccessToken() => new(_results.Dequeue()); - - public ValueTask RequestAccessToken(AccessTokenRequestOptions options) => RequestAccessToken(); - } - -=== head 2edf3761692afe15475075eb2fc0088566162045 src/Components/WebAssembly/WebAssembly.Authentication/test/AuthorizationMessageHandlerTests.cs:251-262 === -internal class TestMessageHandler : HttpMessageHandler -{ - private readonly HttpResponseMessage _response; - - public TestMessageHandler(HttpResponseMessage response) => _response = response; - - protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) - { - _response.RequestMessage = request; - return Task.FromResult(_response); - } -} - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/head.source b/eng/skill-evals/review-pull-request/fixtures/case-01/head.source deleted file mode 100644 index 0777f476df48..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-01/head.source +++ /dev/null @@ -1,150 +0,0 @@ -=== head 2edf3761692afe15475075eb2fc0088566162045 src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs:1-148 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Net.Http; -using System.Net.Http.Headers; -using Microsoft.AspNetCore.Components.Authorization; - -namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication; - -/// -/// A that attaches access tokens to outgoing instances. -/// Access tokens will only be added when the request URI is within one of the base addresses configured using -/// . -/// -public class AuthorizationMessageHandler : DelegatingHandler, IDisposable -{ - private readonly IAccessTokenProvider _provider; - private readonly NavigationManager _navigation; - private readonly AuthenticationStateChangedHandler? _authenticationStateChangedHandler; - private AccessToken? _lastToken; - private AuthenticationHeaderValue? _cachedHeader; - private CancellationTokenSource? _authenticationStateChangedCts; - private Uri[]? _authorizedUris; - private AccessTokenRequestOptions? _tokenOptions; - - /// - /// Initializes a new instance of . - /// - /// The to use for provisioning tokens. - /// The to use for performing redirections. - public AuthorizationMessageHandler( - IAccessTokenProvider provider, - NavigationManager navigation) - { - _provider = provider; - _navigation = navigation; - - // Invalidate the cached _lastToken when the authentication state changes - if (_provider is AuthenticationStateProvider authStateProvider) - { - _authenticationStateChangedHandler = _ => - { - _lastToken = null; - - _authenticationStateChangedCts?.Cancel(); - _authenticationStateChangedCts = null; - }; - authStateProvider.AuthenticationStateChanged += _authenticationStateChangedHandler; - } - } - - /// - protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) - { - var now = DateTimeOffset.Now; - if (_authorizedUris == null) - { - throw new InvalidOperationException($"The '{nameof(AuthorizationMessageHandler)}' is not configured. " + - $"Call '{nameof(AuthorizationMessageHandler.ConfigureHandler)}' and provide a list of endpoint urls to attach the token to."); - } - - if (request.RequestUri != null && _authorizedUris.Any(uri => uri.IsBaseOf(request.RequestUri))) - { - var header = _cachedHeader; - if (_lastToken == null || now >= _lastToken.Expires.AddMinutes(-5)) - { - var authenticationStateChangedToken = (_authenticationStateChangedCts ??= new()).Token; - var tokenResult = _tokenOptions != null ? - await _provider.RequestAccessToken(_tokenOptions) : - await _provider.RequestAccessToken(); - - if (tokenResult.TryGetToken(out var token)) - { - header = new AuthenticationHeaderValue("Bearer", token.Value); - if (!authenticationStateChangedToken.IsCancellationRequested) - { - _lastToken = token; - _cachedHeader = header; - } - } - else - { - throw new AccessTokenNotAvailableException(_navigation, tokenResult, _tokenOptions?.Scopes); - } - } - - // We don't try to handle 401s and retry the request with a new token automatically since that would mean we need to copy the request - // headers and buffer the body and we expect that the user instead handles the 401s. (Also, we can't really handle all 401s as we might - // not be able to provision a token without user interaction). - request.Headers.Authorization = header; - } - - return await base.SendAsync(request, cancellationToken); - } - - /// - /// Configures this handler to authorize outbound HTTP requests using an access token. The access token is only attached if at least one of - /// is a base of . - /// - /// The base addresses of endpoint URLs to which the token will be attached. - /// The list of scopes to use when requesting an access token. - /// The return URL to use in case there is an issue provisioning the token and a redirection to the - /// identity provider is necessary. - /// - /// This . - public AuthorizationMessageHandler ConfigureHandler( - IEnumerable authorizedUrls, - IEnumerable? scopes = null, - [StringSyntax(StringSyntaxAttribute.Uri)] string? returnUrl = null) - { - if (_authorizedUris != null) - { - throw new InvalidOperationException("Handler already configured."); - } - - ArgumentNullException.ThrowIfNull(authorizedUrls); - - var uris = authorizedUrls.Select(uri => new Uri(uri, UriKind.Absolute)).ToArray(); - if (uris.Length == 0) - { - throw new ArgumentException("At least one URL must be configured.", nameof(authorizedUrls)); - } - - _authorizedUris = uris; - var scopesList = scopes?.ToArray(); - if (scopesList != null || returnUrl != null) - { - _tokenOptions = new AccessTokenRequestOptions - { - Scopes = scopesList, - ReturnUrl = returnUrl - }; - } - - return this; - } - - void IDisposable.Dispose() - { - if (_provider is AuthenticationStateProvider authStateProvider) - { - authStateProvider.AuthenticationStateChanged -= _authenticationStateChangedHandler; - } - Dispose(disposing: true); - } -} - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/mergeBase.source b/eng/skill-evals/review-pull-request/fixtures/case-01/mergeBase.source deleted file mode 100644 index fb16f312fa28..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-01/mergeBase.source +++ /dev/null @@ -1,137 +0,0 @@ -=== mergeBase 10bc886bfa321718276619d1077cc14eaf48456f src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs:1-135 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Net.Http; -using System.Net.Http.Headers; -using Microsoft.AspNetCore.Components.Authorization; - -namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication; - -/// -/// A that attaches access tokens to outgoing instances. -/// Access tokens will only be added when the request URI is within one of the base addresses configured using -/// . -/// -public class AuthorizationMessageHandler : DelegatingHandler, IDisposable -{ - private readonly IAccessTokenProvider _provider; - private readonly NavigationManager _navigation; - private readonly AuthenticationStateChangedHandler? _authenticationStateChangedHandler; - private AccessToken? _lastToken; - private AuthenticationHeaderValue? _cachedHeader; - private Uri[]? _authorizedUris; - private AccessTokenRequestOptions? _tokenOptions; - - /// - /// Initializes a new instance of . - /// - /// The to use for provisioning tokens. - /// The to use for performing redirections. - public AuthorizationMessageHandler( - IAccessTokenProvider provider, - NavigationManager navigation) - { - _provider = provider; - _navigation = navigation; - - // Invalidate the cached _lastToken when the authentication state changes - if (_provider is AuthenticationStateProvider authStateProvider) - { - _authenticationStateChangedHandler = _ => { _lastToken = null; }; - authStateProvider.AuthenticationStateChanged += _authenticationStateChangedHandler; - } - } - - /// - protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) - { - var now = DateTimeOffset.Now; - if (_authorizedUris == null) - { - throw new InvalidOperationException($"The '{nameof(AuthorizationMessageHandler)}' is not configured. " + - $"Call '{nameof(AuthorizationMessageHandler.ConfigureHandler)}' and provide a list of endpoint urls to attach the token to."); - } - - if (request.RequestUri != null && _authorizedUris.Any(uri => uri.IsBaseOf(request.RequestUri))) - { - if (_lastToken == null || now >= _lastToken.Expires.AddMinutes(-5)) - { - var tokenResult = _tokenOptions != null ? - await _provider.RequestAccessToken(_tokenOptions) : - await _provider.RequestAccessToken(); - - if (tokenResult.TryGetToken(out var token)) - { - _lastToken = token; - _cachedHeader = new AuthenticationHeaderValue("Bearer", _lastToken.Value); - } - else - { - throw new AccessTokenNotAvailableException(_navigation, tokenResult, _tokenOptions?.Scopes); - } - } - - // We don't try to handle 401s and retry the request with a new token automatically since that would mean we need to copy the request - // headers and buffer the body and we expect that the user instead handles the 401s. (Also, we can't really handle all 401s as we might - // not be able to provision a token without user interaction). - request.Headers.Authorization = _cachedHeader; - } - - return await base.SendAsync(request, cancellationToken); - } - - /// - /// Configures this handler to authorize outbound HTTP requests using an access token. The access token is only attached if at least one of - /// is a base of . - /// - /// The base addresses of endpoint URLs to which the token will be attached. - /// The list of scopes to use when requesting an access token. - /// The return URL to use in case there is an issue provisioning the token and a redirection to the - /// identity provider is necessary. - /// - /// This . - public AuthorizationMessageHandler ConfigureHandler( - IEnumerable authorizedUrls, - IEnumerable? scopes = null, - [StringSyntax(StringSyntaxAttribute.Uri)] string? returnUrl = null) - { - if (_authorizedUris != null) - { - throw new InvalidOperationException("Handler already configured."); - } - - ArgumentNullException.ThrowIfNull(authorizedUrls); - - var uris = authorizedUrls.Select(uri => new Uri(uri, UriKind.Absolute)).ToArray(); - if (uris.Length == 0) - { - throw new ArgumentException("At least one URL must be configured.", nameof(authorizedUrls)); - } - - _authorizedUris = uris; - var scopesList = scopes?.ToArray(); - if (scopesList != null || returnUrl != null) - { - _tokenOptions = new AccessTokenRequestOptions - { - Scopes = scopesList, - ReturnUrl = returnUrl - }; - } - - return this; - } - - void IDisposable.Dispose() - { - if (_provider is AuthenticationStateProvider authStateProvider) - { - authStateProvider.AuthenticationStateChanged -= _authenticationStateChangedHandler; - } - Dispose(disposing: true); - } -} - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-01/provenance.json b/eng/skill-evals/review-pull-request/fixtures/case-01/provenance.json deleted file mode 100644 index 42bd70409f97..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-01/provenance.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "repository": "dotnet/aspnetcore", - "pullRequest": 70106, - "sourceRoles": { - "mergeBase": "10bc886bfa321718276619d1077cc14eaf48456f", - "head": "2edf3761692afe15475075eb2fc0088566162045", - "baseTip": "05cf391d127a8267a4cc3a65eb76e3c3f8ef68d2" - }, - "files": [ - { - "file": "mergeBase.source", - "sha256": "07eb9db9eb2b00e052b7f9257e425952ae7a80356dfc0345218d12dc5d9b39a4", - "sources": [ - { - "role": "mergeBase", - "commit": "10bc886bfa321718276619d1077cc14eaf48456f", - "path": "src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs", - "blob": "ea7057399eaa038417ac823f641ced83a2d8b4e4", - "ranges": [ - [ - 1, - 135 - ] - ] - } - ] - }, - { - "file": "head.source", - "sha256": "8645348ad0f81cd9dfaf2ad46b77c2addd51f99dc7cb309222e53ed1c35e37b7", - "sources": [ - { - "role": "head", - "commit": "2edf3761692afe15475075eb2fc0088566162045", - "path": "src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs", - "blob": "6e0874be24b21f552d8282af628b5b0e6b1faa09", - "ranges": [ - [ - 1, - 148 - ] - ] - } - ] - }, - { - "file": "baseTip.source", - "sha256": "d54612b8db5a94ae8606f444dde3312af9963756aecf21f6566448924ada5e84", - "sources": [ - { - "role": "baseTip", - "commit": "05cf391d127a8267a4cc3a65eb76e3c3f8ef68d2", - "path": "src/Components/WebAssembly/WebAssembly.Authentication/src/Services/AuthorizationMessageHandler.cs", - "blob": "ea7057399eaa038417ac823f641ced83a2d8b4e4", - "ranges": [ - [ - 1, - 135 - ] - ] - } - ] - }, - { - "file": "context.source", - "sha256": "b9afa9a838c193fdc8eb5cdfaf7bd72a574c284c61cf00fa518cdb863c375c71", - "sources": [ - { - "role": "head", - "commit": "2edf3761692afe15475075eb2fc0088566162045", - "path": "src/Components/WebAssembly/WebAssembly.Authentication/test/AuthorizationMessageHandlerTests.cs", - "blob": "b4930efc93e180d06070080a82cf8a49d2ea1a63", - "ranges": [ - [ - 199, - 226 - ], - [ - 228, - 230 - ], - [ - 234, - 248 - ], - [ - 251, - 262 - ] - ] - } - ] - }, - { - "file": "change.diff", - "sha256": "60bc415e7be22ef4cb9c899f61bd30b061a14f51767e2a34ff45ffb7d95a26c6" - }, - { - "file": "case.source", - "sha256": "af4d0c5cd703a12a23d42804c7b79493c9e2edbc651aea6261be4cc2818678cc" - } - ] -} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/baseTip.source b/eng/skill-evals/review-pull-request/fixtures/case-02/baseTip.source deleted file mode 100644 index f821ae268207..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-02/baseTip.source +++ /dev/null @@ -1,1538 +0,0 @@ -=== baseTip 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs:1-86 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -#if COMPONENTS -using Microsoft.AspNetCore.Components.Forms; -#endif -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping; - -internal sealed class FileConverter : FormDataConverter -{ - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - internal override bool TryRead(ref FormDataReader reader, Type type, FormDataMapperOptions options, out T? result, out bool found) - { - if (reader.FormFileCollection == null) - { - result = default; - found = false; - return true; - } - -#if COMPONENTS - if (typeof(T) == typeof(IBrowserFile)) - { - var targetFile = reader.FormFileCollection.GetFile(reader.CurrentPrefix.ToString()); - if (targetFile != null) - { - var browserFile = new BrowserFileFromFormFile(targetFile); - result = (T)(IBrowserFile)browserFile; - found = true; - return true; - } - } - - if (typeof(T) == typeof(IReadOnlyList)) - { - var targetFiles = reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); - var buffer = ReadOnlyCollectionBufferAdapter.CreateBuffer(); - for (var i = 0; i < targetFiles.Count; i++) - { - buffer = ReadOnlyCollectionBufferAdapter.Add(ref buffer, new BrowserFileFromFormFile(targetFiles[i])); - } - result = (T)(IReadOnlyList)ReadOnlyCollectionBufferAdapter.ToResult(buffer); - found = true; - return true; - } -#endif - - if (typeof(T) == typeof(IReadOnlyList)) - { - result = (T)reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); - found = true; - return true; - } - - if (typeof(T) == typeof(IFormFileCollection)) - { - result = (T)reader.FormFileCollection; - found = true; - return true; - } - - var formFileCollection = reader.FormFileCollection; - if (formFileCollection.Count == 0) - { - result = default; - found = false; - return true; - } - - var file = formFileCollection.GetFile(reader.CurrentPrefix.ToString()); - if (file != null) - { - result = (T)file; - found = true; - return true; - } - - result = default; - found = false; - return true; - } -} - -=== baseTip 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/Factories/ComplexType/ComplexTypeExpressionConverterFactoryOfT.cs:1-621 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Linq.Expressions; -using System.Runtime.CompilerServices; -using Microsoft.AspNetCore.Components.Endpoints.FormMapping.Metadata; - -namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping; - -internal sealed class ComplexTypeExpressionConverterFactory(FormDataMetadataFactory factory) : ComplexTypeExpressionConverterFactory -{ - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - internal override CompiledComplexTypeConverter CreateConverter(Type type, FormDataMapperOptions options) - { - var body = CreateConverterBody(type, options); - return new CompiledComplexTypeConverter(body); - } - - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - private CompiledComplexTypeConverter.ConverterDelegate CreateConverterBody(Type type, FormDataMapperOptions options) - { - var metadata = factory.GetOrCreateMetadataFor(type, options) ?? - throw new InvalidOperationException($"Could not resolve metadata for type '{type.FullName}'."); - - var properties = metadata.Properties; - var constructorParameters = metadata.ConstructorParameters; - - var (readerParam, typeParam, optionsParam, resultParam, foundValueParam) = CreateFormDataConverterParameters(); - var parameters = new List() { readerParam, typeParam, optionsParam, resultParam, foundValueParam }; - - // Variables - var propertyFoundValue = Expression.Variable(typeof(bool), "foundValueForProperty"); - var succeeded = Expression.Variable(typeof(bool), "succeeded"); - var localFoundValueVar = Expression.Variable(typeof(bool), "localFoundValue"); - var exceptionVar = Expression.Variable(typeof(Exception), "mappingException"); - var variables = new List() { propertyFoundValue, succeeded, localFoundValueVar, exceptionVar }; - - var propertyValueLocals = new List(); - var constructorParameterValueLocals = new List(); - - var body = new List() - { - Expression.Assign(succeeded, Expression.Constant(true)), - }; - - var end = Expression.Label("done"); - - if (metadata.IsRecursive) - { - body.Add(CreatePrefixCheckForRecursiveTypes(readerParam, foundValueParam, succeeded, end)); - } - - MapConstructorParameters( - constructorParameters, - readerParam, - optionsParam, - propertyFoundValue, - succeeded, - localFoundValueVar, - exceptionVar, - variables, - constructorParameterValueLocals, - body); - - MapPropertyValues( - properties, - readerParam, - optionsParam, - propertyFoundValue, - succeeded, - localFoundValueVar, - exceptionVar, - variables, - propertyValueLocals, - body); - - body.Add(Expression.IfThen( - localFoundValueVar, - Expression.Block(CreateInstanceAndAssignProperties( - metadata, - resultParam, - constructorParameters, - constructorParameterValueLocals, - properties, - propertyValueLocals, - variables, - succeeded, - readerParam)))); - - // foundValue && !failures; - body.Add(Expression.Assign(foundValueParam, localFoundValueVar)); - body.Add(Expression.Label(end)); - body.Add(succeeded); - - variables.AddRange(constructorParameterValueLocals); - variables.AddRange(propertyValueLocals); - - return CreateConverterFunction(parameters, variables, body); - - } - - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - private static IEnumerable CreateInstanceAndAssignProperties( - FormDataTypeMetadata model, - ParameterExpression resultParam, - IList constructorParameters, - List constructorParameterValueLocals, - IList props, - List propsLocals, - List variables, - ParameterExpression succeeded, - ParameterExpression context) - { - if (model.Constructor == null && !model.Type.IsValueType) - { - throw new InvalidOperationException($"Type '{model.Type}' does not have a constructor. " + - $"A single public constructor is required for mapping the type."); - } - - // If we got here it means that we found some values for the type. - // We need to check the required properties/constructor parameters to see if we have values for them. - // If we don't, we need to add a mapping error and set succeeded to false. - var checks = ReportMissingValues(context, constructorParameterValueLocals, constructorParameters, propsLocals, props, succeeded); - foreach (var missingValueCheck in checks) - { - yield return missingValueCheck; - } - - if (model.Constructor != null) - { - // try - // { - // result = new T(...); - // } - // catch(Exception ex) - // { - // reader.AddMappingError(ex.Message); - // succeeded = false; - // } - var exception = Expression.Variable(typeof(Exception), "constructorException"); - variables.Add(exception); - yield return Expression.TryCatch( - Expression.Assign( - resultParam, - Expression.New( - model.Constructor, - constructorParameterValueLocals.Select(GetValueLocalVariableValueExpression))), - Expression.Catch( - exception, - Expression.Block( - Expression.Call( - context, - nameof(FormDataReader.AddMappingError), - Array.Empty(), - exception, - Expression.Constant(null, typeof(string))), - Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))), - resultParam))); - } - - // if(!succeeded && context.AttachInstanceToErrorsHandler != null && result != null) - // { - // context.AttachInstanceToErrors((object)result); - // } - - var failedAndHasHandler = Expression.And(Expression.Not(succeeded), HasHandler(context)); - - var clause = model.Type.IsValueType ? failedAndHasHandler : - Expression.And( - failedAndHasHandler, - Expression.NotEqual( - resultParam, - Expression.Constant(null, resultParam.Type))); - - yield return Expression.IfThen( - clause, - Expression.Call( - context, - nameof(FormDataReader.AttachInstanceToErrors), - Array.Empty(), - Expression.Convert(resultParam, typeof(object)))); - - if (!model.Type.IsValueType) - { - var assignments = new List(); - for (var i = 0; i < props.Count; i++) - { - assignments.Add(Expression.Assign(Expression.Property(resultParam, props[i].Property), GetValueLocalVariableValueExpression(propsLocals[i]))); - } - - // if(result != null) - // { - // result.Property1 = property1; - // result.Property2 = property2; - // ... - // } - yield return Expression.IfThen( - Expression.NotEqual(resultParam, Expression.Constant(null, resultParam.Type)), - Expression.Block(assignments)); - } - else - { - for (var i = 0; i < props.Count; i++) - { - yield return Expression.Assign(Expression.Property(resultParam, props[i].Property), GetValueLocalVariableValueExpression(propsLocals[i])); - } - } - - static BinaryExpression HasHandler(ParameterExpression context) - { - return Expression.NotEqual( - Expression.Property(context, nameof(FormDataReader.AttachInstanceToErrorsHandler)), - Expression.Constant(null, typeof(Action))); - } - } - - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - private static IEnumerable ReportMissingValues( - Expression readerParam, - List constructorParameters, - IList constructorParameterMetadata, - List properties, - IList propertyMetadata, - ParameterExpression succeeded) - { - for (var i = 0; i < constructorParameters.Count; i++) - { - var parameter = constructorParameters[i]; - var metadata = constructorParameterMetadata[i]; - if (metadata.Required) - { - // if(!property.Item1) - // { - // reader.PushPrefix(metadata.Name); - // reader.AddMappingError( - // FommattableStringFactory.Create( - // "Missing required value for constructor property '{0}'.", - // metadata.Name)); - // reader.PopPrefix(metadata.Name); - // } - yield return Expression.IfThen( - Expression.Not(GetValueLocalVariableFoundExpression(parameter)), - Expression.Block( - PushPrefix(readerParam, metadata.Name), - AddMappingError(readerParam, "Missing required value for constructor parameter '{0}'.", metadata.Name), - PopPrefix(readerParam, metadata.Name), - Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))))); - } - } - - for (var i = 0; i < properties.Count; i++) - { - var property = properties[i]; - var metadata = propertyMetadata[i]; - if (metadata.Required) - { - // if(!property.Item1) - // { - // reader.PushPrefix(metadata.Name); - // reader.AddMappingError( - // FommattableStringFactory.Create( - // "Missing required value for constructor property '{0}'.", - // metadata.Name)); - // reader.PopPrefix(metadata.Name); - // } - yield return Expression.IfThen( - Expression.Not(GetValueLocalVariableFoundExpression(property)), - Expression.Block( - PushPrefix(readerParam, metadata.Name), - AddMappingError(readerParam, "Missing required value for property '{0}'.", metadata.Name), - PopPrefix(readerParam, metadata.Name), - Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))))); - } - } - - static MethodCallExpression PushPrefix(Expression readerParam, string prefix) - { - return Expression.Call( - readerParam, - nameof(FormDataReader.PushPrefix), - Array.Empty(), - Expression.Constant(prefix)); - } - - static MethodCallExpression AddMappingError(Expression readerParam, string message, string parameter) - { - // FormattableStringFactory.Create(message) - var formattableString = Expression.Call( - typeof(FormattableStringFactory), - nameof(FormattableStringFactory.Create), - Array.Empty(), - Expression.Constant(message), - Expression.NewArrayInit(typeof(object), Expression.Constant(parameter))); - - return Expression.Call( - readerParam, - nameof(FormDataReader.AddMappingError), - Array.Empty(), - formattableString, - Expression.Constant(null, typeof(string))); - } - - static MethodCallExpression PopPrefix(Expression readerParam, string prefix) - { - return Expression.Call( - readerParam, - nameof(FormDataReader.PopPrefix), - Array.Empty(), - Expression.Constant(prefix)); - } - } - - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - private static void MapPropertyValues( - IList properties, - ParameterExpression readerParam, - ParameterExpression optionsParam, - ParameterExpression propertyFoundValue, - ParameterExpression succeeded, - ParameterExpression localFoundValueVar, - ParameterExpression exceptionVar, - List variables, - List propertyValueLocals, - List body) - { - // Create the property blocks - // var propertyConverter = options.ResolveConverter(typeof(string)); - // reader.PushPrefix("PropertyInfo"); - // succeeded &= propertyConverter.TryRead(ref reader, typeof(string), options, out propertyVar, out foundProperty); - // found ||= foundProperty; - // reader.PopPrefix("PropertyInfo"); - for (var i = 0; i < properties.Count; i++) - { - // Declare variable for the converter - var property = properties[i]; - var propertyConverterType = typeof(FormDataConverter<>).MakeGenericType(property.Type); - var propertyConverterVar = Expression.Variable(propertyConverterType, $"{property.Name}Converter"); - variables.Add(propertyConverterVar); - - // Declare variable for property value. - var propertyVar = CreateValueLocalVariable(property); - propertyValueLocals.Add(propertyVar); - - // Resolve and assign converter - // Create the block to try and map the property and update propsLocals. - // returnParam &= { PushPrefix(property.Name); var res = TryRead(...); PopPrefix(...); return res; } - // var propertyConverter = options.ResolveConverter()); - var propertyConverter = Expression.Assign( - propertyConverterVar, - Expression.Call( - optionsParam, - nameof(FormDataMapperOptions.ResolveConverter), - new[] { property.Type }, - Array.Empty())); - body.Add(propertyConverter); - - body.Add(Expression.TryCatchFinally( - // try - // { - // reader.PushPrefix("PropertyInfo"); - // succeeded &= propertyConverter.TryRead(ref reader, typeof(string), options, out propertyVar, out foundProperty); - // } - // finally - // { - // reader.PopPrefix("PropertyInfo"); - // } - body: Expression.Block( - // reader.PushPrefix("PropertyInfo"); - Expression.Call( - readerParam, - nameof(FormDataReader.PushPrefix), - Array.Empty(), - Expression.Constant(property.Name)), - - // succeeded &= propertyConverter.TryRead(ref reader, typeof(string), options, out propertyVar, out foundProperty); - Expression.AndAssign( - succeeded, - Expression.Call( - propertyConverterVar, - nameof(FormDataConverter.TryRead), - Type.EmptyTypes, - readerParam, - Expression.Constant(property.Type), - optionsParam, - GetValueLocalVariableValueExpression(propertyVar), - propertyFoundValue))), - // reader.PopPrefix("PropertyInfo"); - @finally: Expression.Call( - readerParam, - nameof(FormDataReader.PopPrefix), - Array.Empty(), - Expression.Constant(property.Name)), - handlers: Expression.Catch( - exceptionVar, - Expression.Block( - Expression.Call( - readerParam, - nameof(FormDataReader.AddMappingError), - Array.Empty(), - exceptionVar, - Expression.Constant(null, typeof(string))), - Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))) - )))); - - // parameter.found = foundProperty; - body.Add(Expression.Assign(GetValueLocalVariableFoundExpression(propertyVar), propertyFoundValue)); - body.Add(Expression.OrAssign(localFoundValueVar, propertyFoundValue)); - } - } - - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - private static void MapConstructorParameters( - IList constructorParameters, - ParameterExpression readerParam, - ParameterExpression optionsParam, - ParameterExpression propertyFoundValue, - ParameterExpression succeeded, - ParameterExpression localFoundValueVar, - ParameterExpression exceptionVar, - List variables, - List constructorParameterValueLocals, - List body) - { - // Create the constructor property blocks - - // var parameterConverter = options.ResolveConverter(typeof(string)); - // reader.PushPrefix("PropertyInfo"); - // succeeded &= parameterConverter.TryRead(ref reader, typeof(string), options, out constructorParameterVar, out foundProperty); - // found ||= foundProperty; - // reader.PopPrefix("PropertyInfo"); - for (var i = 0; i < constructorParameters.Count; i++) - { - // Declare variable for the converter - var constructorParameter = constructorParameters[i]; - var constructorParameterConverterType = typeof(FormDataConverter<>).MakeGenericType(constructorParameter.Type); - var constructorParameterConverterVar = Expression.Variable(constructorParameterConverterType, $"{constructorParameter.Name}Converter"); - variables.Add(constructorParameterConverterVar); - - // Declare variable for constructorParameter value. - var constructorParameterVar = CreateValueLocalVariable(constructorParameter); - constructorParameterValueLocals.Add(constructorParameterVar); - - // Resolve and assign converter - // Create the block to try and map the constructorParameter and update propsLocals. - // returnParam &= { PushPrefix(constructorParameter.Name); var res = TryRead(...); PopPrefix(...); return res; } - // var constructorParameterConverter = options.ResolveConverter()); - var constructorParameterConverter = Expression.Assign( - constructorParameterConverterVar, - Expression.Call( - optionsParam, - nameof(FormDataMapperOptions.ResolveConverter), - new[] { constructorParameter.Type }, - Array.Empty())); - body.Add(constructorParameterConverter); - - // try - // { - // reader.PushPrefix("PropertyInfo"); - // succeeded &= constructorParameterConverter.TryRead(ref reader, typeof(string), options, out constructorParameterVar, out foundProperty); - // if(!succeeded || !found) - // { - // reader.AddMappingError("Missing required value for constructor property {0}", constructorParameter.Name); - // } - // } - // finally - // { - // reader.PopPrefix("PropertyInfo"); - // } - body.Add(Expression.TryCatchFinally( - body: Expression.Block( - // reader.PushPrefix("PropertyInfo"); - Expression.Call( - readerParam, - nameof(FormDataReader.PushPrefix), - Array.Empty(), - Expression.Constant(constructorParameter.Name)), - // succeeded &= constructorParameterConverter.TryRead(ref reader, typeof(string), options, out constructorParameterVar, out foundProperty); - Expression.AndAssign( - succeeded, - Expression.Call( - constructorParameterConverterVar, - nameof(FormDataConverter.TryRead), - Type.EmptyTypes, - readerParam, - Expression.Constant(constructorParameter.Type), - optionsParam, - GetValueLocalVariableValueExpression(constructorParameterVar), - propertyFoundValue))), - // reader.PopPrefix("PropertyInfo"); - @finally: Expression.Call( - readerParam, - nameof(FormDataReader.PopPrefix), - Array.Empty(), - Expression.Constant(constructorParameter.Name)), - handlers: Expression.Catch( - exceptionVar, - Expression.Block( - Expression.Call( - readerParam, - nameof(FormDataReader.AddMappingError), - Array.Empty(), - exceptionVar, - Expression.Constant(null, typeof(string))), - Expression.Assign(succeeded, Expression.Constant(false, typeof(bool))) - )))); - - // parameter.found = foundProperty; - body.Add(Expression.Assign(GetValueLocalVariableFoundExpression(constructorParameterVar), propertyFoundValue)); - body.Add(Expression.OrAssign(localFoundValueVar, propertyFoundValue)); - } - } - - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - private static Expression GetValueLocalVariableFoundExpression(ParameterExpression constructorParameterVar) - { - return Expression.PropertyOrField(constructorParameterVar, nameof(ValueTuple.Item1)); - } - - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - private static Expression GetValueLocalVariableValueExpression(ParameterExpression constructorParameterVar) => - Expression.PropertyOrField(constructorParameterVar, nameof(ValueTuple.Item2)); - - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - private static ParameterExpression CreateValueLocalVariable(IFormDataValue constructorParameter) - { - return Expression.Variable(typeof(ValueTuple<,>).MakeGenericType(typeof(bool), constructorParameter.Type), constructorParameter.Name); - } - - // For recursive types we need to do a prefix check. - // if(!reader.CurrentPrefixExists()) - // { - // found = false; - // return true; - // } - // - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - private static ConditionalExpression CreatePrefixCheckForRecursiveTypes(ParameterExpression readerParam, ParameterExpression foundValueParam, ParameterExpression succeeded, LabelTarget end) - { - return Expression.IfThen( - Expression.Not(Expression.Call(readerParam, nameof(FormDataReader.CurrentPrefixExists), Array.Empty())), - Expression.Block( - Expression.Assign(foundValueParam, Expression.Constant(false)), - Expression.Assign(succeeded, Expression.Constant(true)), - Expression.Goto(end))); - } - - private static CompiledComplexTypeConverter.ConverterDelegate CreateConverterFunction( - List parameters, - List variables, - List body) - { - var lambda = Expression.Lambda.ConverterDelegate>( - Expression.Block(variables, body), - parameters); - - return lambda.Compile(); - } - - private static FormDataConverterReadParameters CreateFormDataConverterParameters() - { - return new( - Expression.Parameter(typeof(FormDataReader).MakeByRefType(), "reader"), - Expression.Parameter(typeof(Type), "type"), - Expression.Parameter(typeof(FormDataMapperOptions), "options"), - Expression.Parameter(typeof(T).MakeByRefType(), "result"), - Expression.Parameter(typeof(bool).MakeByRefType(), "foundValue")); - } - - private readonly struct FormDataConverterReadParameters - { - public ParameterExpression ReaderParam { get; } - - public ParameterExpression TypeParam { get; } - - public ParameterExpression OptionsParam { get; } - - public ParameterExpression ResultParam { get; } - - public ParameterExpression FoundValueParam { get; } - - public FormDataConverterReadParameters( - ParameterExpression readerParam, - ParameterExpression typeParam, - ParameterExpression optionsParam, - ParameterExpression resultParam, - ParameterExpression foundValueParam) - { - ReaderParam = readerParam; - TypeParam = typeParam; - OptionsParam = optionsParam; - ResultParam = resultParam; - FoundValueParam = foundValueParam; - } - - public void Deconstruct( - out ParameterExpression readerParam, - out ParameterExpression typeParam, - out ParameterExpression optionsParam, - out ParameterExpression resultParam, - out ParameterExpression foundValueParam) - { - readerParam = ReaderParam; - typeParam = TypeParam; - optionsParam = OptionsParam; - resultParam = ResultParam; - foundValueParam = FoundValueParam; - } - } -} - -=== baseTip 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/Metadata/FormDataMetadataFactory.cs:1-428 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.Serialization; -using Microsoft.Extensions.Internal; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping.Metadata; - -internal partial class FormDataMetadataFactory(List factories, ILoggerFactory loggerFactory) -{ - private readonly object _lock = new object(); - private readonly FormMetadataContext _context = new(); - private readonly ParsableConverterFactory _parsableFactory = factories.OfType().Single(); - private readonly DictionaryConverterFactory _dictionaryFactory = factories.OfType().Single(); - private readonly FileConverterFactory _fileConverterFactory = factories.OfType().Single(); - private readonly CollectionConverterFactory _collectionFactory = factories.OfType().Single(); - private readonly ILogger _logger = loggerFactory.CreateLogger(); - - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - public FormDataTypeMetadata? GetOrCreateMetadataFor(Type type, FormDataMapperOptions options) - { - var shouldClearContext = !_context.ResolutionInProgress; - lock (_lock) - { - try - { - // We are walking the graph in order to detect recursive types. - // We evaluate whether a type is: - // 1. Primitive - // 2. Dictionary - // 3. Collection - // 4. Complex - // Only complex types can be recursive. - // We only compute metadata when we are dealing with objects, other classes of - // types are handled directly by the appropriate converters. - // We keep track of the metadata for the types because it is useful when we generate - // the specific object converter for a type. - // The code generation varies depending on whether there is recursion or not within - // the type graph. - if (shouldClearContext) - { - Log.StartResolveMetadataGraph(_logger, type); - _context.BeginResolveGraph(); - } - - // Try to get the metadata for the type or create and add a new instance. - var result = _context.TypeMetadata.TryGetValue(type, out var value) ? value : new FormDataTypeMetadata(type); - if (value == null) - { - Log.NoMetadataFound(_logger, type); - _context.TypeMetadata[type] = result; - } - else - { - Log.MetadataFound(_logger, type); - } - - if (type.IsGenericTypeDefinition) - { - Log.GenericTypeDefinitionNotSupported(_logger, type); - _context.TypeMetadata.Remove(type); - return null; - } - - // Check for cycles and mark any type as recursive if needed. - DetectCyclesAndMarkMetadataTypesAsRecursive(type, result); - - // We found the value on the existing metadata, we can return it. - if (value != null) - { - return result; - } - - // These blocks are evaluated in a specific order. - if (_parsableFactory.CanConvert(type, options) || type.IsEnum || - (Nullable.GetUnderlyingType(type) is { } underlyingType && - _parsableFactory.CanConvert(underlyingType, options))) - { - Log.PrimitiveType(_logger, type); - result.Kind = FormDataTypeKind.Primitive; - return result; - } - - if (_fileConverterFactory.CanConvert(type, options)) - { - result.Kind = FormDataTypeKind.File; - return result; - } - - if (WellKnownConverters.Converters.TryGetValue(type, out var converter)) - { - result.Kind = FormDataTypeKind.Primitive; - return result; - } - - if (_dictionaryFactory.CanConvert(type, options)) - { - Log.DictionaryType(_logger, type); - result.Kind = FormDataTypeKind.Dictionary; - var (keyType, valueType) = DictionaryConverterFactory.ResolveDictionaryTypes(type)!; - result.KeyType = GetOrCreateMetadataFor(keyType, options); - result.ValueType = GetOrCreateMetadataFor(valueType, options); - return result; - } - - if (_collectionFactory.CanConvert(type, options)) - { - Log.CollectionType(_logger, type); - result.Kind = FormDataTypeKind.Collection; - result.ElementType = GetOrCreateMetadataFor(CollectionConverterFactory.ResolveElementType(type)!, options); - return result; - } - - Log.ObjectType(_logger, type); - result.Kind = FormDataTypeKind.Object; - _context.Track(type); - var constructors = type.GetConstructors(); - - if (constructors.Length == 1) - { - result.Constructor = constructors[0]; - if (type.IsAbstract) - { - Log.AbstractClassesNotSupported(_logger, type); - _context.TypeMetadata.Remove(type); - return null; - } - } - else if (constructors.Length > 1) - { - // We can't select the constructor when there are multiple of them. - Log.MultiplePublicConstructorsFound(_logger, type); - return null; - } - else if (!type.IsValueType) - { - if (type.IsInterface) - { - Log.InterfacesNotSupported(_logger, type); - } - else if (type.IsAbstract) - { - Log.AbstractClassesNotSupported(_logger, type); - } - else - { - Log.NoPublicConstructorFound(_logger, type); - } - - _context.TypeMetadata.Remove(type); - // We can't bind to reference types without constructors. - return null; - } - - if (result.Constructor != null) - { - if (_logger.IsEnabled(LogLevel.Debug)) - { - var parameters = $"({string.Join(", ", result.Constructor.GetParameters().Select(p => p.ParameterType.Name))})"; - Log.ConstructorFound(_logger, type, parameters); - } - - var values = result.Constructor.GetParameters(); - - foreach (var parameter in values) - { - Log.ConstructorParameter(_logger, type, parameter.Name!, parameter.ParameterType); - var parameterTypeInfo = GetOrCreateMetadataFor(parameter.ParameterType, options); - if (parameterTypeInfo == null) - { - Log.ConstructorParameterTypeNotSupported(_logger, type, parameter.Name!, parameter.ParameterType); - _context.TypeMetadata.Remove(type); - return null; - } - - result.ConstructorParameters.Add(new FormDataParameterMetadata(parameter, parameterTypeInfo)); - } - } - - var candidateProperty = PropertyHelper.GetVisibleProperties(type); - foreach (var propertyHelper in candidateProperty) - { - var property = propertyHelper.Property; - Log.CandidateProperty(_logger, propertyHelper.Name, property.PropertyType); - var matchingConstructorParameter = result - .ConstructorParameters - .FirstOrDefault(p => string.Equals(p.Name, property.Name, StringComparison.OrdinalIgnoreCase)); - - if (matchingConstructorParameter != null) - { - Log.MatchingConstructorParameterFound(_logger, matchingConstructorParameter.Name, property.Name); - var dataMember = property.GetCustomAttribute(); - if (dataMember != null && dataMember.IsNameSetExplicitly && dataMember.Name != null) - { - Log.CustomParameterNameMetadata(_logger, dataMember.Name, property.Name); - matchingConstructorParameter.Name = dataMember.Name; - } - - // The propertyHelper is already present in the constructor, we don't need to add it again. - continue; - } - - var ignoreDataMember = property.GetCustomAttribute(); - if (ignoreDataMember != null) - { - Log.IgnoredProperty(_logger, property.Name); - // The propertyHelper is marked as ignored, we don't need to add it. - continue; - } - - if (property.SetMethod == null || !property.SetMethod.IsPublic) - { - Log.NonPublicSetter(_logger, property.Name); - // The property is readonly, we don't need to add it. - continue; - } - - var propertyTypeInfo = GetOrCreateMetadataFor(property.PropertyType, options); - if (propertyTypeInfo == null) - { - Log.PropertyTypeNotSupported(_logger, type, property.Name, property.PropertyType); - _context.TypeMetadata.Remove(type); - return null; - } - var propertyInfo = new FormDataPropertyMetadata(property, propertyTypeInfo); - - var dataMemberAttribute = property.GetCustomAttribute(); - if (dataMemberAttribute != null && dataMemberAttribute.IsNameSetExplicitly && dataMemberAttribute.Name != null) - { - Log.CustomParameterNameMetadata(_logger, dataMemberAttribute.Name, property.Name); - propertyInfo.Name = dataMemberAttribute.Name; - propertyInfo.Required = dataMemberAttribute.IsRequired; - Log.PropertyRequired(_logger, propertyInfo.Name); - } - - var requiredAttribute = property.GetCustomAttribute(); - if (requiredAttribute != null) - { - propertyInfo.Required = true; - Log.PropertyRequired(_logger, propertyInfo.Name); - } - - result.Properties.Add(propertyInfo); - } - - Log.MetadataComputed(_logger, type); - return result; - } - finally - { - _context.Untrack(type); - if (shouldClearContext) - { - Log.EndResolveMetadataGraph(_logger, type); - _context.EndResolveGraph(); - } - } - } - } - - internal bool HasMetadataFor(Type type) => _context.TypeMetadata.ContainsKey(type); - - private void DetectCyclesAndMarkMetadataTypesAsRecursive(Type type, FormDataTypeMetadata result) - { - // Mark any type as recursive if its already present in the current resolution graph or - // if there is a base type for it on the resolution graph. - // For example, given A and B : A. With A having a propertyHelper of type B. - // when we inspect B, we can tell that A is recursive because you can have A -> B -> B -> B -> ... - // The opposite scenario is not something we need to worry about because we don't support polymorphism, - // meaning that we will never create an instance of B if the declared type is A. - // In that scenario, A and B : A. With B having a propertyHelper of type A. - // The recursion stops at A, because A doesn't define the propertyHelper and we will never bind B to A. - // If in the future we support polymorphism, it's a matter or updating the logic below to account for it. - for (var i = 0; i < _context.CurrentTypes.Count; i++) - { - if (_context.CurrentTypes[i] == type) - { - // We found an exact match in the current resolution graph. - // This means that the type is recursive. - result.IsRecursive = true; - ReportRecursiveChain(type); - - } - else if (type.IsSubclassOf(_context.CurrentTypes[i])) - { - // We found a type that is assignable from the current type. - // This means that the type is recursive. - var existingType = _context.TypeMetadata[_context.CurrentTypes[i]]; - ReportRecursiveChain(type); - existingType.IsRecursive = true; - } - - // We don't need to check for interfaces here because we never map to an interface, so if we encounter one, we will fail, - // as we can't construct the converter to map the interface to a concrete instance. - } - - void ReportRecursiveChain(Type type) - { - if (_logger.IsEnabled(LogLevel.Debug)) - { - var chain = string.Join(" -> ", _context.CurrentTypes.Append(type).Select(t => t.Name)); - Log.RecursiveTypeFound(_logger, type, chain); - } - } - } - - private class FormMetadataContext - { - public Dictionary TypeMetadata { get; set; } = new(); - - public List CurrentTypes { get; set; } = new(); - - public bool ResolutionInProgress { get; internal set; } - - internal void BeginResolveGraph() - { - if (ResolutionInProgress) - { - throw new InvalidOperationException("Cannot begin a new resolution graph while one is already in progress."); - } - ResolutionInProgress = true; - } - - internal void EndResolveGraph() - { - if (!ResolutionInProgress) - { - throw new InvalidOperationException("Cannot end a resolution graph while one is not in progress."); - } - ResolutionInProgress = false; - CurrentTypes.Clear(); - } - - internal void Track(Type type) - { - CurrentTypes.Add(type); - } - - internal void Untrack(Type type) - { - CurrentTypes.Remove(type); - } - } - - private static partial class Log - { - [LoggerMessage(1, LogLevel.Debug, "Begin resolve metadata graph for type '{Type}'.", EventName = nameof(StartResolveMetadataGraph))] - public static partial void StartResolveMetadataGraph(ILogger logger, Type type); - - [LoggerMessage(2, LogLevel.Debug, "End resolve metadata graph for type '{Type}'.", EventName = nameof(EndResolveMetadataGraph))] - public static partial void EndResolveMetadataGraph(ILogger logger, Type type); - - [LoggerMessage(3, LogLevel.Debug, "Cached metadata found for type '{Type}'.", EventName = nameof(Metadata))] - public static partial void MetadataFound(ILogger logger, Type type); - - [LoggerMessage(4, LogLevel.Debug, "No cached metadata graph for type '{Type}'.", EventName = nameof(NoMetadataFound))] - public static partial void NoMetadataFound(ILogger logger, Type type); - - [LoggerMessage(5, LogLevel.Debug, "Recursive type '{Type}' found in the resolution graph '{Chain}'.", EventName = nameof(RecursiveTypeFound))] - public static partial void RecursiveTypeFound(ILogger logger, Type type, string chain); - - [LoggerMessage(6, LogLevel.Debug, "'{Type}' identified as primitive.", EventName = nameof(PrimitiveType))] - public static partial void PrimitiveType(ILogger logger, Type type); - - [LoggerMessage(7, LogLevel.Debug, "'{Type}' identified as dictionary.", EventName = nameof(DictionaryType))] - public static partial void DictionaryType(ILogger logger, Type type); - - [LoggerMessage(8, LogLevel.Debug, "'{Type}' identified as collection.", EventName = nameof(CollectionType))] - public static partial void CollectionType(ILogger logger, Type type); - - [LoggerMessage(9, LogLevel.Debug, "'{Type}' identified as object.", EventName = nameof(ObjectType))] - public static partial void ObjectType(ILogger logger, Type type); - - [LoggerMessage(10, LogLevel.Debug, "Constructor found for type '{Type}' with parameters '{Parameters}'.", EventName = nameof(ConstructorFound))] - public static partial void ConstructorFound(ILogger logger, Type type, string parameters); - - [LoggerMessage(11, LogLevel.Debug, "Constructor parameter '{Name}' of type '{ParameterType}' found for type '{Type}'.", EventName = nameof(ConstructorParameter))] - public static partial void ConstructorParameter(ILogger logger, Type type, string name, Type parameterType); - - [LoggerMessage(12, LogLevel.Debug, "Candidate property '{Name}' of type '{PropertyType}'.", EventName = nameof(CandidateProperty))] - public static partial void CandidateProperty(ILogger logger, string name, Type propertyType); - - [LoggerMessage(13, LogLevel.Debug, "Candidate property {PropertyName} has a matching constructor parameter '{ConstructorParameterName}'.", EventName = nameof(MatchingConstructorParameterFound))] - public static partial void MatchingConstructorParameterFound(ILogger logger, string constructorParameterName, string propertyName); - - [LoggerMessage(14, LogLevel.Debug, "Candidate property or constructor parameter {PropertyName} defines a custom name '{CustomName}'.", EventName = nameof(CustomParameterNameMetadata))] - public static partial void CustomParameterNameMetadata(ILogger logger, string customName, string propertyName); - - [LoggerMessage(15, LogLevel.Debug, "Candidate property {Name} will not be mapped. It has been explicitly ignored.", EventName = nameof(IgnoredProperty))] - public static partial void IgnoredProperty(ILogger logger, string name); - - [LoggerMessage(16, LogLevel.Debug, "Candidate property {Name} will not be mapped. It has no public setter.", EventName = nameof(NonPublicSetter))] - public static partial void NonPublicSetter(ILogger logger, string name); - - [LoggerMessage(17, LogLevel.Debug, "Candidate property {Name} is marked as required.", EventName = nameof(PropertyRequired))] - public static partial void PropertyRequired(ILogger logger, string name); - - [LoggerMessage(18, LogLevel.Debug, "Metadata created for {Type}.", EventName = nameof(MetadataComputed))] - public static partial void MetadataComputed(ILogger logger, Type type); - - [LoggerMessage(19, LogLevel.Debug, "Can not map type generic type definition '{Type}'.", EventName = nameof(GenericTypeDefinitionNotSupported))] - public static partial void GenericTypeDefinitionNotSupported(ILogger logger, Type type); - - [LoggerMessage(20, LogLevel.Debug, "Unable to select a constructor. Multiple public constructors found for type '{Type}'.", EventName = nameof(MultiplePublicConstructorsFound))] - public static partial void MultiplePublicConstructorsFound(ILogger logger, Type type); - - [LoggerMessage(21, LogLevel.Debug, "Can not map interface type '{Type}'.", EventName = nameof(InterfacesNotSupported))] - public static partial void InterfacesNotSupported(ILogger logger, Type type); - - [LoggerMessage(22, LogLevel.Debug, "Can not map abstract type '{Type}'.", EventName = nameof(AbstractClassesNotSupported))] - public static partial void AbstractClassesNotSupported(ILogger logger, Type type); - - [LoggerMessage(23, LogLevel.Debug, "Unable to select a constructor. No public constructors found for type '{Type}'.", EventName = nameof(NoPublicConstructorFound))] - public static partial void NoPublicConstructorFound(ILogger logger, Type type); - - [LoggerMessage(24, LogLevel.Debug, "Can not map type '{Type}'. Constructor parameter {Name} of type {ParameterType} is not supported.", EventName = nameof(ConstructorParameterTypeNotSupported))] - public static partial void ConstructorParameterTypeNotSupported(ILogger logger, Type type, string name, Type parameterType); - - [LoggerMessage(25, LogLevel.Debug, "Can not map type '{Type}'. Property {Name} of type {PropertyType} is not supported.", EventName = nameof(PropertyTypeNotSupported))] - public static partial void PropertyTypeNotSupported(ILogger logger, Type type, string name, Type propertyType); - } -} - -=== baseTip 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/Metadata/FormDataParameterMetadata.cs:1-25 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Reflection; - -namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping.Metadata; -internal class FormDataParameterMetadata(ParameterInfo parameter, FormDataTypeMetadata parameterTypeInfo) : IFormDataValue -{ - public ParameterInfo Parameter { get; } = parameter; - public string Name { get; set; } = parameter.Name!; - public Type Type { get; set; } = parameter.ParameterType; - - public bool Required => true; - - internal FormDataTypeMetadata ParameterMetadata { get; } = parameterTypeInfo; -} - -internal interface IFormDataValue -{ - public string Name { get; } - - public Type Type { get; } - - public bool Required { get; } -} - -=== baseTip 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/FormDataReader.cs:1-318 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Runtime.CompilerServices; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.WebUtilities; -using Microsoft.Extensions.Primitives; - -namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping; - -[DebuggerDisplay($"{{{nameof(DebuggerDisplay)}(),nq}}")] -internal struct FormDataReader : IDisposable -{ - private readonly IReadOnlyDictionary _readOnlyMemoryKeys; - private readonly Memory _prefixBuffer; - private Memory _currentPrefixBuffer; - private int _currentDepth; - private int _errorCount; - - // As an implementation detail, reuse FormKey for the values. - // It's just a thin wrapper over ReadOnlyMemory that caches - // the computed hash code. - - private PrefixResolver _prefixResolver; - - public FormDataReader(IReadOnlyDictionary formCollection, CultureInfo culture, Memory buffer) - { - _readOnlyMemoryKeys = formCollection; - Culture = culture; - _prefixBuffer = buffer; - } - - public FormDataReader(IReadOnlyDictionary formCollection, CultureInfo culture, Memory buffer, IFormFileCollection formFileCollection) - : this(formCollection, culture, buffer) - { - FormFileCollection = formFileCollection; - } - - internal ReadOnlyMemory CurrentPrefix => _currentPrefixBuffer; - - public IFormatProvider Culture { get; } - - public IFormFileCollection? FormFileCollection { get; internal set; } - - public int MaxRecursionDepth { get; set; } = 64; - - public int MaxCollectionSize { get; set; } = FormReader.DefaultValueCountLimit; - - public Action? ErrorHandler { get; set; } - - public Action? AttachInstanceToErrorsHandler { get; set; } - - public int MaxErrorCount { get; set; } = 200; - - public void AddMappingError(FormattableString errorMessage, string? attemptedValue) - { - ArgumentNullException.ThrowIfNull(errorMessage); - - if (ErrorHandler == null) - { - throw new FormDataMappingException(new FormDataMappingError(_currentPrefixBuffer.ToString(), errorMessage, attemptedValue)); - } - - _errorCount++; - if (_errorCount == MaxErrorCount) - { - ErrorHandler.Invoke( - _currentPrefixBuffer.ToString(), - FormattableStringFactory.Create($"Maximum number of errors ({MaxErrorCount}) reached. Further errors will be suppressed."), - null); - } - - if (_errorCount >= MaxErrorCount) - { - return; - } - - ErrorHandler.Invoke(_currentPrefixBuffer.ToString(), errorMessage, attemptedValue); - } - - public void AddMappingError(Exception exception, string? attemptedValue) - { - ArgumentNullException.ThrowIfNull(exception); - - // Avoid re-wrapping the exception if it is already a FormDataMappingException - // and we don't have an ErrorHandler configured. - if (exception is FormDataMappingException && ErrorHandler == null) - { - throw exception; - } - - var errorMessage = FormattableStringFactory.Create(exception.Message); - AddMappingError(errorMessage, attemptedValue); - } - - public void AttachInstanceToErrors(object value) - { - if (AttachInstanceToErrorsHandler == null) - { - return; - } - - AttachInstanceToErrorsHandler(_currentPrefixBuffer.ToString(), value); - } - - internal FormKeyCollection GetKeys() - { - // Scan the input dictionary for keys matching the current prefix followed by a bracket segment. - // This avoids building a large upfront dictionary of all prefix→key mappings. - var prefix = _currentPrefixBuffer; - var result = new HashSet(); - - foreach (var kvp in _readOnlyMemoryKeys) - { - var key = kvp.Key.Value; - - // The key must start with the current prefix (case-insensitive). - if (key.Length <= prefix.Length || - !key.Span[..prefix.Length].Equals(prefix.Span, StringComparison.OrdinalIgnoreCase)) - { - continue; - } - - // Immediately after the prefix, there must be a '['. - if (key.Span[prefix.Length] != '[') - { - continue; - } - - // Find the closing ']' after the '['. - var remaining = key[prefix.Length..]; - var closeIndex = remaining.Span[1..].IndexOf(']'); - if (closeIndex == -1) - { - // Malformed key — no closing bracket. Skip it. - continue; - } - - // Extract "[value]" (closeIndex is relative to position 1, so add 2 for the full segment). - var segment = remaining[..(closeIndex + 2)]; - result.Add(new FormKey(segment)); - - // Allow one extra item through so collection/dictionary binding can still detect overflow - // and report the existing max-size error instead of silently truncating the input. - if (result.Count > MaxCollectionSize) - { - break; - } - } - - return result.Count > 0 - ? new FormKeyCollection(result) - : FormKeyCollection.Empty; - } - - // This only ever gets invoked if we have a recursive type. - // Recursive types make an existential check for the current prefix to determine if they - // need to continue mapping data. - // At that point, we are placing the keys into a sorted array, and we use binary search to - // determine if the prefix exists. - // We only make this search on recursive paths, as opposed to in every new scope that we push. - internal bool CurrentPrefixExists() - { - if (CurrentPrefix.Span.Length == 0) - { - // Avoid creating the prefix array at the root level. - return _readOnlyMemoryKeys.Count > 0; - } - - if (!_prefixResolver.HasValues) - { - _prefixResolver = new PrefixResolver(_readOnlyMemoryKeys.Keys, _readOnlyMemoryKeys.Count); - } - - return _prefixResolver.HasPrefix(_currentPrefixBuffer); - } - - internal void PopPrefix(string key) - { - PopPrefix(key.AsSpan()); - } - - internal void PopPrefix(ReadOnlySpan key) - { - if (_currentDepth > MaxRecursionDepth) - { - return; - } - - _currentDepth--; - Debug.Assert(_currentDepth >= 0); - var keyLength = key.Length; - // If keyLength is bigger than the current scope keyLength typically means there is a - // bug where some part of the code has not popped the scope appropriately. - Debug.Assert(_currentPrefixBuffer.Length >= keyLength); - if (_currentPrefixBuffer.Length == keyLength || _currentPrefixBuffer.Span[^(keyLength + 1)] != '.') - { - _currentPrefixBuffer = _currentPrefixBuffer[..^keyLength]; - } - else - { - _currentPrefixBuffer = _currentPrefixBuffer[..^(keyLength + 1)]; - } - } - - internal void PushPrefix(string key) - { - PushPrefix(key.AsSpan()); - } - - internal void PushPrefix(scoped ReadOnlySpan key) - { - _currentDepth++; - // We automatically append a "." before adding the suffix, except when its the first element pushed to the - // scope, or when we are accessing a property after a collection or an indexer like items[1]. - var separator = _currentPrefixBuffer.Length > 0 && key[0] != '[' - ? ".".AsSpan() - : "".AsSpan(); - if (_currentDepth > MaxRecursionDepth) - { - throw new InvalidOperationException($"The maximum recursion depth of '{MaxRecursionDepth}' was exceeded for '{_currentPrefixBuffer}{separator}{key}'."); - } - - Debug.Assert(_prefixBuffer.Length >= (_currentPrefixBuffer.Length + separator.Length)); - - separator.CopyTo(_prefixBuffer.Span[_currentPrefixBuffer.Length..]); - - var startingPoint = _currentPrefixBuffer.Length + separator.Length; - _currentPrefixBuffer = _prefixBuffer.Slice(0, startingPoint + key.Length); - key.CopyTo(_prefixBuffer[startingPoint..].Span); - } - - internal readonly bool TryGetValue([NotNullWhen(true)] out string? value) - { - var foundSingleValue = _readOnlyMemoryKeys.TryGetValue(new FormKey(_currentPrefixBuffer), out var result) || result.Count == 1; - if (foundSingleValue) - { - value = result[0]; - } - else - { - value = null; - } - - return foundSingleValue; - } - - internal readonly bool TryGetValues(out StringValues values) => - _readOnlyMemoryKeys.TryGetValue(new FormKey(_currentPrefixBuffer), out values); - - internal string GetPrefix() => _currentPrefixBuffer.ToString(); - - internal string GetLastPrefixSegment() - { - var index = _currentPrefixBuffer.Span.LastIndexOfAny(".["); - if (index == -1) - { - return _currentPrefixBuffer.ToString(); - } - if (_currentPrefixBuffer.Span[index] == '.') - { - return _currentPrefixBuffer.Span[(index + 1)..].ToString(); - } - else - { - // Return the value without the closing bracket ] - return _currentPrefixBuffer.Span[(index + 1)..^1].ToString(); - } - } - - public void Dispose() - { - _prefixResolver.Dispose(); - } - - internal readonly struct FormKeyCollection : IEnumerable> - { - private readonly HashSet _values; - internal static readonly FormKeyCollection Empty; - - public bool HasValues() => _values != null; - - public FormKeyCollection(HashSet values) => _values = values; - - public Enumerator GetEnumerator() => new Enumerator(_values.GetEnumerator()); - - IEnumerator> IEnumerable>.GetEnumerator() => GetEnumerator(); - - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - - internal struct Enumerator : IEnumerator> - { - private HashSet.Enumerator _enumerator; - - public Enumerator(HashSet.Enumerator enumerator) - { - _enumerator = enumerator; - } - - public ReadOnlyMemory Current => _enumerator.Current.Value; - - object IEnumerator.Current => _enumerator.Current; - - void IDisposable.Dispose() => _enumerator.Dispose(); - - public bool MoveNext() => _enumerator.MoveNext(); - - void IEnumerator.Reset() { } - } - } - - private readonly string DebuggerDisplay => - $"Key count = {_readOnlyMemoryKeys.Count}, Prefix = {_currentPrefixBuffer}, Error count = {_errorCount}, Current depth = {_currentDepth}"; -} - -=== baseTip 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/FormDataMapper.cs:1-48 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -using Microsoft.Extensions.Logging; - -namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping; - -internal static partial class FormDataMapper -{ - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - public static T? Map( - FormDataReader reader, - FormDataMapperOptions options) - { - FormDataConverter? converter; - try - { - converter = options.ResolveConverter(); - if (converter == null) - { - Log.CannotResolveConverter(options.Logger, typeof(T), null); - return default; - } - } - catch (Exception ex) - { - Log.CannotResolveConverter(options.Logger, typeof(T), ex); - return default; - } - - if (converter.TryRead(ref reader, typeof(T), options, out var result, out _)) - { - return result; - } - - // Always return the result, even if it has failures. This is because we do not want - // to loose the data that we were able to deserialize. - return result; - } - - private static partial class Log - { - [LoggerMessage(1, LogLevel.Warning, "Cannot resolve converter for type '{Type}'.", EventName = "CannotResolveConverter")] - public static partial void CannotResolveConverter(ILogger logger, Type type, Exception? ex); - } -} - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/case.source b/eng/skill-evals/review-pull-request/fixtures/case-02/case.source deleted file mode 100644 index a6e91438784d..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-02/case.source +++ /dev/null @@ -1,8 +0,0 @@ -Repository: dotnet/aspnetcore -Pull request: https://github.com/dotnet/aspnetcore/pull/69782 -Head: cfe304ed94f2c9de0e1069947ba51c8c82690ba7 -Merge base: 4f556f73a610b386e5ec29355a300e493d30c4c5 -Base tip: 4f556f73a610b386e5ec29355a300e493d30c4c5 -The source files are excerpts, not a complete ready version-2 review bundle. -provenance.json maps every excerpt to its original source path and lines. -C1: Changing found to false for an unmatched IReadOnlyList causes a required constructor parameter to report a mapping error where the old mapper supplied an empty collection. Consider mapping a complex type with constructor IReadOnlyList files and a populated non-file property, with form files named otherFile and none named files. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/change.diff b/eng/skill-evals/review-pull-request/fixtures/case-02/change.diff deleted file mode 100644 index e7645aff4bd1..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-02/change.diff +++ /dev/null @@ -1,34 +0,0 @@ -diff --git a/src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs b/src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs -index fb2d1b74ea..1218cae3d7 100644 ---- a/src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs -+++ b/src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs -@@ -44,22 +44,25 @@ internal sealed class FileConverter : FormDataConverter - buffer = ReadOnlyCollectionBufferAdapter.Add(ref buffer, new BrowserFileFromFormFile(targetFiles[i])); - } - result = (T)(IReadOnlyList)ReadOnlyCollectionBufferAdapter.ToResult(buffer); -- found = true; -+ found = targetFiles.Count > 0; - return true; - } - #endif - - if (typeof(T) == typeof(IReadOnlyList)) - { -- result = (T)reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); -- found = true; -+ var targetFiles = reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); -+ result = (T)targetFiles; -+ found = targetFiles.Count > 0; - return true; - } - - if (typeof(T) == typeof(IFormFileCollection)) - { - result = (T)reader.FormFileCollection; -- found = true; -+ found = reader.CurrentPrefix.Span.IndexOf('[') < 0 -+ ? reader.FormFileCollection.Count > 0 -+ : reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()).Count > 0; - return true; - } - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/context.source b/eng/skill-evals/review-pull-request/fixtures/case-02/context.source deleted file mode 100644 index 992e68d82656..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-02/context.source +++ /dev/null @@ -1,19 +0,0 @@ -=== head cfe304ed94f2c9de0e1069947ba51c8c82690ba7 src/Components/Endpoints/test/Binding/FormDataMapperTests.cs:2512-2528 === - public void CanDeserialize_ComplexType_IReadOnlyListFormFileWithNoMatches_IsNotFound() - { - var formFileCollection = new FormFileCollection - { - new FormFile(Stream.Null, 0, 10, "otherFile", "file.txt"), - }; - var data = new Dictionary(); - var reader = CreateFormDataReader(data, CultureInfo.InvariantCulture, formFileCollection); - reader.PushPrefix("file"); - var converter = new FileConverter>(); - - var succeeded = converter.TryRead(ref reader, typeof(IReadOnlyList), default!, out var result, out var found); - - Assert.True(succeeded); - Assert.False(found); - Assert.Empty(result); - } - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/head.source b/eng/skill-evals/review-pull-request/fixtures/case-02/head.source deleted file mode 100644 index 9ffd38a2455f..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-02/head.source +++ /dev/null @@ -1,91 +0,0 @@ -=== head cfe304ed94f2c9de0e1069947ba51c8c82690ba7 src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs:1-89 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -#if COMPONENTS -using Microsoft.AspNetCore.Components.Forms; -#endif -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping; - -internal sealed class FileConverter : FormDataConverter -{ - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - internal override bool TryRead(ref FormDataReader reader, Type type, FormDataMapperOptions options, out T? result, out bool found) - { - if (reader.FormFileCollection == null) - { - result = default; - found = false; - return true; - } - -#if COMPONENTS - if (typeof(T) == typeof(IBrowserFile)) - { - var targetFile = reader.FormFileCollection.GetFile(reader.CurrentPrefix.ToString()); - if (targetFile != null) - { - var browserFile = new BrowserFileFromFormFile(targetFile); - result = (T)(IBrowserFile)browserFile; - found = true; - return true; - } - } - - if (typeof(T) == typeof(IReadOnlyList)) - { - var targetFiles = reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); - var buffer = ReadOnlyCollectionBufferAdapter.CreateBuffer(); - for (var i = 0; i < targetFiles.Count; i++) - { - buffer = ReadOnlyCollectionBufferAdapter.Add(ref buffer, new BrowserFileFromFormFile(targetFiles[i])); - } - result = (T)(IReadOnlyList)ReadOnlyCollectionBufferAdapter.ToResult(buffer); - found = targetFiles.Count > 0; - return true; - } -#endif - - if (typeof(T) == typeof(IReadOnlyList)) - { - var targetFiles = reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); - result = (T)targetFiles; - found = targetFiles.Count > 0; - return true; - } - - if (typeof(T) == typeof(IFormFileCollection)) - { - result = (T)reader.FormFileCollection; - found = reader.CurrentPrefix.Span.IndexOf('[') < 0 - ? reader.FormFileCollection.Count > 0 - : reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()).Count > 0; - return true; - } - - var formFileCollection = reader.FormFileCollection; - if (formFileCollection.Count == 0) - { - result = default; - found = false; - return true; - } - - var file = formFileCollection.GetFile(reader.CurrentPrefix.ToString()); - if (file != null) - { - result = (T)file; - found = true; - return true; - } - - result = default; - found = false; - return true; - } -} - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/mergeBase.source b/eng/skill-evals/review-pull-request/fixtures/case-02/mergeBase.source deleted file mode 100644 index 528e2e1a1123..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-02/mergeBase.source +++ /dev/null @@ -1,88 +0,0 @@ -=== mergeBase 4f556f73a610b386e5ec29355a300e493d30c4c5 src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs:1-86 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -#if COMPONENTS -using Microsoft.AspNetCore.Components.Forms; -#endif -using Microsoft.AspNetCore.Http; - -namespace Microsoft.AspNetCore.Components.Endpoints.FormMapping; - -internal sealed class FileConverter : FormDataConverter -{ - [RequiresDynamicCode(FormMappingHelpers.RequiresDynamicCodeMessage)] - [RequiresUnreferencedCode(FormMappingHelpers.RequiresUnreferencedCodeMessage)] - internal override bool TryRead(ref FormDataReader reader, Type type, FormDataMapperOptions options, out T? result, out bool found) - { - if (reader.FormFileCollection == null) - { - result = default; - found = false; - return true; - } - -#if COMPONENTS - if (typeof(T) == typeof(IBrowserFile)) - { - var targetFile = reader.FormFileCollection.GetFile(reader.CurrentPrefix.ToString()); - if (targetFile != null) - { - var browserFile = new BrowserFileFromFormFile(targetFile); - result = (T)(IBrowserFile)browserFile; - found = true; - return true; - } - } - - if (typeof(T) == typeof(IReadOnlyList)) - { - var targetFiles = reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); - var buffer = ReadOnlyCollectionBufferAdapter.CreateBuffer(); - for (var i = 0; i < targetFiles.Count; i++) - { - buffer = ReadOnlyCollectionBufferAdapter.Add(ref buffer, new BrowserFileFromFormFile(targetFiles[i])); - } - result = (T)(IReadOnlyList)ReadOnlyCollectionBufferAdapter.ToResult(buffer); - found = true; - return true; - } -#endif - - if (typeof(T) == typeof(IReadOnlyList)) - { - result = (T)reader.FormFileCollection.GetFiles(reader.CurrentPrefix.ToString()); - found = true; - return true; - } - - if (typeof(T) == typeof(IFormFileCollection)) - { - result = (T)reader.FormFileCollection; - found = true; - return true; - } - - var formFileCollection = reader.FormFileCollection; - if (formFileCollection.Count == 0) - { - result = default; - found = false; - return true; - } - - var file = formFileCollection.GetFile(reader.CurrentPrefix.ToString()); - if (file != null) - { - result = (T)file; - found = true; - return true; - } - - result = default; - found = false; - return true; - } -} - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-02/provenance.json b/eng/skill-evals/review-pull-request/fixtures/case-02/provenance.json deleted file mode 100644 index 0965e2678f3f..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-02/provenance.json +++ /dev/null @@ -1,151 +0,0 @@ -{ - "repository": "dotnet/aspnetcore", - "pullRequest": 69782, - "sourceRoles": { - "mergeBase": "4f556f73a610b386e5ec29355a300e493d30c4c5", - "head": "cfe304ed94f2c9de0e1069947ba51c8c82690ba7", - "baseTip": "4f556f73a610b386e5ec29355a300e493d30c4c5" - }, - "files": [ - { - "file": "mergeBase.source", - "sha256": "8abba8f0360a7d24e52517cecef7e365f689fa554df5dd81ad58aa6e7d9f5f4a", - "sources": [ - { - "role": "mergeBase", - "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", - "path": "src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs", - "blob": "fb2d1b74eae55c6c61cfb3bfbf30b4f08c2c79ff", - "ranges": [ - [ - 1, - 86 - ] - ] - } - ] - }, - { - "file": "head.source", - "sha256": "69b46771aa41acfbc6394eb67e7024eaf1900485561a562cbd78dff3e2b15571", - "sources": [ - { - "role": "head", - "commit": "cfe304ed94f2c9de0e1069947ba51c8c82690ba7", - "path": "src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs", - "blob": "1218cae3d76bff951a6711a966648ed08fc66b6b", - "ranges": [ - [ - 1, - 89 - ] - ] - } - ] - }, - { - "file": "baseTip.source", - "sha256": "70227fa96f82af98184a4ee45d5f34fcad6aae1c595f2efce558235dc5b335a6", - "sources": [ - { - "role": "baseTip", - "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", - "path": "src/Components/Endpoints/src/FormMapping/Converters/FileConverter.cs", - "blob": "fb2d1b74eae55c6c61cfb3bfbf30b4f08c2c79ff", - "ranges": [ - [ - 1, - 86 - ] - ] - }, - { - "role": "baseTip", - "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", - "path": "src/Components/Endpoints/src/FormMapping/Factories/ComplexType/ComplexTypeExpressionConverterFactoryOfT.cs", - "blob": "96146387c11ca2a7fa96a06b9e1fbdea515923b6", - "ranges": [ - [ - 1, - 621 - ] - ] - }, - { - "role": "baseTip", - "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", - "path": "src/Components/Endpoints/src/FormMapping/Metadata/FormDataMetadataFactory.cs", - "blob": "ff2fa90f11333969775a6b426c46581310936114", - "ranges": [ - [ - 1, - 428 - ] - ] - }, - { - "role": "baseTip", - "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", - "path": "src/Components/Endpoints/src/FormMapping/Metadata/FormDataParameterMetadata.cs", - "blob": "1d631872df400af8e691dbed26218491bb3daed2", - "ranges": [ - [ - 1, - 25 - ] - ] - }, - { - "role": "baseTip", - "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", - "path": "src/Components/Endpoints/src/FormMapping/FormDataReader.cs", - "blob": "f142f0e9e003ea913fbc66149ca9634449e99b1b", - "ranges": [ - [ - 1, - 318 - ] - ] - }, - { - "role": "baseTip", - "commit": "4f556f73a610b386e5ec29355a300e493d30c4c5", - "path": "src/Components/Endpoints/src/FormMapping/FormDataMapper.cs", - "blob": "00873d0f9baf500d71c719697aabd3d10cfc632a", - "ranges": [ - [ - 1, - 48 - ] - ] - } - ] - }, - { - "file": "context.source", - "sha256": "8217b34af259159122162b8dc3ed55bbac2546d86c7dca8ed69cdb8a6cf2230b", - "sources": [ - { - "role": "head", - "commit": "cfe304ed94f2c9de0e1069947ba51c8c82690ba7", - "path": "src/Components/Endpoints/test/Binding/FormDataMapperTests.cs", - "blob": "1c8d7e66f14c3cb1264589608657ed6bdb7bbb30", - "ranges": [ - [ - 2512, - 2528 - ] - ] - } - ] - }, - { - "file": "change.diff", - "sha256": "19e641ec597c9b3d9d3d3985178bc2e34713fa628eeb0616cca4ba757b025f56" - }, - { - "file": "case.source", - "sha256": "4325461840a90e04aef5ad5eff7734c3e386343a21e45aa158a4474710b12985" - } - ] -} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/baseTip.source b/eng/skill-evals/review-pull-request/fixtures/case-03/baseTip.source deleted file mode 100644 index 67c86497d5b8..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-03/baseTip.source +++ /dev/null @@ -1,127 +0,0 @@ -=== baseTip 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 src/Components/Components/src/RenderHandle.cs:1-125 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Diagnostics.CodeAnalysis; -using Microsoft.AspNetCore.Components.HotReload; -using Microsoft.AspNetCore.Components.RenderTree; -using Microsoft.AspNetCore.Components.Sections; - -namespace Microsoft.AspNetCore.Components; - -/// -/// Allows a component to interact with its renderer. -/// -public readonly struct RenderHandle -{ - private readonly Renderer? _renderer; - private readonly int _componentId; - - internal RenderHandle(Renderer renderer, int componentId) - { - _renderer = renderer ?? throw new ArgumentNullException(nameof(renderer)); - _componentId = componentId; - } - - internal ComponentsMetrics? ComponentMetrics => _renderer?.ComponentMetrics; - internal ComponentsActivitySource? ComponentActivitySource => _renderer?.ComponentActivitySource; - internal SectionRegistry SectionRegistry => _renderer?.SectionRegistry ?? throw new InvalidOperationException("No renderer has been initialized."); - - /// - /// Gets the associated with the component. - /// - public Dispatcher Dispatcher - { - get - { - if (_renderer == null) - { - ThrowNotInitialized(); - } - - return _renderer.Dispatcher; - } - } - - /// - /// Gets a value that indicates whether the has been - /// initialized and is ready to use. - /// - public bool IsInitialized => _renderer is not null; - - /// - /// Gets a value that determines if the is triggering a render in response to a metadata update (hot-reload) change. - /// - public bool IsRenderingOnMetadataUpdate => HotReloadManager.IsSupported && (_renderer?.IsRenderingOnMetadataUpdate ?? false); - - internal bool IsFirstHotReloadRender() => IsRenderingOnMetadataUpdate && _renderer?.IsFirstHotReloadRender(_componentId) == true; - - internal bool IsRendererDisposed => _renderer?.Disposed - ?? throw new InvalidOperationException("No renderer has been initialized."); - - /// - /// Gets the the component is running on. - /// - public RendererInfo RendererInfo => _renderer?.RendererInfo ?? throw new InvalidOperationException("No renderer has been initialized."); - - /// - /// Retrieves the assigned to the component. - /// - /// The assigned to the component. - public IComponentRenderMode? RenderMode - { - get - { - if (_renderer == null) - { - throw new InvalidOperationException("No renderer has been initialized."); - } - - return _renderer.GetComponentRenderMode(_componentId); - } - } - - /// - /// Gets the associated with the . - /// - public ResourceAssetCollection Assets - { - get - { - return _renderer?.Assets ?? throw new InvalidOperationException("No renderer has been initialized."); - } - } - - /// - /// Notifies the renderer that the component should be rendered. - /// - /// The content that should be rendered. - public void Render(RenderFragment renderFragment) - { - if (_renderer == null) - { - ThrowNotInitialized(); - } - - _renderer.AddToRenderQueue(_componentId, renderFragment); - } - - /// - /// Dispatches an to the . - /// - /// The that will be dispatched to the renderer. - /// A that will be completed when the exception has finished dispatching. - public Task DispatchExceptionAsync(Exception exception) - { - var renderer = _renderer; - var componentId = _componentId; - return Dispatcher.InvokeAsync(() => renderer!.HandleComponentException(exception, componentId)); - } - - [DoesNotReturn] - private static void ThrowNotInitialized() - { - throw new InvalidOperationException("The render handle is not yet assigned."); - } -} - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/case.source b/eng/skill-evals/review-pull-request/fixtures/case-03/case.source deleted file mode 100644 index 61014c106768..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-03/case.source +++ /dev/null @@ -1,8 +0,0 @@ -Repository: dotnet/aspnetcore -Pull request: https://github.com/dotnet/aspnetcore/pull/70304 -Head: fd7be3828242ffabf3f64d230bfb511bbe42f553 -Merge base: 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 -Base tip: 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 -The source files are excerpts, not a complete ready version-2 review bundle. -provenance.json maps every excerpt to its original source path and lines. -C1: The new _rendererIsDisposed guard removes previously functioning ErrorBoundary delivery for DispatchExceptionAsync called by background work after Renderer.Dispose completes. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/change.diff b/eng/skill-evals/review-pull-request/fixtures/case-03/change.diff deleted file mode 100644 index 8dbf27563705..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-03/change.diff +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/src/Components/Components/src/RenderTree/Renderer.cs b/src/Components/Components/src/RenderTree/Renderer.cs -index 43130ce396..1b66058ffd 100644 ---- a/src/Components/Components/src/RenderTree/Renderer.cs -+++ b/src/Components/Components/src/RenderTree/Renderer.cs -@@ -1180,7 +1180,14 @@ public abstract partial class Renderer : IDisposable, IAsyncDisposable - } - - internal void HandleComponentException(Exception exception, int componentId) -- => HandleExceptionViaErrorBoundary(exception, GetRequiredComponentState(componentId)); -+ { -+ if (_rendererIsDisposed) -+ { -+ return; -+ } -+ -+ HandleExceptionViaErrorBoundary(exception, GetRequiredComponentState(componentId)); -+ } - - /// - /// If the exception can be routed to an error boundary around , do so. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/context.source b/eng/skill-evals/review-pull-request/fixtures/case-03/context.source deleted file mode 100644 index 139698b0fd40..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-03/context.source +++ /dev/null @@ -1,116 +0,0 @@ -=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/test/RendererTest.cs:6095-6106 === - public async Task DispatchExceptionAsync_AfterRendererIsDisposed_DoesNotThrow() - { - var renderer = new TestRenderer(); - var component = new DispatchExceptionComponent(); - var componentId = renderer.AssignRootComponentId(component); - await renderer.RenderRootComponentAsync(componentId); - renderer.Dispose(); - - await component.DispatchAsync(new InvalidTimeZoneException("Test exception")); - - Assert.Empty(renderer.HandledExceptions); - } - -=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/test/RendererTest.cs:6109-6121 === - public async Task DispatchExceptionAsync_AfterComponentIsRemoved_Throws() - { - var renderer = new TestRenderer(); - var component = new DispatchExceptionComponent(); - var componentId = renderer.AssignRootComponentId(component); - await renderer.RenderRootComponentAsync(componentId); - await renderer.Dispatcher.InvokeAsync(() => renderer.RemoveRootComponent(componentId)); - - var exception = await Assert.ThrowsAsync(() => component.DispatchAsync(new InvalidTimeZoneException("Test exception"))); - - Assert.Equal($"The renderer does not have a component with ID {componentId}.", exception.Message); - Assert.Empty(renderer.HandledExceptions); - } - -=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/test/RendererTest.cs:6232-6258 === - public async Task DispatchExceptionAsync_LiveComponent_UsesClosestErrorBoundary() - { - var renderer = new TestRenderer(); - var rootComponentId = renderer.AssignRootComponentId(new TestComponent(builder => - { - TestErrorBoundary.RenderNestedErrorBoundaries(builder, builder => - { - builder.OpenComponent(0); - builder.CloseComponent(); - }); - })); - await renderer.RenderRootComponentAsync(rootComponentId); - var batch = Assert.Single(renderer.Batches); - var componentFrame = Assert.Single(batch.GetComponentFrames()); - var component = (DispatchExceptionComponent)componentFrame.Component; - var errorBoundaries = batch.GetComponentFrames() - .Select(frame => (TestErrorBoundary)frame.Component).ToArray(); - var exception = new InvalidTimeZoneException("Test exception"); - - await component.DispatchAsync(exception); - - Assert.Collection(errorBoundaries, - boundary => Assert.Null(boundary.ReceivedException), - boundary => Assert.Same(exception, boundary.ReceivedException)); - Assert.Empty(renderer.HandledExceptions); - Assert.Equal(componentFrame.ComponentId, Assert.Single(renderer.Batches[1].DisposedComponentIDs)); - } - -=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/test/RendererTest.cs:6291-6294 === - private class DispatchExceptionComponent : ComponentBase - { - public Task DispatchAsync(Exception exception) => DispatchExceptionAsync(exception); - } - - -=== https://github.com/dotnet/aspnetcore/issues/66322 === -### Describe the bug - -I originally reported this issue on the .NET MAUI side: https://github.com/dotnet/maui/issues/34855. While investigating, I encountered several exceptions, and I believe the specific case described below belongs in this repository. - -Consider the following: - -```csharp -@code { - private bool _loading; - - protected override async Task OnInitializedAsync() - { - await base.OnInitializedAsync(); - _ = BackgroundWork(); - } - - private async Task BackgroundWork() - { - _loading = true; - await InvokeAsync(StateHasChanged); - - try - { - await Task.Delay(5000); - throw new Exception("Exception"); - } - catch (Exception exception) - { - // MainLayout needs to be wrapped in ErrorBoundary - await DispatchExceptionAsync(exception); - } - finally - { - _loading = false; - await InvokeAsync(StateHasChanged); - } - } -} -``` - -If the browser is closed while `Task.Delay` is still in progress and the WebView is **explicitly disposed**(!!!) via `BlazorWebView.DisposeAsync()`, an exception `Renderer does not have a component with ID XX` is thrown. -If the WebView is not explicitly disposed, a different exception occurs instead, related to the `WebView2` control already being disposed. - -This behavior has been reproduced in WPF. I have not tested WinForms, but I expect similar behavior since most of the code is shared (aside from the dispatcher). I have also not verified whether this affects MAUI Hybrid. - - -### Expected Behavior - -Not to throw exception when webview is disposed. - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/head.source b/eng/skill-evals/review-pull-request/fixtures/case-03/head.source deleted file mode 100644 index 4f8cffe2c414..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-03/head.source +++ /dev/null @@ -1,182 +0,0 @@ -=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/src/RenderTree/Renderer.cs:802-805 === - internal ComponentState GetRequiredComponentState(int componentId) - => _componentStateById.TryGetValue(componentId, out var componentState) - ? componentState - : throw new ArgumentException($"The renderer does not have a component with ID {componentId}."); - -=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/src/RenderTree/Renderer.cs:1182-1190 === - internal void HandleComponentException(Exception exception, int componentId) - { - if (_rendererIsDisposed) - { - return; - } - - HandleExceptionViaErrorBoundary(exception, GetRequiredComponentState(componentId)); - } - -=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/src/RenderTree/Renderer.cs:1196-1240 === - private void HandleExceptionViaErrorBoundary(Exception error, ComponentState? errorSourceOrNull) - { - // We only get here in specific situations. Currently, all of them are when we're - // already on the sync context (and if not, we have a bug we want to know about). - Dispatcher.AssertAccess(); - - // We don't allow NavigationException instances to be caught by error boundaries. - // These are special exceptions whose purpose is to be as invisible as possible to - // user code and bubble all the way up to get handled by the framework as a redirect. - if (error is NavigationException) - { - HandleException(error); - return; - } - - // Find the closest error boundary, if any - var candidate = errorSourceOrNull; - while (candidate is not null) - { - if (candidate.Component is IErrorBoundary errorBoundary) - { - // Don't just trust the error boundary to dispose its subtree - force it to do so by - // making it render an empty fragment. Ensures that failed components don't continue to - // operate, which would be a whole new kind of edge case to support forever. - AddToRenderQueue(candidate.ComponentId, builder => { }); - - try - { - errorBoundary.HandleException(error); - } - catch (Exception errorBoundaryException) - { - // If *notifying* about an exception fails, it's OK for that to be fatal - HandleException(errorBoundaryException); - } - - return; // Handled successfully - } - - candidate = candidate.LogicalParentComponentState; - } - - // It's unhandled, so treat as fatal - HandleException(error); - } - -=== head fd7be3828242ffabf3f64d230bfb511bbe42f553 src/Components/Components/src/RenderTree/Renderer.cs:1246-1361 === - protected virtual void Dispose(bool disposing) - { - // Unlike other Renderer APIs, we need Dispose to be thread-safe - // (and not require being called only from the sync context) - // because other classes many need to dispose a Renderer during their own Dispose (rather than DisposeAsync) - // and we don't want to force that other code to deal with calling InvokeAsync from a synchronous method. - lock (_lockObject) - { - if (_rendererIsDisposed) - { - // quitting synchronously as soon as possible is avoiding - // possible async dispatch to another thread and - // possible deadlock on synchronous `done.Wait()` below. - return; - } - } - - if (!Dispatcher.CheckAccess()) - { - // It's important that we only call the components' Dispose/DisposeAsync lifecycle methods - // on the sync context, like other lifecycle methods. In almost all cases we'd already be - // on the sync context here since DisposeAsync dispatches, but just in case someone is using - // Dispose directly, we'll dispatch and block. - var done = Dispatcher.InvokeAsync(() => Dispose(disposing)); - - // only block caller when this is not finalizer - if (disposing) - { - done.Wait(); - } - - return; - } - - lock (_lockObject) - { - _rendererIsDisposed = true; - } - - if (HotReload.HotReloadManager.IsSupported && HotReloadManager != null && _hotReloadInitialized && _hotReloadRenderHandler is not null) - { - HotReloadManager.OnDeltaApplied -= _hotReloadRenderHandler.RerenderOnHotReload; - } - - // It's important that we handle all exceptions here before reporting any of them. - // This way we can dispose all components before an error handler kicks in. - List exceptions = null; - List asyncDisposables = null; - foreach (var componentState in _componentStateById.Values) - { - Log.DisposingComponent(_logger, componentState); - - try - { - var task = componentState.DisposeAsync(); - if (task.IsCompletedSuccessfully) - { - // If it's a IValueTaskSource backed ValueTask, - // inform it its result has been read so it can reset - task.GetAwaiter().GetResult(); - } - else - { - asyncDisposables ??= new(); - asyncDisposables.Add(task.AsTask()); - } - } - catch (Exception exception) - { - exceptions ??= new List(); - exceptions.Add(exception); - } - } - - _componentStateById.Clear(); // So we know they were all disposed - _componentStateByComponent.Clear(); - _batchBuilder.Dispose(); - - NotifyExceptions(exceptions); - - if (asyncDisposables?.Count >= 1) - { - _disposeTask = HandleAsyncExceptions(asyncDisposables); - } - - async Task HandleAsyncExceptions(List tasks) - { - List asyncExceptions = null; - foreach (var task in tasks) - { - try - { - await task; - } - catch (Exception exception) - { - asyncExceptions ??= new List(); - asyncExceptions.Add(exception); - } - } - - NotifyExceptions(asyncExceptions); - } - - void NotifyExceptions(List exceptions) - { - if (exceptions?.Count > 1) - { - HandleException(new AggregateException("Exceptions were encountered while disposing components.", exceptions)); - } - else if (exceptions?.Count == 1) - { - HandleException(exceptions[0]); - } - } - } - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/mergeBase.source b/eng/skill-evals/review-pull-request/fixtures/case-03/mergeBase.source deleted file mode 100644 index f7cadb6f4a2e..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-03/mergeBase.source +++ /dev/null @@ -1,175 +0,0 @@ -=== mergeBase 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 src/Components/Components/src/RenderTree/Renderer.cs:802-805 === - internal ComponentState GetRequiredComponentState(int componentId) - => _componentStateById.TryGetValue(componentId, out var componentState) - ? componentState - : throw new ArgumentException($"The renderer does not have a component with ID {componentId}."); - -=== mergeBase 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 src/Components/Components/src/RenderTree/Renderer.cs:1182-1183 === - internal void HandleComponentException(Exception exception, int componentId) - => HandleExceptionViaErrorBoundary(exception, GetRequiredComponentState(componentId)); - -=== mergeBase 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 src/Components/Components/src/RenderTree/Renderer.cs:1189-1233 === - private void HandleExceptionViaErrorBoundary(Exception error, ComponentState? errorSourceOrNull) - { - // We only get here in specific situations. Currently, all of them are when we're - // already on the sync context (and if not, we have a bug we want to know about). - Dispatcher.AssertAccess(); - - // We don't allow NavigationException instances to be caught by error boundaries. - // These are special exceptions whose purpose is to be as invisible as possible to - // user code and bubble all the way up to get handled by the framework as a redirect. - if (error is NavigationException) - { - HandleException(error); - return; - } - - // Find the closest error boundary, if any - var candidate = errorSourceOrNull; - while (candidate is not null) - { - if (candidate.Component is IErrorBoundary errorBoundary) - { - // Don't just trust the error boundary to dispose its subtree - force it to do so by - // making it render an empty fragment. Ensures that failed components don't continue to - // operate, which would be a whole new kind of edge case to support forever. - AddToRenderQueue(candidate.ComponentId, builder => { }); - - try - { - errorBoundary.HandleException(error); - } - catch (Exception errorBoundaryException) - { - // If *notifying* about an exception fails, it's OK for that to be fatal - HandleException(errorBoundaryException); - } - - return; // Handled successfully - } - - candidate = candidate.LogicalParentComponentState; - } - - // It's unhandled, so treat as fatal - HandleException(error); - } - -=== mergeBase 1c94b15aa54d3d490d0ee060b7d496db3cb291e7 src/Components/Components/src/RenderTree/Renderer.cs:1239-1354 === - protected virtual void Dispose(bool disposing) - { - // Unlike other Renderer APIs, we need Dispose to be thread-safe - // (and not require being called only from the sync context) - // because other classes many need to dispose a Renderer during their own Dispose (rather than DisposeAsync) - // and we don't want to force that other code to deal with calling InvokeAsync from a synchronous method. - lock (_lockObject) - { - if (_rendererIsDisposed) - { - // quitting synchronously as soon as possible is avoiding - // possible async dispatch to another thread and - // possible deadlock on synchronous `done.Wait()` below. - return; - } - } - - if (!Dispatcher.CheckAccess()) - { - // It's important that we only call the components' Dispose/DisposeAsync lifecycle methods - // on the sync context, like other lifecycle methods. In almost all cases we'd already be - // on the sync context here since DisposeAsync dispatches, but just in case someone is using - // Dispose directly, we'll dispatch and block. - var done = Dispatcher.InvokeAsync(() => Dispose(disposing)); - - // only block caller when this is not finalizer - if (disposing) - { - done.Wait(); - } - - return; - } - - lock (_lockObject) - { - _rendererIsDisposed = true; - } - - if (HotReload.HotReloadManager.IsSupported && HotReloadManager != null && _hotReloadInitialized && _hotReloadRenderHandler is not null) - { - HotReloadManager.OnDeltaApplied -= _hotReloadRenderHandler.RerenderOnHotReload; - } - - // It's important that we handle all exceptions here before reporting any of them. - // This way we can dispose all components before an error handler kicks in. - List exceptions = null; - List asyncDisposables = null; - foreach (var componentState in _componentStateById.Values) - { - Log.DisposingComponent(_logger, componentState); - - try - { - var task = componentState.DisposeAsync(); - if (task.IsCompletedSuccessfully) - { - // If it's a IValueTaskSource backed ValueTask, - // inform it its result has been read so it can reset - task.GetAwaiter().GetResult(); - } - else - { - asyncDisposables ??= new(); - asyncDisposables.Add(task.AsTask()); - } - } - catch (Exception exception) - { - exceptions ??= new List(); - exceptions.Add(exception); - } - } - - _componentStateById.Clear(); // So we know they were all disposed - _componentStateByComponent.Clear(); - _batchBuilder.Dispose(); - - NotifyExceptions(exceptions); - - if (asyncDisposables?.Count >= 1) - { - _disposeTask = HandleAsyncExceptions(asyncDisposables); - } - - async Task HandleAsyncExceptions(List tasks) - { - List asyncExceptions = null; - foreach (var task in tasks) - { - try - { - await task; - } - catch (Exception exception) - { - asyncExceptions ??= new List(); - asyncExceptions.Add(exception); - } - } - - NotifyExceptions(asyncExceptions); - } - - void NotifyExceptions(List exceptions) - { - if (exceptions?.Count > 1) - { - HandleException(new AggregateException("Exceptions were encountered while disposing components.", exceptions)); - } - else if (exceptions?.Count == 1) - { - HandleException(exceptions[0]); - } - } - } - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-03/provenance.json b/eng/skill-evals/review-pull-request/fixtures/case-03/provenance.json deleted file mode 100644 index 6dd3c117dfe3..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-03/provenance.json +++ /dev/null @@ -1,131 +0,0 @@ -{ - "repository": "dotnet/aspnetcore", - "pullRequest": 70304, - "sourceRoles": { - "mergeBase": "1c94b15aa54d3d490d0ee060b7d496db3cb291e7", - "head": "fd7be3828242ffabf3f64d230bfb511bbe42f553", - "baseTip": "1c94b15aa54d3d490d0ee060b7d496db3cb291e7" - }, - "files": [ - { - "file": "mergeBase.source", - "sha256": "ecb8038853cbc557a8bf189df33bf00820761e1cc05b088fe0ada1e70a1f0236", - "sources": [ - { - "role": "mergeBase", - "commit": "1c94b15aa54d3d490d0ee060b7d496db3cb291e7", - "path": "src/Components/Components/src/RenderTree/Renderer.cs", - "blob": "43130ce39615fad333f5e7ecf9401c0f4d0dc540", - "ranges": [ - [ - 802, - 805 - ], - [ - 1182, - 1183 - ], - [ - 1189, - 1233 - ], - [ - 1239, - 1354 - ] - ] - } - ] - }, - { - "file": "head.source", - "sha256": "1f92291015003c6ac6993efec14449443ef38d470899beb1c0e7d086424fd824", - "sources": [ - { - "role": "head", - "commit": "fd7be3828242ffabf3f64d230bfb511bbe42f553", - "path": "src/Components/Components/src/RenderTree/Renderer.cs", - "blob": "1b66058ffdc00d9a7f657057dadd8331815acb31", - "ranges": [ - [ - 802, - 805 - ], - [ - 1182, - 1190 - ], - [ - 1196, - 1240 - ], - [ - 1246, - 1361 - ] - ] - } - ] - }, - { - "file": "baseTip.source", - "sha256": "19fad0c5eb14bb14491bf45e2d097eed8d22016472bacd515dbc799e1d98d6db", - "sources": [ - { - "role": "baseTip", - "commit": "1c94b15aa54d3d490d0ee060b7d496db3cb291e7", - "path": "src/Components/Components/src/RenderHandle.cs", - "blob": "bc5e2eb02a019506941d1db8d572ff899b392096", - "ranges": [ - [ - 1, - 125 - ] - ] - } - ] - }, - { - "file": "context.source", - "sha256": "5f4ff01204f825cfab5d6e2dd22f619c1f17bb95608ccae181b1891455635c66", - "sources": [ - { - "role": "head", - "commit": "fd7be3828242ffabf3f64d230bfb511bbe42f553", - "path": "src/Components/Components/test/RendererTest.cs", - "blob": "8c5f99d695e75e9f5fd3d97b229d13e46e4cdb02", - "ranges": [ - [ - 6095, - 6106 - ], - [ - 6109, - 6121 - ], - [ - 6232, - 6258 - ], - [ - 6291, - 6294 - ] - ] - } - ], - "issue": { - "url": "https://github.com/dotnet/aspnetcore/issues/66322", - "updatedAt": "2026-10-07T19:08:14Z" - } - }, - { - "file": "change.diff", - "sha256": "7d4f8a6cb6d9989d849a9a3c485e85238cbb1c844408c7ab9b724807f98ac975" - }, - { - "file": "case.source", - "sha256": "769c32c864e5c768a7e2351f3bcf188ee703912c8bce2a07cbb0e61bdf5be807" - } - ] -} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/baseTip.source b/eng/skill-evals/review-pull-request/fixtures/case-04/baseTip.source deleted file mode 100644 index f78793112cca..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-04/baseTip.source +++ /dev/null @@ -1,517 +0,0 @@ -=== baseTip 66e2adb4e0297e445686cb7a70d6c9aa84dcf3af src/Components/WebAssembly/Authentication.Msal/src/Interop/AuthenticationService.ts:1-515 === -import * as Msal from '@azure/msal-browser'; - -interface AccessTokenRequestOptions { - scopes: string[]; - returnUrl: string; -} - -interface AccessTokenResult { - status: AccessTokenResultStatus; - token?: AccessToken; -} - -interface AccessToken { - value: string; - expires: Date | null; - grantedScopes: string[]; -} - -enum AccessTokenResultStatus { - Success = "success", - RequiresRedirect = "requiresRedirect" -} - -enum AuthenticationResultStatus { - Redirect = "redirect", - Success = "success", - Failure = "failure", - OperationCompleted = "operationCompleted" -} - -interface AuthenticationResult { - status: AuthenticationResultStatus; - state?: any; - message?: string; -} - -interface AuthorizeService { - getUser(): Promise; - getAccessToken(request?: AccessTokenRequestOptions): Promise; - signIn(state: any): Promise; - completeSignIn(state: any): Promise; - signOut(state: any): Promise; - completeSignOut(url: string): Promise; -} - -// These are the values for the .NET logger LogLevel. -// We only use debug and trace -export enum LogLevel { - Trace = 0, - Debug = 1 -} - -interface JavaScriptLoggingOptions { - debugEnabled: boolean; - traceEnabled: boolean; -} - -export class Logger { - public debug: boolean; - public trace: boolean; - public constructor(options: JavaScriptLoggingOptions) { - this.debug = options.debugEnabled; - this.trace = options.traceEnabled; - } - - log(level: LogLevel, message: string): void { - if ((level == LogLevel.Trace && this.trace) || - (level == LogLevel.Debug && this.debug)) { - const levelString = level == LogLevel.Trace ? 'trce' : 'dbug'; - console.debug( - // Logs in the following format to keep consistency with the way ASP.NET Core logs to the console while avoiding the - // additional overhead of passing the logger as a JSObjectReference - // dbug: Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService[0] - // <> - // trce: Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService[0] - // <> - `${levelString}: Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService[0] - ${message}`); - } - } -} - -export interface AuthenticationContext { - state?: unknown; - interactiveRequest: InteractiveAuthenticationRequest; -} - -export interface InteractiveAuthenticationRequest { - interaction: string; - scopes?: string[]; - additionalRequestParameters?: { [key: string]: any }; -}; - -interface AuthorizeServiceConfiguration extends Msal.Configuration { - defaultAccessTokenScopes: string[]; - additionalScopesToConsent: string[]; - loginMode: string; -} - -class MsalAuthorizeService implements AuthorizeService { - private readonly _msalApplication: Msal.PublicClientApplication; - private _account: Msal.AccountInfo | null | undefined; - private _redirectCallback: Promise | undefined; - - constructor(private readonly _settings: AuthorizeServiceConfiguration, private readonly _logger: Logger) { - if (this._settings.auth?.knownAuthorities?.length == 0) { - this._settings.auth.knownAuthorities = [new URL(this._settings.auth.authority!).hostname] - } - - this._settings.system = this._settings.system || {}; - - this._settings.system.navigationClient = { - async navigateInternal(url: string, options: Msal.NavigationOptions): Promise { - // We always replace the URL - _logger.log(LogLevel.Trace, `Navigating to ${url}`); - location.replace(url); - return false; - }, - async navigateExternal(url: string, options: Msal.NavigationOptions): Promise { - // We always replace the URL - _logger.log(LogLevel.Trace, `Navigating to ${url}`); - location.replace(url); - return false; - } - } - - this._settings.system.loggerOptions = { - logLevel: _logger.trace ? Msal.LogLevel.Trace : (_logger.debug ? Msal.LogLevel.Verbose : Msal.LogLevel.Warning), - loggerCallback: (level, message, containsPii) => { - if (containsPii) { - return; - } - if (level === Msal.LogLevel.Trace) { - _logger.log(LogLevel.Trace, message); - return; - } - - // We only have Debug/Trace, so anything above, we only log when Debug is enabled. - _logger.log(LogLevel.Debug, message); - return; - } - }; - - this._msalApplication = new Msal.PublicClientApplication(this._settings); - } - - async initialize(): Promise { - await this._msalApplication.initialize(); - } - - getAccount() { - if (this._account) { - return this._account; - } - - const accounts = this._msalApplication.getAllAccounts(); - if (accounts && accounts.length) { - return accounts[0]; - } - - return null; - } - - async getUser() { - const account = this.getAccount(); - if (!account) { - return; - } - - return account.idTokenClaims; - } - - async getAccessToken(request?: AccessTokenRequestOptions): Promise { - try { - this.trace('getAccessToken', request); - const newToken = await this.getTokenCore(request?.scopes); - return { - status: AccessTokenResultStatus.Success, - token: newToken - }; - } catch (e) { - return { - status: AccessTokenResultStatus.RequiresRedirect - }; - } - } - - async getTokenCore(scopes?: string[]): Promise { - const account = this.getAccount(); - if (!account) { - throw new Error('Failed to retrieve token, no account found.'); - } - - const silentRequest = { - redirectUri: this._settings.auth?.redirectUri, - account: account, - scopes: scopes || this._settings.defaultAccessTokenScopes - }; - - this.debug(`Provisioning a token silently for scopes '${silentRequest.scopes}'`) - this.trace('_msalApplication.acquireTokenSilent', silentRequest); - const response = await this._msalApplication.acquireTokenSilent(silentRequest); - this.trace('_msalApplication.acquireTokenSilent-response', response); - - if (response.scopes.length === 0 || response.accessToken === '') { - throw new Error('Scopes not granted.'); - } - - const result = { - value: response.accessToken, - grantedScopes: response.scopes, - expires: response.expiresOn - }; - - this.trace('getAccessToken-result', result); - - return result; - } - - async signIn(context: AuthenticationContext) { - this.trace('signIn', context); - try { - // Before we start any sign-in flow, clear out any previous state so that it doesn't pile up. - this.purgeState(); - - const { state, interactiveRequest } = context; - - if (interactiveRequest && interactiveRequest.interaction === 'GetToken') { - this.debug('Acquiring additional token.'); - const request: Msal.RedirectRequest = { - scopes: interactiveRequest.scopes || [], - state: this.saveState(context.state), - ...interactiveRequest.additionalRequestParameters - }; - this.trace('getInteractiveToken-Request', request); - await this._msalApplication.acquireTokenRedirect(request); - return this.success(state); - } else { - const request: Partial = { - redirectUri: this._settings.auth.redirectUri!, - state: this.saveState(context.state), - ...interactiveRequest?.additionalRequestParameters - }; - - request.scopes = request.scopes || this._settings.defaultAccessTokenScopes || []; - - const result = await this.signInCore(request); - this.trace('signIn-Response', result); - if (!result) { - return this.redirect(); - } else if (this.isMsalError(result)) { - return this.error(result.errorMessage); - } - - return this.success(state); - } - } catch (e) { - const message = (e as Error).message; - this.debug(`Sign in error '${message}'`); - return this.error(message); - } - } - - async signInCore(request: Partial): Promise { - this.trace('signIn-Request', request); - const loginMode = this._settings.loginMode.toLowerCase(); - if (loginMode === 'redirect') { - return this.signInWithRedirect(request as Msal.RedirectRequest); - } else { - return this.signInWithPopup(request as Msal.PopupRequest); - } - } - - private async signInWithRedirect(request: Msal.RedirectRequest) { - try { - this.debug('Starting sign-in redirect.'); - return await this._msalApplication.loginRedirect(request); - } catch (e) { - this.debug(`Sign-in redirect failed: '${(e as Error).message}'.`); - return e as any; - } - } - - private async signInWithPopup(request: Msal.PopupRequest) { - try { - this.debug('Starting sign-in pop-up'); - return await this._msalApplication.loginPopup(request); - } catch (e) { - // If the user explicitly cancelled the pop-up, avoid performing a redirect. - if (this.isMsalError(e) && e.errorCode !== Msal.BrowserAuthErrorCodes.userCancelled) { - this.signInWithRedirect(request); - } else { - this.debug(`Sign-in pop-up failed: '${(e as Error).message}'.`); - return e as any; - } - } - } - - async completeSignIn() { - // Make sure that the redirect handler has completed execution before - // completing sign in. - try { - this.debug('Completing sign-in redirect.'); - var authenticationResult = await this._redirectCallback; - this.trace('completeSignIn-result', authenticationResult); - if (authenticationResult) { - this.trace('completeSignIn-success', authenticationResult); - return authenticationResult; - } - this.debug('No authentication result.'); - return this.operationCompleted(); - } catch (e) { - this.debug(`completeSignIn-error:'${(e as Error).message}'`); - return this.error((e as Error).message); - } - } - - async signOut(context: AuthenticationContext) { - this.trace('signOut', context); - try { - // Before we start any sign-in flow, clear out any previous state so that it doesn't pile up. - this.purgeState(); - - const { state, interactiveRequest } = context; - - const request: Partial = { - postLogoutRedirectUri: this._settings.auth.postLogoutRedirectUri, - state: this.saveState(state), - ...interactiveRequest?.additionalRequestParameters - }; - this.trace('signOut-Request', request); - - await this._msalApplication.logoutRedirect(request); - - // We are about to be redirected. - return this.redirect(); - } catch (e) { - return this.error((e as Error).message); - } - } - - async completeSignOut(url: string) { - this.trace('completeSignOut-request', url); - try { - this.debug('Completing sign-out redirect.'); - var authenticationResult = await this._redirectCallback; - this.trace('completeSignOut-result', authenticationResult); - if (authenticationResult) { - this.trace('completeSignOut-success', authenticationResult); - return authenticationResult; - } - this.debug('No authentication result.'); - return this.operationCompleted(); - } catch (e) { - this.debug(`completeSignOut-error:'${(e as Error).message}'`); - return this.error((e as Error).message); - } - } - - // msal.js only allows a string as the account state and it simply attaches it to the sign-in request state. - // Given that we don't want to serialize the entire state and put it in the query string, we need to serialize the - // state ourselves and pass an identifier to retrieve it while in the callback flow. - saveState(state: T): string { - const identifier = window.crypto.randomUUID(); - sessionStorage.setItem(`${AuthenticationService._infrastructureKey}.AuthorizeService.${identifier}`, JSON.stringify(state)); - return identifier; - } - - retrieveState(url: string | null, providedState: string | null = null, isLogout: boolean = false): T | undefined { - let stateFromUrl; - // Parse the state key from the `search` query parameter in the URL if provided - if (url) { - const parsedUrl = new URL(url); - stateFromUrl = parsedUrl.searchParams && parsedUrl.searchParams.getAll('state'); - } - - // Chose the provided state from MSAL. Otherwise, choose the state computed from the URL - const state = providedState || stateFromUrl; - - if (!state) { - return undefined; - } - - const stateKey = `${AuthenticationService._infrastructureKey}.AuthorizeService.${state}`; - const stateString = sessionStorage.getItem(stateKey); - if (stateString) { - sessionStorage.removeItem(stateKey); - const savedState = JSON.parse(stateString); - return savedState; - } - - return undefined; - } - - purgeState() { - for (let i = 0; i < sessionStorage.length; i++) { - const key = sessionStorage.key(i); - if (key?.startsWith(AuthenticationService._infrastructureKey)) { - sessionStorage.removeItem(key); - } - } - } - - initializeMsalHandler() { - this._redirectCallback = this.completeAuthentication(); - } - - private async completeAuthentication() { - try { - const result = await this._msalApplication.handleRedirectPromise(); - const res = this.handleResult(result); - return res; - } catch (error) { - if (this.isMsalError(error)) { - return this.error(error.errorMessage); - } else { - return this.error((error as Error).message); - } - }; - } - - private handleResult(result: Msal.AuthenticationResult | null) { - const logoutState = this.retrieveState(location.href, undefined); - if (result) { - this._account = result.account; - return this.success(this.retrieveState(null, result.state)); - } else if (logoutState) { - return this.success(logoutState); - } else { - return this.operationCompleted(); - } - } - - private isMsalError(resultOrError: any): resultOrError is Msal.AuthError { - return resultOrError?.errorCode; - } - - private error(message: string) { - return { status: AuthenticationResultStatus.Failure, errorMessage: message }; - } - - private success(state: any) { - return { status: AuthenticationResultStatus.Success, state }; - } - - private redirect() { - return { status: AuthenticationResultStatus.Redirect }; - } - - private operationCompleted() { - return { status: AuthenticationResultStatus.OperationCompleted }; - } - - private debug(message: string) { - this._logger?.log(LogLevel.Debug, message); - } - - private trace(message: string, data: any) { - this._logger?.log(LogLevel.Trace, `${message}: ${JSON.stringify(data)}`); - } -} - -export class AuthenticationService { - - static _infrastructureKey = 'Microsoft.Authentication.WebAssembly.Msal'; - private static _initialization: Promise | undefined; - static instance: MsalAuthorizeService; - - public static async init(settings: AuthorizeServiceConfiguration, jsLoggingOptions: JavaScriptLoggingOptions) { - if (!AuthenticationService._initialization) { - const instance = new MsalAuthorizeService(settings, new Logger(jsLoggingOptions)); - AuthenticationService.instance = instance; - AuthenticationService._initialization = instance.initialize() - .then(() => instance.initializeMsalHandler()) - .catch(error => { - AuthenticationService._initialization = undefined; - throw error; - }); - } - return AuthenticationService._initialization; - } - - public static getUser() { - return AuthenticationService.instance.getUser(); - } - - public static getAccessToken(request: AccessTokenRequestOptions) { - return AuthenticationService.instance.getAccessToken(request); - } - - public static signIn(state: any) { - return AuthenticationService.instance.signIn(state); - } - - // url is not used in the msal.js implementation but we keep it here - // as it is part of the default RemoteAuthenticationService contract implementation. - // The unused parameter here just reflects that. - public static completeSignIn(url: string) { - return AuthenticationService.instance.completeSignIn(); - } - - public static signOut(state: any) { - return AuthenticationService.instance.signOut(state); - } - - public static completeSignOut(url: string) { - return AuthenticationService.instance.completeSignOut(url); - } -} - -declare global { - interface Window { AuthenticationService: AuthenticationService; } -} - -window.AuthenticationService = AuthenticationService; - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/case.source b/eng/skill-evals/review-pull-request/fixtures/case-04/case.source deleted file mode 100644 index c0e0d2cdd231..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-04/case.source +++ /dev/null @@ -1,8 +0,0 @@ -Repository: dotnet/aspnetcore -Pull request: https://github.com/dotnet/aspnetcore/pull/69721 -Head: 153f8ef684a760e30b43609e54a9d22027dc6b62 -Merge base: 66e2adb4e0297e445686cb7a70d6c9aa84dcf3af -Base tip: 66e2adb4e0297e445686cb7a70d6c9aa84dcf3af -The source files are excerpts, not a complete ready version-2 review bundle. -provenance.json maps every excerpt to its original source path and lines. -C1: The new RemoteMsalAuthenticationStartup token endpoint changes the observed result of NavigateDirectlyToLoginCallbackRestartsLoginWithoutInteropFailure because that browser scenario completes an exchange through this endpoint before its assertions. The concern is the asserted browser-test effect, not an independent endpoint policy claim. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/change.diff b/eng/skill-evals/review-pull-request/fixtures/case-04/change.diff deleted file mode 100644 index 7feba2a36173..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-04/change.diff +++ /dev/null @@ -1,108 +0,0 @@ -diff --git a/src/Components/test/testassets/Components.TestServer/RemoteMsalAuthenticationStartup.cs b/src/Components/test/testassets/Components.TestServer/RemoteMsalAuthenticationStartup.cs -new file mode 100644 -index 0000000000..6e4e181c18 ---- /dev/null -+++ b/src/Components/test/testassets/Components.TestServer/RemoteMsalAuthenticationStartup.cs -@@ -0,0 +1,102 @@ -+// Licensed to the .NET Foundation under one or more agreements. -+// The .NET Foundation licenses this file to you under the MIT license. -+ -+using System.Globalization; -+using System.Reflection; -+using Components.TestServer.RazorComponents; -+using Microsoft.AspNetCore.Mvc; -+using Microsoft.IdentityModel.JsonWebTokens; -+using Microsoft.IdentityModel.Tokens; -+ -+namespace TestServer; -+ -+public class RemoteMsalAuthenticationStartup -+{ -+ public void ConfigureServices(IServiceCollection services) -+ { -+ services.AddRazorComponents() -+ .AddInteractiveWebAssemblyComponents(); -+ } -+ -+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) -+ { -+ app.Map("/subdir", app => -+ { -+ app.UseRouting(); -+ -+ app.UseAntiforgery(); -+ app.UseEndpoints(endpoints => -+ { -+ var contentRootStaticAssetsPath = Path.Combine(env.ContentRootPath, "Components.TestServer.staticwebassets.endpoints.json"); -+ if (File.Exists(contentRootStaticAssetsPath)) -+ { -+ endpoints.MapStaticAssets(contentRootStaticAssetsPath); -+ } -+ else -+ { -+ endpoints.MapStaticAssets(); -+ } -+ -+ endpoints.MapRazorComponents() -+ .AddAdditionalAssemblies(Assembly.Load("Components.WasmMsalRemoteAuthentication")) -+ .AddInteractiveWebAssemblyRenderMode(options => options.PathPrefix = "/WasmMsalRemoteAuthentication"); -+ -+ var oidcEndpoints = endpoints.MapGroup("oidc"); -+ -+ var issuer = ""; -+ oidcEndpoints.MapGet(".well-known/openid-configuration", (HttpRequest request, [FromHeader] string host) => -+ { -+ issuer = $"{(request.IsHttps ? "https" : "http")}://{host}"; -+ return Results.Json(new -+ { -+ issuer, -+ authorization_endpoint = $"{issuer}/subdir/oidc/authorize", -+ token_endpoint = $"{issuer}/subdir/oidc/token", -+ }); -+ }); -+ -+ var lastCode = ""; -+ var interactiveAuthorizationRequests = 0; -+ oidcEndpoints.MapGet("authorize", (string redirect_uri, string? state, string? prompt) => -+ { -+ if (prompt == "none") -+ { -+ return Results.Redirect($"{redirect_uri}?error=interaction_required&state={state}"); -+ } -+ -+ interactiveAuthorizationRequests++; -+ lastCode = Random.Shared.Next().ToString(CultureInfo.InvariantCulture); -+ return Results.Redirect($"{redirect_uri}?code={lastCode}&state={state}"); -+ }); -+ -+ oidcEndpoints.MapGet("interactive-authorization-requests", () => interactiveAuthorizationRequests); -+ -+ var jwtHandler = new JsonWebTokenHandler(); -+ oidcEndpoints.MapPost("token", ([FromForm] string code) => -+ { -+ if (string.IsNullOrEmpty(lastCode) && code != lastCode) -+ { -+ return Results.BadRequest("Bad code"); -+ } -+ -+ return Results.Json(new -+ { -+ token_type = "Bearer", -+ scope = "openid profile", -+ expires_in = 3600, -+ id_token = jwtHandler.CreateToken(new SecurityTokenDescriptor -+ { -+ Issuer = issuer, -+ Audience = "s6BhdRkqt3", -+ Claims = new Dictionary -+ { -+ ["sub"] = "248289761001", -+ ["name"] = "Jane Doe", -+ }, -+ }), -+ }); -+ }).DisableAntiforgery(); -+ }); -+ }); -+ } -+} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/context.source b/eng/skill-evals/review-pull-request/fixtures/case-04/context.source deleted file mode 100644 index 4aac59a38f84..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-04/context.source +++ /dev/null @@ -1,164 +0,0 @@ -=== head 153f8ef684a760e30b43609e54a9d22027dc6b62 src/Components/test/E2ETest/Tests/RemoteMsalAuthenticationTest.cs:1-37 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Components.E2ETest.Infrastructure; -using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; -using Microsoft.AspNetCore.E2ETesting; -using OpenQA.Selenium; -using TestServer; -using Xunit.Abstractions; - -namespace Microsoft.AspNetCore.Components.E2ETest.Tests; - -public class RemoteMsalAuthenticationTest : - ServerTestBase> -{ - public RemoteMsalAuthenticationTest( - BrowserFixture browserFixture, - TrimmingServerFixture serverFixture, - ITestOutputHelper output) - : base(browserFixture, serverFixture, output) - { - } - - [Fact] - public void NavigateDirectlyToLoginCallbackRestartsLoginWithoutInteropFailure() - { - Navigate("/subdir/msal-authentication/login-callback"); - - Browser.True(() => (bool?)((IJavaScriptExecutor)Browser).ExecuteScript( - "return window.__msalSignInCalled") == true); - - var browserLog = Browser.Manage().Logs.GetLog(LogType.Browser); - Assert.DoesNotContain(browserLog, entry => entry.Message.Contains( - "The value 'AuthenticationService.isTopLevelWindow' is not a function.", - StringComparison.Ordinal)); - } -} - -=== head 153f8ef684a760e30b43609e54a9d22027dc6b62 src/Components/test/testassets/Components.TestServer/RazorComponents/RemoteMsalAuthenticationApp.razor:1-30 === - - - - - - - - - - - - - - - - - - - -=== head 153f8ef684a760e30b43609e54a9d22027dc6b62 src/Components/test/testassets/Components.WasmMsalRemoteAuthentication/Program.cs:1-31 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Components.WebAssembly.Hosting; - -var builder = WebAssemblyHostBuilder.CreateDefault(args); -var authorityBaseUriBuilder = new UriBuilder(builder.HostEnvironment.BaseAddress) -{ - Host = "localhost", - Path = "subdir/oidc", -}; - -builder.Services.AddMsalAuthentication(options => -{ - options.ProviderOptions.Authentication.Authority = authorityBaseUriBuilder.Uri.AbsoluteUri; - options.ProviderOptions.Authentication.ClientId = "s6BhdRkqt3"; - options.ProviderOptions.Authentication.RedirectUri = "msal-authentication/login-callback"; - options.ProviderOptions.Authentication.PostLogoutRedirectUri = "msal-authentication/logout-callback"; - options.ProviderOptions.LoginMode = "redirect"; - options.AuthenticationPaths.LogInPath = "msal-authentication/login"; - options.AuthenticationPaths.LogInCallbackPath = "msal-authentication/login-callback"; - options.AuthenticationPaths.LogInFailedPath = "msal-authentication/login-failed"; - options.AuthenticationPaths.LogOutPath = "msal-authentication/logout"; - options.AuthenticationPaths.LogOutCallbackPath = "msal-authentication/logout-callback"; - options.AuthenticationPaths.LogOutFailedPath = "msal-authentication/logout-failed"; - options.AuthenticationPaths.LogOutSucceededPath = "msal-authentication/logged-out"; - options.AuthenticationPaths.ProfilePath = "msal-authentication/profile"; - options.AuthenticationPaths.RegisterPath = "msal-authentication/register"; -}); - -await builder.Build().RunAsync(); - -=== head 153f8ef684a760e30b43609e54a9d22027dc6b62 src/Components/WebAssembly/Authentication.Msal/src/Interop/AuthenticationService.ts:472-484 === - public static async init(settings: AuthorizeServiceConfiguration, jsLoggingOptions: JavaScriptLoggingOptions) { - if (!AuthenticationService._initialization) { - const instance = new MsalAuthorizeService(settings, new Logger(jsLoggingOptions)); - AuthenticationService.instance = instance; - AuthenticationService._initialization = instance.initialize() - .then(() => instance.initializeMsalHandler()) - .catch(error => { - AuthenticationService._initialization = undefined; - throw error; - }); - } - return AuthenticationService._initialization; - } - -=== head 153f8ef684a760e30b43609e54a9d22027dc6b62 src/Components/WebAssembly/Authentication.Msal/src/Interop/AuthenticationService.ts:220-262 === - async signIn(context: AuthenticationContext) { - this.trace('signIn', context); - try { - // Before we start any sign-in flow, clear out any previous state so that it doesn't pile up. - this.purgeState(); - - const { state, interactiveRequest } = context; - - if (interactiveRequest && interactiveRequest.interaction === 'GetToken') { - this.debug('Acquiring additional token.'); - const request: Msal.RedirectRequest = { - scopes: interactiveRequest.scopes || [], - state: this.saveState(context.state), - ...interactiveRequest.additionalRequestParameters - }; - this.trace('getInteractiveToken-Request', request); - await this._msalApplication.acquireTokenRedirect(request); - return this.success(state); - } else { - const request: Partial = { - redirectUri: this._settings.auth.redirectUri!, - state: this.saveState(context.state), - ...interactiveRequest?.additionalRequestParameters - }; - - request.scopes = request.scopes || this._settings.defaultAccessTokenScopes || []; - - const result = await this.signInCore(request); - this.trace('signIn-Response', result); - if (!result) { - return this.redirect(); - } else if (this.isMsalError(result)) { - return this.error(result.errorMessage); - } - - return this.success(state); - } - } catch (e) { - const message = (e as Error).message; - this.debug(`Sign in error '${message}'`); - return this.error(message); - } - } - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/head.source b/eng/skill-evals/review-pull-request/fixtures/case-04/head.source deleted file mode 100644 index bd4b34cdb118..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-04/head.source +++ /dev/null @@ -1,104 +0,0 @@ -=== head 153f8ef684a760e30b43609e54a9d22027dc6b62 src/Components/test/testassets/Components.TestServer/RemoteMsalAuthenticationStartup.cs:1-102 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Globalization; -using System.Reflection; -using Components.TestServer.RazorComponents; -using Microsoft.AspNetCore.Mvc; -using Microsoft.IdentityModel.JsonWebTokens; -using Microsoft.IdentityModel.Tokens; - -namespace TestServer; - -public class RemoteMsalAuthenticationStartup -{ - public void ConfigureServices(IServiceCollection services) - { - services.AddRazorComponents() - .AddInteractiveWebAssemblyComponents(); - } - - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - app.Map("/subdir", app => - { - app.UseRouting(); - - app.UseAntiforgery(); - app.UseEndpoints(endpoints => - { - var contentRootStaticAssetsPath = Path.Combine(env.ContentRootPath, "Components.TestServer.staticwebassets.endpoints.json"); - if (File.Exists(contentRootStaticAssetsPath)) - { - endpoints.MapStaticAssets(contentRootStaticAssetsPath); - } - else - { - endpoints.MapStaticAssets(); - } - - endpoints.MapRazorComponents() - .AddAdditionalAssemblies(Assembly.Load("Components.WasmMsalRemoteAuthentication")) - .AddInteractiveWebAssemblyRenderMode(options => options.PathPrefix = "/WasmMsalRemoteAuthentication"); - - var oidcEndpoints = endpoints.MapGroup("oidc"); - - var issuer = ""; - oidcEndpoints.MapGet(".well-known/openid-configuration", (HttpRequest request, [FromHeader] string host) => - { - issuer = $"{(request.IsHttps ? "https" : "http")}://{host}"; - return Results.Json(new - { - issuer, - authorization_endpoint = $"{issuer}/subdir/oidc/authorize", - token_endpoint = $"{issuer}/subdir/oidc/token", - }); - }); - - var lastCode = ""; - var interactiveAuthorizationRequests = 0; - oidcEndpoints.MapGet("authorize", (string redirect_uri, string? state, string? prompt) => - { - if (prompt == "none") - { - return Results.Redirect($"{redirect_uri}?error=interaction_required&state={state}"); - } - - interactiveAuthorizationRequests++; - lastCode = Random.Shared.Next().ToString(CultureInfo.InvariantCulture); - return Results.Redirect($"{redirect_uri}?code={lastCode}&state={state}"); - }); - - oidcEndpoints.MapGet("interactive-authorization-requests", () => interactiveAuthorizationRequests); - - var jwtHandler = new JsonWebTokenHandler(); - oidcEndpoints.MapPost("token", ([FromForm] string code) => - { - if (string.IsNullOrEmpty(lastCode) && code != lastCode) - { - return Results.BadRequest("Bad code"); - } - - return Results.Json(new - { - token_type = "Bearer", - scope = "openid profile", - expires_in = 3600, - id_token = jwtHandler.CreateToken(new SecurityTokenDescriptor - { - Issuer = issuer, - Audience = "s6BhdRkqt3", - Claims = new Dictionary - { - ["sub"] = "248289761001", - ["name"] = "Jane Doe", - }, - }), - }); - }).DisableAntiforgery(); - }); - }); - } -} - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/mergeBase.source b/eng/skill-evals/review-pull-request/fixtures/case-04/mergeBase.source deleted file mode 100644 index 3c3c0a87005c..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-04/mergeBase.source +++ /dev/null @@ -1,109 +0,0 @@ -=== mergeBase 66e2adb4e0297e445686cb7a70d6c9aa84dcf3af src/Components/test/testassets/Components.TestServer/RemoteAuthenticationStartup.cs:1-107 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Globalization; -using System.Reflection; -using Components.TestServer.RazorComponents; -using Microsoft.AspNetCore.Mvc; -using Microsoft.IdentityModel.JsonWebTokens; -using Microsoft.IdentityModel.Tokens; - -namespace TestServer; - -public class RemoteAuthenticationStartup -{ - public void ConfigureServices(IServiceCollection services) - { - services.AddRazorComponents() - .AddInteractiveWebAssemblyComponents(); - } - - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - app.Map("/subdir", app => - { - app.UseRouting(); - - app.UseAntiforgery(); - app.UseEndpoints(endpoints => - { - var contentRootStaticAssetsPath = Path.Combine(env.ContentRootPath, "Components.TestServer.staticwebassets.endpoints.json"); - if (File.Exists(contentRootStaticAssetsPath)) - { - endpoints.MapStaticAssets(contentRootStaticAssetsPath); - } - else - { - endpoints.MapStaticAssets(); - } - - endpoints.MapRazorComponents() - .AddAdditionalAssemblies(Assembly.Load("Components.WasmRemoteAuthentication")) - .AddInteractiveWebAssemblyRenderMode(options => options.PathPrefix = "/WasmRemoteAuthentication"); - - var oidcEndpoints = endpoints.MapGroup("oidc"); - - // This is designed to test a single login at a time. - var issuer = ""; - oidcEndpoints.MapGet(".well-known/openid-configuration", (HttpRequest request, [FromHeader] string host) => - { - issuer = $"{(request.IsHttps ? "https" : "http")}://{host}"; - return Results.Json(new - { - issuer, - authorization_endpoint = $"{issuer}/subdir/oidc/authorize", - token_endpoint = $"{issuer}/subdir/oidc/token", - }); - }); - - var lastCode = ""; - oidcEndpoints.MapGet("authorize", (string redirect_uri, string? state, string? prompt, bool? preservedExtraQueryParams) => - { - // Require interaction so silent sign-in does not skip RedirectToLogin.razor. - if (prompt == "none") - { - return Results.Redirect($"{redirect_uri}?error=interaction_required&state={state}"); - } - - // Verify that the extra query parameters added by RedirectToLogin.razor are preserved. - if (preservedExtraQueryParams != true) - { - return Results.Redirect($"{redirect_uri}?error=invalid_request&error_description=extraQueryParams%20not%20preserved&state={state}"); - } - - lastCode = Random.Shared.Next().ToString(CultureInfo.InvariantCulture); - return Results.Redirect($"{redirect_uri}?code={lastCode}&state={state}"); - }); - - var jwtHandler = new JsonWebTokenHandler(); - oidcEndpoints.MapPost("token", ([FromForm] string code) => - { - if (string.IsNullOrEmpty(lastCode) && code != lastCode) - { - return Results.BadRequest("Bad code"); - } - - return Results.Json(new - { - token_type = "Bearer", - scope = "openid profile", - expires_in = 3600, - id_token = jwtHandler.CreateToken(new SecurityTokenDescriptor - { - Issuer = issuer, - Audience = "s6BhdRkqt3", - Claims = new Dictionary - { - ["sub"] = "248289761001", - ["name"] = "Jane Doe", - }, - }), - }); - }).DisableAntiforgery(); - }); - }); - } -} - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-04/provenance.json b/eng/skill-evals/review-pull-request/fixtures/case-04/provenance.json deleted file mode 100644 index 285509429ad1..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-04/provenance.json +++ /dev/null @@ -1,131 +0,0 @@ -{ - "repository": "dotnet/aspnetcore", - "pullRequest": 69721, - "sourceRoles": { - "mergeBase": "66e2adb4e0297e445686cb7a70d6c9aa84dcf3af", - "head": "153f8ef684a760e30b43609e54a9d22027dc6b62", - "baseTip": "66e2adb4e0297e445686cb7a70d6c9aa84dcf3af" - }, - "files": [ - { - "file": "mergeBase.source", - "sha256": "bf3e50473d2061531eb249607c88b04e66e2fffd45233f89ebe2f0f3dc77a851", - "sources": [ - { - "role": "mergeBase", - "commit": "66e2adb4e0297e445686cb7a70d6c9aa84dcf3af", - "path": "src/Components/test/testassets/Components.TestServer/RemoteAuthenticationStartup.cs", - "blob": "e0ea4303ef8ed4915e575f8a1a28d4bd8d3cae31", - "ranges": [ - [ - 1, - 107 - ] - ] - } - ] - }, - { - "file": "head.source", - "sha256": "3035f16602cd1b9dded50443993ad5665076a44190f19edce62ef4da5adf716b", - "sources": [ - { - "role": "head", - "commit": "153f8ef684a760e30b43609e54a9d22027dc6b62", - "path": "src/Components/test/testassets/Components.TestServer/RemoteMsalAuthenticationStartup.cs", - "blob": "6e4e181c18555c54edc082c8f247636957a2adc6", - "ranges": [ - [ - 1, - 102 - ] - ] - } - ] - }, - { - "file": "baseTip.source", - "sha256": "ecaafa0098b41c0079385e460596f80f6825379340fc44d27d636c3d88633f56", - "sources": [ - { - "role": "baseTip", - "commit": "66e2adb4e0297e445686cb7a70d6c9aa84dcf3af", - "path": "src/Components/WebAssembly/Authentication.Msal/src/Interop/AuthenticationService.ts", - "blob": "9f921f557fff57c06052bf35ce550d2788ce451c", - "ranges": [ - [ - 1, - 515 - ] - ] - } - ] - }, - { - "file": "context.source", - "sha256": "aec831d5ab8146c1d8a2f67b1d62c0a70f7359b94161f225b929a0a0e1a01ffa", - "sources": [ - { - "role": "head", - "commit": "153f8ef684a760e30b43609e54a9d22027dc6b62", - "path": "src/Components/test/E2ETest/Tests/RemoteMsalAuthenticationTest.cs", - "blob": "cac01175d2486ef842a4c5093f9160ee8fa633a0", - "ranges": [ - [ - 1, - 37 - ] - ] - }, - { - "role": "head", - "commit": "153f8ef684a760e30b43609e54a9d22027dc6b62", - "path": "src/Components/test/testassets/Components.TestServer/RazorComponents/RemoteMsalAuthenticationApp.razor", - "blob": "d9ec11afcc97013f3f3b59c56d4172e72f55a426", - "ranges": [ - [ - 1, - 30 - ] - ] - }, - { - "role": "head", - "commit": "153f8ef684a760e30b43609e54a9d22027dc6b62", - "path": "src/Components/test/testassets/Components.WasmMsalRemoteAuthentication/Program.cs", - "blob": "6962660265d363fcac65712941520f375e9b9b4a", - "ranges": [ - [ - 1, - 31 - ] - ] - }, - { - "role": "head", - "commit": "153f8ef684a760e30b43609e54a9d22027dc6b62", - "path": "src/Components/WebAssembly/Authentication.Msal/src/Interop/AuthenticationService.ts", - "blob": "61da3cba0ebbb29922c1549c7567594a46daee67", - "ranges": [ - [ - 472, - 484 - ], - [ - 220, - 262 - ] - ] - } - ] - }, - { - "file": "change.diff", - "sha256": "07956bec2265b888b034c331638e353a762f9f6bd7001f60d773498d3d8b89cf" - }, - { - "file": "case.source", - "sha256": "43116be262a937b2c1d227222b1cb45d1023c3f23c3ce29b73947f512794a2da" - } - ] -} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/baseTip.source b/eng/skill-evals/review-pull-request/fixtures/case-05/baseTip.source deleted file mode 100644 index cb0e32dbee4f..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-05/baseTip.source +++ /dev/null @@ -1,160 +0,0 @@ -=== baseTip 2a731a48bdbe8747100ce19282d8b96bb93b876e src/Components/Web.JS/src/Services/NavigationUtils.ts:1-158 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -import { WebRendererId } from '../Rendering/WebRendererId'; - -let interactiveRouterRendererId: WebRendererId | undefined = undefined; -let programmaticEnhancedNavigationHandler: typeof performProgrammaticEnhancedNavigation | undefined; -let enhancedNavigationListener: typeof notifyEnhancedNavigationListeners | undefined; - -/** - * Checks if a click event corresponds to an tag referencing a URL within the base href, and that interception - * isn't bypassed (e.g., by a 'download' attribute or the user holding a meta key while clicking). - * @param event The event that occurred - * @param callbackIfIntercepted A callback that will be invoked if the event corresponds to a click on an that can be intercepted. - */ -export function handleClickForNavigationInterception(event: MouseEvent, callbackIfIntercepted: (absoluteInternalHref: string) => void): void { - if (event.button !== 0 || eventHasSpecialKey(event)) { - // Don't stop ctrl/meta-click (etc) from opening links in new tabs/windows - return; - } - - if (event.defaultPrevented) { - return; - } - - // Intercept clicks on all elements where the href is within the URI space - // We must explicitly check if it has an 'href' attribute, because if it doesn't, the result might be null or an empty string depending on the browser - const anchorTarget = findAnchorTarget(event); - - if (anchorTarget && canProcessAnchor(anchorTarget)) { - const anchorHref = anchorTarget.getAttribute('href')!; - - const absoluteHref = toAbsoluteUri(anchorHref); - - if (isWithinBaseUriSpace(absoluteHref)) { - event.preventDefault(); - callbackIfIntercepted(absoluteHref); - } - } -} - -export function isWithinBaseUriSpace(href: string) { - const baseUriWithoutTrailingSlash = toBaseUriWithoutTrailingSlash(document.baseURI!); - const nextChar = href.charAt(baseUriWithoutTrailingSlash.length); - - return href.startsWith(baseUriWithoutTrailingSlash) - && (nextChar === '' || nextChar === '/' || nextChar === '?' || nextChar === '#'); -} - -export function isSamePageWithHash(oldUrl: string, newUrl: string): boolean { - const a = new URL(oldUrl); - const b = new URL(newUrl); - return a.origin === b.origin && a.pathname === b.pathname - && a.search === b.search && b.hash !== ''; -} - -export function isForSamePath(url1: string, url2: string) { - // We are going to use the scheme, host, port and path to determine if the two URLs are compatible. - // We do not account for the query string as we want to allow for the query string to change. - // (Blazor doesn't use the query string for routing purposes). - const parsedUrl1 = new URL(url1); - const parsedUrl2 = new URL(url2); - return parsedUrl1.protocol === parsedUrl2.protocol - && parsedUrl1.host === parsedUrl2.host - && parsedUrl1.port === parsedUrl2.port - && parsedUrl1.pathname === parsedUrl2.pathname; -} - -export function performScrollToElementOnTheSamePage(absoluteHref : string): void { - const hashIndex = absoluteHref.indexOf('#'); - if (hashIndex === absoluteHref.length - 1) { - return; - } - - const identifier = absoluteHref.substring(hashIndex + 1); - scrollToElement(identifier); -} - -export function scrollToElement(identifier: string): void { - document.getElementById(identifier)?.scrollIntoView(); -} - -export function attachEnhancedNavigationListener(listener: typeof enhancedNavigationListener) { - enhancedNavigationListener = listener; -} - -export function notifyEnhancedNavigationListeners(internalDestinationHref: string, interceptedLink: boolean) { - enhancedNavigationListener?.(internalDestinationHref, interceptedLink); -} - -export function hasProgrammaticEnhancedNavigationHandler(): boolean { - return programmaticEnhancedNavigationHandler !== undefined; -} - -export function attachProgrammaticEnhancedNavigationHandler(handler: typeof programmaticEnhancedNavigationHandler) { - programmaticEnhancedNavigationHandler = handler; -} - -export function performProgrammaticEnhancedNavigation(absoluteInternalHref: string, replace: boolean): void { - if (!programmaticEnhancedNavigationHandler) { - throw new Error('No enhanced programmatic navigation handler has been attached'); - } - - programmaticEnhancedNavigationHandler(absoluteInternalHref, replace); -} - -function toBaseUriWithoutTrailingSlash(baseUri: string) { - return baseUri.substring(0, baseUri.lastIndexOf('/')); -} - -let testAnchor: HTMLAnchorElement; -export function toAbsoluteUri(relativeUri: string): string { - testAnchor = testAnchor || document.createElement('a'); - testAnchor.href = relativeUri; - return testAnchor.href; -} - -function eventHasSpecialKey(event: MouseEvent) { - return event.ctrlKey || event.shiftKey || event.altKey || event.metaKey; -} - -function canProcessAnchor(anchorTarget: HTMLAnchorElement | SVGAElement) { - const targetAttributeValue = anchorTarget.getAttribute('target'); - const opensInSameFrame = !targetAttributeValue || targetAttributeValue === '_self'; - return opensInSameFrame && anchorTarget.hasAttribute('href') && !anchorTarget.hasAttribute('download'); -} - -function findAnchorTarget(event: MouseEvent): HTMLAnchorElement | SVGAElement | null { - const path = event.composedPath && event.composedPath(); - if (path) { - // This logic works with events that target elements within a shadow root, - // as long as the shadow mode is 'open'. For closed shadows, we can't possibly - // know what internal element was clicked. - for (let i = 0; i < path.length; i++) { - const candidate = path[i]; - if (candidate instanceof HTMLAnchorElement || candidate instanceof SVGAElement) { - return candidate; - } - } - } - return null; -} - -export function hasInteractiveRouter(): boolean { - return interactiveRouterRendererId !== undefined; -} - -export function getInteractiveRouterRendererId() : WebRendererId | undefined { - return interactiveRouterRendererId; -} - -export function setHasInteractiveRouter(rendererId: WebRendererId) { - if (interactiveRouterRendererId !== undefined && interactiveRouterRendererId !== rendererId) { - throw new Error('Only one interactive runtime may enable navigation interception at a time.'); - } - - interactiveRouterRendererId = rendererId; -} - diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/case.source b/eng/skill-evals/review-pull-request/fixtures/case-05/case.source deleted file mode 100644 index 39049a02c31d..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-05/case.source +++ /dev/null @@ -1,8 +0,0 @@ -Repository: dotnet/aspnetcore -Pull request: https://github.com/dotnet/aspnetcore/pull/70299 -Head: 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 -Merge base: 2a731a48bdbe8747100ce19282d8b96bb93b876e -Base tip: 2a731a48bdbe8747100ce19282d8b96bb93b876e -The source files are excerpts, not a complete ready version-2 review bundle. -provenance.json maps every excerpt to its original source path and lines. -C1: After listener reordering, an unprevented anchor whose @onclick calls NavigationManager.NavigateTo can land on its href in Interactive WebAssembly but on the programmatic destination in Interactive Server. Is the different final navigation intended? diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/change.diff b/eng/skill-evals/review-pull-request/fixtures/case-05/change.diff deleted file mode 100644 index f62044083cb4..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-05/change.diff +++ /dev/null @@ -1,83 +0,0 @@ -diff --git a/src/Components/Web.JS/src/Services/NavigationEnhancement.ts b/src/Components/Web.JS/src/Services/NavigationEnhancement.ts -index 7bd29bee95..dd06e2cf5b 100644 ---- a/src/Components/Web.JS/src/Services/NavigationEnhancement.ts -+++ b/src/Components/Web.JS/src/Services/NavigationEnhancement.ts -@@ -4,6 +4,7 @@ - import { synchronizeDomContent } from '../Rendering/DomMerging/DomSync'; - import { attachProgrammaticEnhancedNavigationHandler, handleClickForNavigationInterception, hasInteractiveRouter, isForSamePath, notifyEnhancedNavigationListeners, performScrollToElementOnTheSamePage, isSamePageWithHash } from './NavigationUtils'; - import { scheduleScrollReset, ScrollResetSchedule } from '../Rendering/Renderer'; -+import { isDispatchingClick, setClickListenerRegisteredCallback } from '../Rendering/Events/EventDelegatorListeners'; - - /* - In effect, we have two separate client-side navigation mechanisms: -@@ -37,6 +38,8 @@ const acceptHeader = 'text/html; blazor-enhanced-nav=on'; - let currentEnhancedNavigationAbortController: AbortController | null; - let navigationEnhancementCallbacks: NavigationEnhancementCallbacks; - let performingEnhancedPageLoad: boolean; -+let clickListenerReorderPending = false; -+const capturedClickEvents = new Set(); - - // This gets initialized to the current URL when we load. - // After that, it gets updated every time we successfully complete a navigation. -@@ -59,6 +62,8 @@ export function hasNeverStartedAnyEnhancedPageLoad() { - - export function attachProgressivelyEnhancedNavigationListener(callbacks: NavigationEnhancementCallbacks) { - navigationEnhancementCallbacks = callbacks; -+ setClickListenerRegisteredCallback(onClickListenerRegistered); -+ window.addEventListener('click', onClickCapture, true); - document.addEventListener('click', onDocumentClick); - document.addEventListener('submit', onDocumentSubmit); - window.addEventListener('popstate', onPopState); -@@ -67,6 +72,10 @@ export function attachProgressivelyEnhancedNavigationListener(callbacks: Navigat - } - - export function detachProgressivelyEnhancedNavigationListener() { -+ setClickListenerRegisteredCallback(undefined); -+ clickListenerReorderPending = false; -+ window.removeEventListener('click', onClickCapture, true); -+ capturedClickEvents.clear(); - document.removeEventListener('click', onDocumentClick); - document.removeEventListener('submit', onDocumentSubmit); - window.removeEventListener('popstate', onPopState); -@@ -88,7 +97,41 @@ function performProgrammaticEnhancedNavigation(absoluteInternalHref: string, rep - performEnhancedPageLoad(absoluteInternalHref, /* interceptedLink */ false); - } - -+function onClickCapture(event: MouseEvent) { -+ // Window capture observes even native document listeners registered before Blazor starts. -+ capturedClickEvents.add(event); -+ // Microtasks can run between browser-invoked listeners, so release the event after the dispatch task. -+ setTimeout(() => capturedClickEvents.delete(event), 0); -+} -+ -+function isDispatchingBrowserClick(except?: MouseEvent): boolean { -+ for (const event of capturedClickEvents) { -+ if (event !== except && event.eventPhase !== Event.NONE) { -+ return true; -+ } -+ } -+ -+ return false; -+} -+ -+function onClickListenerRegistered(isDispatchingClick: boolean, currentClick?: MouseEvent) { -+ // Removing a listener during dispatch skips it for that click. Let it run before reordering. -+ if (isDispatchingClick || isDispatchingBrowserClick(currentClick)) { -+ clickListenerReorderPending = true; -+ return; -+ } -+ -+ clickListenerReorderPending = false; -+ document.removeEventListener('click', onDocumentClick); -+ document.addEventListener('click', onDocumentClick); -+} -+ - function onDocumentClick(event: MouseEvent) { -+ // A nested click must not remove this listener from an outer click's dispatch. -+ if (clickListenerReorderPending && !isDispatchingClick()) { -+ onClickListenerRegistered(false, event); -+ } -+ - if (hasInteractiveRouter()) { - return; - } diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/context.source b/eng/skill-evals/review-pull-request/fixtures/case-05/context.source deleted file mode 100644 index 06958e3203c0..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-05/context.source +++ /dev/null @@ -1,87 +0,0 @@ -=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/test/testassets/TestContentPackage/InteractiveNavigationComponent.razor:1-41 === -@inject NavigationManager Navigation - - -Navigate with an unprevented link -Navigate with a prevented link - -
- -
- -
- -
- - -@code { - private void NavigateToAnotherPage() - { - Navigation.NavigateTo("nav"); - } - - private void RefreshWithNavigateTo() - { - Navigation.NavigateTo(Navigation.Uri, replace: true); - } - - private void ReloadWithNavigateTo() - { - Navigation.NavigateTo(Navigation.Uri, forceLoad: true, replace: true); - } - - private void RefreshWithRefresh() - { - Navigation.Refresh(); - } - - private void ReloadWithRefresh() - { - Navigation.Refresh(forceReload: true); - } -} - -=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Rendering/Events/EventDelegatorListeners.ts:1-33 === -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -let clickListenerRegisteredCallback: ((isDispatchingClick: boolean) => void) | undefined; -let clickDispatchDepth = 0; - -export function setClickListenerRegisteredCallback(callback: typeof clickListenerRegisteredCallback): void { - clickListenerRegisteredCallback = callback; -} - -export function isDispatchingClick(): boolean { - return clickDispatchDepth > 0; -} - -export function notifyGlobalListenerAdded(eventName: string): void { - if (eventName === 'click') { - clickListenerRegisteredCallback?.(clickDispatchDepth > 0); - } -} - -export function dispatchGlobalEvent(event: Event, listener: EventListener): void { - if (event.type !== 'click') { - listener(event); - return; - } - - clickDispatchDepth++; - try { - listener(event); - } finally { - clickDispatchDepth--; - } -} - - -=== Existing feedback discussion_r4487936812 at commit 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 === -**[P2] [QUESTION] Confirm whether `` with `@onclick` calling `NavigateTo` (without `@onclick:preventDefault`) should differ between Interactive WebAssembly and Interactive Server** - -Because `onDocumentClick` is now moved after the renderer's click delegate, consider a link such as `` (without `@onclick:preventDefault`) on a page where enhanced navigation is active: -- **Before this PR:** `onDocumentClick` ran first (`/other`), and then the `@onclick` handler's `Nav.NavigateTo("/counter")` ran second and won in both Interactive WebAssembly and Interactive Server (landing on `/counter`). -- **With this PR:** In Interactive WebAssembly, `@onclick` runs synchronously during the click event and starts programmatic enhanced navigation to `/counter`, and then `onDocumentClick` runs second on the un-prevented ``, aborting `/counter` (`NavigationEnhancement.ts:226`) and landing on `/other` (matching native browser order where an un-prevented link's default action runs after click handlers). However, in Interactive Server, `@onclick` runs asynchronously over SignalR after `onDocumentClick`, so `/counter` still wins. - -Is this Interactive WebAssembly (`/other`) vs. Interactive Server (`/counter`) difference intended when `@onclick` calls `NavigateTo` without `@onclick:preventDefault` (for example under `InteractiveAuto`), or should programmatic enhanced navigation initiated during the click take precedence? diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/head.source b/eng/skill-evals/review-pull-request/fixtures/case-05/head.source deleted file mode 100644 index 8dc71d74ba59..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-05/head.source +++ /dev/null @@ -1,122 +0,0 @@ -=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:63-72 === -export function attachProgressivelyEnhancedNavigationListener(callbacks: NavigationEnhancementCallbacks) { - navigationEnhancementCallbacks = callbacks; - setClickListenerRegisteredCallback(onClickListenerRegistered); - window.addEventListener('click', onClickCapture, true); - document.addEventListener('click', onDocumentClick); - document.addEventListener('submit', onDocumentSubmit); - window.addEventListener('popstate', onPopState); - - attachProgrammaticEnhancedNavigationHandler(performProgrammaticEnhancedNavigation); -} - -=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:84-98 === -function performProgrammaticEnhancedNavigation(absoluteInternalHref: string, replace: boolean) : void { - const originalLocation = location.href; - - if (replace) { - history.replaceState(null, /* ignored title */ '', absoluteInternalHref); - } else { - history.pushState(null, /* ignored title */ '', absoluteInternalHref); - } - - if (!isForSamePath(absoluteInternalHref, originalLocation)) { - scheduleScrollReset(ScrollResetSchedule.AfterDocumentUpdate); - } - - performEnhancedPageLoad(absoluteInternalHref, /* interceptedLink */ false); -} - -=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:129-159 === -function onDocumentClick(event: MouseEvent) { - // A nested click must not remove this listener from an outer click's dispatch. - if (clickListenerReorderPending && !isDispatchingClick()) { - onClickListenerRegistered(false, event); - } - - if (hasInteractiveRouter()) { - return; - } - - if (event.target instanceof Element && !enhancedNavigationIsEnabledForElement(event.target)) { - return; - } - - handleClickForNavigationInterception(event, absoluteInternalHref => { - const originalLocation = location.href; - - const shouldScrollToHash = isSamePageWithHash(originalLocation, absoluteInternalHref); - history.pushState(null, /* ignored title */ '', absoluteInternalHref); - - if (shouldScrollToHash) { - performScrollToElementOnTheSamePage(absoluteInternalHref); - } else { - const isSelfNavigation = isForSamePath(absoluteInternalHref, originalLocation); - performEnhancedPageLoad(absoluteInternalHref, /* interceptedLink */ true); - if (!isSelfNavigation) { - scheduleScrollReset(ScrollResetSchedule.AfterDocumentUpdate); - } - } - }); -} - -=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:100-105 === -function onClickCapture(event: MouseEvent) { - // Window capture observes even native document listeners registered before Blazor starts. - capturedClickEvents.add(event); - // Microtasks can run between browser-invoked listeners, so release the event after the dispatch task. - setTimeout(() => capturedClickEvents.delete(event), 0); -} - -=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:107-115 === -function isDispatchingBrowserClick(except?: MouseEvent): boolean { - for (const event of capturedClickEvents) { - if (event !== except && event.eventPhase !== Event.NONE) { - return true; - } - } - - return false; -} - -=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:117-127 === -function onClickListenerRegistered(isDispatchingClick: boolean, currentClick?: MouseEvent) { - // Removing a listener during dispatch skips it for that click. Let it run before reordering. - if (isDispatchingClick || isDispatchingBrowserClick(currentClick)) { - clickListenerReorderPending = true; - return; - } - - clickListenerReorderPending = false; - document.removeEventListener('click', onDocumentClick); - document.addEventListener('click', onDocumentClick); -} - -=== head 0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6 src/Components/Web.JS/src/Services/NavigationEnhancement.ts:243-269 === -export async function performEnhancedPageLoad(internalDestinationHref: string, interceptedLink: boolean, fetchOptions?: RequestInit, treatAsRedirectionFromMethod?: 'get' | 'post', changeUrl = true) { - performingEnhancedPageLoad = true; - - // First, stop any preceding enhanced page load - currentEnhancedNavigationAbortController?.abort(); - - // Notify any interactive runtimes that an enhanced navigation is starting - notifyEnhancedNavigationListeners(internalDestinationHref, interceptedLink); - - // Notify handlers that enhanced navigation is starting - navigationEnhancementCallbacks.enhancedNavigationStarted(); - - // Now request the new page via fetch, and a special header that tells the server we want it to inject - // framing boundaries to distinguish the initial document and each subsequent streaming SSR update. - currentEnhancedNavigationAbortController = new AbortController(); - const abortSignal = currentEnhancedNavigationAbortController.signal; - const responsePromise = fetch(internalDestinationHref, Object.assign({ - signal: abortSignal, - mode: 'no-cors', // If there's a redirection to an external origin, even if it enables CORS, we don't want to receive its content and patch it into our DOM on this origin - headers: { - // Because of no-cors, we can only send CORS-safelisted headers, so communicate the info about - // enhanced nav as a MIME type parameter - 'accept': acceptHeader, - }, - }, fetchOptions)); - let isNonRedirectedPostToADifferentUrlMessage: string | null = null; - await getResponsePartsWithFraming( diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/mergeBase.source b/eng/skill-evals/review-pull-request/fixtures/case-05/mergeBase.source deleted file mode 100644 index 26e2c9001c9e..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-05/mergeBase.source +++ /dev/null @@ -1,83 +0,0 @@ -=== mergeBase 2a731a48bdbe8747100ce19282d8b96bb93b876e src/Components/Web.JS/src/Services/NavigationEnhancement.ts:60-67 === -export function attachProgressivelyEnhancedNavigationListener(callbacks: NavigationEnhancementCallbacks) { - navigationEnhancementCallbacks = callbacks; - document.addEventListener('click', onDocumentClick); - document.addEventListener('submit', onDocumentSubmit); - window.addEventListener('popstate', onPopState); - - attachProgrammaticEnhancedNavigationHandler(performProgrammaticEnhancedNavigation); -} - -=== mergeBase 2a731a48bdbe8747100ce19282d8b96bb93b876e src/Components/Web.JS/src/Services/NavigationEnhancement.ts:75-89 === -function performProgrammaticEnhancedNavigation(absoluteInternalHref: string, replace: boolean) : void { - const originalLocation = location.href; - - if (replace) { - history.replaceState(null, /* ignored title */ '', absoluteInternalHref); - } else { - history.pushState(null, /* ignored title */ '', absoluteInternalHref); - } - - if (!isForSamePath(absoluteInternalHref, originalLocation)) { - scheduleScrollReset(ScrollResetSchedule.AfterDocumentUpdate); - } - - performEnhancedPageLoad(absoluteInternalHref, /* interceptedLink */ false); -} - -=== mergeBase 2a731a48bdbe8747100ce19282d8b96bb93b876e src/Components/Web.JS/src/Services/NavigationEnhancement.ts:91-116 === -function onDocumentClick(event: MouseEvent) { - if (hasInteractiveRouter()) { - return; - } - - if (event.target instanceof Element && !enhancedNavigationIsEnabledForElement(event.target)) { - return; - } - - handleClickForNavigationInterception(event, absoluteInternalHref => { - const originalLocation = location.href; - - const shouldScrollToHash = isSamePageWithHash(originalLocation, absoluteInternalHref); - history.pushState(null, /* ignored title */ '', absoluteInternalHref); - - if (shouldScrollToHash) { - performScrollToElementOnTheSamePage(absoluteInternalHref); - } else { - const isSelfNavigation = isForSamePath(absoluteInternalHref, originalLocation); - performEnhancedPageLoad(absoluteInternalHref, /* interceptedLink */ true); - if (!isSelfNavigation) { - scheduleScrollReset(ScrollResetSchedule.AfterDocumentUpdate); - } - } - }); -} - -=== mergeBase 2a731a48bdbe8747100ce19282d8b96bb93b876e src/Components/Web.JS/src/Services/NavigationEnhancement.ts:200-226 === -export async function performEnhancedPageLoad(internalDestinationHref: string, interceptedLink: boolean, fetchOptions?: RequestInit, treatAsRedirectionFromMethod?: 'get' | 'post', changeUrl = true) { - performingEnhancedPageLoad = true; - - // First, stop any preceding enhanced page load - currentEnhancedNavigationAbortController?.abort(); - - // Notify any interactive runtimes that an enhanced navigation is starting - notifyEnhancedNavigationListeners(internalDestinationHref, interceptedLink); - - // Notify handlers that enhanced navigation is starting - navigationEnhancementCallbacks.enhancedNavigationStarted(); - - // Now request the new page via fetch, and a special header that tells the server we want it to inject - // framing boundaries to distinguish the initial document and each subsequent streaming SSR update. - currentEnhancedNavigationAbortController = new AbortController(); - const abortSignal = currentEnhancedNavigationAbortController.signal; - const responsePromise = fetch(internalDestinationHref, Object.assign({ - signal: abortSignal, - mode: 'no-cors', // If there's a redirection to an external origin, even if it enables CORS, we don't want to receive its content and patch it into our DOM on this origin - headers: { - // Because of no-cors, we can only send CORS-safelisted headers, so communicate the info about - // enhanced nav as a MIME type parameter - 'accept': acceptHeader, - }, - }, fetchOptions)); - let isNonRedirectedPostToADifferentUrlMessage: string | null = null; - await getResponsePartsWithFraming( diff --git a/eng/skill-evals/review-pull-request/fixtures/case-05/provenance.json b/eng/skill-evals/review-pull-request/fixtures/case-05/provenance.json deleted file mode 100644 index 32289e60edb5..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-05/provenance.json +++ /dev/null @@ -1,145 +0,0 @@ -{ - "repository": "dotnet/aspnetcore", - "pullRequest": 70299, - "sourceRoles": { - "mergeBase": "2a731a48bdbe8747100ce19282d8b96bb93b876e", - "head": "0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6", - "baseTip": "2a731a48bdbe8747100ce19282d8b96bb93b876e" - }, - "files": [ - { - "file": "mergeBase.source", - "sha256": "19d83bf27940b4b66a5957ce363efd9c17c1d4757788b77891aa708cc5c01574", - "sources": [ - { - "role": "mergeBase", - "commit": "2a731a48bdbe8747100ce19282d8b96bb93b876e", - "path": "src/Components/Web.JS/src/Services/NavigationEnhancement.ts", - "blob": "7bd29bee95bb154787994017aceb0d29960ebebb", - "ranges": [ - [ - 60, - 67 - ], - [ - 75, - 89 - ], - [ - 91, - 116 - ], - [ - 200, - 226 - ] - ] - } - ] - }, - { - "file": "head.source", - "sha256": "2d34778b27f6c9fab6ae76e225d9bc1bd335b5422d54a6f94f0bb2c0ee4e25d0", - "sources": [ - { - "role": "head", - "commit": "0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6", - "path": "src/Components/Web.JS/src/Services/NavigationEnhancement.ts", - "blob": "dd06e2cf5beb414f8760fabfe97424414a032220", - "ranges": [ - [ - 63, - 72 - ], - [ - 84, - 98 - ], - [ - 129, - 159 - ], - [ - 100, - 105 - ], - [ - 107, - 115 - ], - [ - 117, - 127 - ], - [ - 243, - 269 - ] - ] - } - ] - }, - { - "file": "baseTip.source", - "sha256": "5eac5e1629c5d668ca00cd19a8e9ee49f11393e210323de6f78d97e274ac4d3a", - "sources": [ - { - "role": "baseTip", - "commit": "2a731a48bdbe8747100ce19282d8b96bb93b876e", - "path": "src/Components/Web.JS/src/Services/NavigationUtils.ts", - "blob": "9976eafc898cdc52039a75029da0c8dcfcdb6fb0", - "ranges": [ - [ - 1, - 158 - ] - ] - } - ] - }, - { - "file": "context.source", - "sha256": "f8f95a6e4bf3d5556b291e3294f880939669309ed03a29bc8dd0c6261bc58aaa", - "sources": [ - { - "role": "head", - "commit": "0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6", - "path": "src/Components/test/testassets/TestContentPackage/InteractiveNavigationComponent.razor", - "blob": "71217ca2ee717f7a6e9abd1adb7df6369413f2c1", - "ranges": [ - [ - 1, - 41 - ] - ] - }, - { - "role": "head", - "commit": "0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6", - "path": "src/Components/Web.JS/src/Rendering/Events/EventDelegatorListeners.ts", - "blob": "6b3737d7c0fecb9b8ae6805fe9744cb149e4c04e", - "ranges": [ - [ - 1, - 33 - ] - ] - } - ], - "feedback": { - "url": "https://github.com/dotnet/aspnetcore/pull/70299#discussion_r4487936812", - "commit": "0317f5f729136a3a4f7320ab8bff3aa7d66fe5d6", - "updatedAt": "2026-11-06T01:08:38Z", - "role": "frozen existing feedback, not a target contract or runtime trace" - } - }, - { - "file": "change.diff", - "sha256": "eb4815b07d61137eead6c4526cafa73e5c352547fe00acb53297b9c4b419e5e9" - }, - { - "file": "case.source", - "sha256": "7e72e1a5ecbfcc32c1be9ac2bbdd3bc2a66291542ab2baef7dca26efa02f122a" - } - ] -} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-06/case.source b/eng/skill-evals/review-pull-request/fixtures/case-06/case.source deleted file mode 100644 index bf9bd1ffa2c6..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-06/case.source +++ /dev/null @@ -1 +0,0 @@ -C1: The added inner catch prevents a diagnostic sink failure from reaching the caller of SendMessageAsync. Remove the inner catch so the sink exception propagates. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-06/context.source b/eng/skill-evals/review-pull-request/fixtures/case-06/context.source deleted file mode 100644 index 8418afe3187b..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-06/context.source +++ /dev/null @@ -1,40 +0,0 @@ -Selected scenario -Construct ConversationEngine with FailingClient and ThrowingDiagnosticSink. -Register StatusObserver.OnStatusChanged, then await SendMessageAsync. -These are the only implementations in scope for this bounded scenario. - -Originating issue -Report conversation-processing failures through the configured diagnostic sink. - -Target-base contract -Processing failures are exposed in Error and the Error status; notify status observers. - -PR rationale and test -The author says the nested catch preserves successful task completion. -A new test awaits SendMessageAsync and asserts that Error is the client's Failure. -Its complete implementation follows below. - -Existing feedback -None. - -using System.Threading.Tasks; -using Xunit; - -public class ConversationEngineTests -{ - [Fact] - public async Task ProcessingFailureIsExposed() - { - var client = new FailingClient(); - var sink = new ThrowingDiagnosticSink(); - var observer = new StatusObserver(); - var engine = new ConversationEngine(client, sink); - engine.StatusChanged += observer.OnStatusChanged; - - await engine.SendMessageAsync(); - - Assert.Same(client.Failure, engine.Error); - Assert.Equal("Error", engine.Status); - Assert.Equal(1, observer.NotificationCount); - } -} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-06/provenance.json b/eng/skill-evals/review-pull-request/fixtures/case-06/provenance.json deleted file mode 100644 index 0105c8582c94..000000000000 --- a/eng/skill-evals/review-pull-request/fixtures/case-06/provenance.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "repository": "dotnet/aspnetcore", - "pullRequest": 70312, - "fixtureKind": "synthetic public catch-policy example, not framework production source", - "revision": "4bb1a49fbbf7c217286f289cf975019491c83f16", - "transformations": [ - "Normalize scenario prompt to the single-candidate format.", - "Combine scenario and head test as context." - ], - "files": [ - { - "file": "mergeBase.source", - "sha256": "a41b5ee85d9f19c0b1002d988efe4adf5c479acba95e000f453dba7bcc715bb3" - }, - { - "file": "head.source", - "sha256": "6d6ba76ae43c4cb27de0c6579f5532c174b40d87de929717da0f6c2120631b24" - }, - { - "file": "baseTip.source", - "sha256": "e1621fa56245d23a6d234585cfc2da3f54dd148ee9a7ec2c7689000373b0046c" - }, - { - "file": "context.source", - "sha256": "3ad5fafd5ac86b76d82480d12cf889a520631431276567fb1bb45f069944b90b" - }, - { - "file": "change.diff", - "sha256": "fd8229c834dda082f4f4ae0dbd9d799c7c819df5b469ed2476e89f662fed840c" - }, - { - "file": "case.source", - "sha256": "71d7ca9d0dae95d9bba4e689d8979e1784db68c85a5bfcb65d82403e8f9d7ddd" - } - ] -} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-06/change.diff b/eng/skill-evals/review-pull-request/fixtures/catch-policy/ConversationEngine.diff similarity index 100% rename from eng/skill-evals/review-pull-request/fixtures/case-06/change.diff rename to eng/skill-evals/review-pull-request/fixtures/catch-policy/ConversationEngine.diff index 20f237e3708c..9523a4649cd3 100644 --- a/eng/skill-evals/review-pull-request/fixtures/case-06/change.diff +++ b/eng/skill-evals/review-pull-request/fixtures/catch-policy/ConversationEngine.diff @@ -5,7 +5,6 @@ diff --git a/ConversationEngine.cs.source b/ConversationEngine.cs.source { Error = processingError; Status = "Error"; - StatusChanged?.Invoke(Status); + try + { + _sink.Write(processingError); @@ -13,5 +12,6 @@ diff --git a/ConversationEngine.cs.source b/ConversationEngine.cs.source + catch (Exception) + { + } + StatusChanged?.Invoke(Status); return; } diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/ConversationEngineTests.cs.source b/eng/skill-evals/review-pull-request/fixtures/catch-policy/ConversationEngineTests.cs.source new file mode 100644 index 000000000000..43fb5be02639 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/catch-policy/ConversationEngineTests.cs.source @@ -0,0 +1,21 @@ +using System.Threading.Tasks; +using Xunit; + +public class ConversationEngineTests +{ + [Fact] + public async Task ProcessingFailureIsExposed() + { + var client = new FailingClient(); + var sink = new ThrowingDiagnosticSink(); + var observer = new StatusObserver(); + var engine = new ConversationEngine(client, sink); + engine.StatusChanged += observer.OnStatusChanged; + + await engine.SendMessageAsync(); + + Assert.Same(client.Failure, engine.Error); + Assert.Equal("Error", engine.Status); + Assert.Equal(1, observer.NotificationCount); + } +} diff --git a/eng/skill-evals/review-pull-request/fixtures/case-06/baseTip.source b/eng/skill-evals/review-pull-request/fixtures/catch-policy/Dependencies.cs.source similarity index 100% rename from eng/skill-evals/review-pull-request/fixtures/case-06/baseTip.source rename to eng/skill-evals/review-pull-request/fixtures/catch-policy/Dependencies.cs.source diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/best-effort.txt b/eng/skill-evals/review-pull-request/fixtures/catch-policy/best-effort.txt new file mode 100644 index 000000000000..9810331939f3 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/catch-policy/best-effort.txt @@ -0,0 +1,20 @@ +Selected scenario +Construct ConversationEngine with FailingClient and ThrowingDiagnosticSink. +Register StatusObserver.OnStatusChanged, then await SendMessageAsync. +These are the only implementations in scope for this bounded scenario. + +Originating issue +Report conversation-processing failures through the configured diagnostic sink. + +Target-base contract +Processing failures are exposed in Error and the Error status. +Error reporting is best-effort: suppress diagnostic sink failures, preserve the +processing failure in Error, notify status observers, and complete the task normally. + +PR rationale and test +The author says the nested catch preserves successful task completion. +A new test awaits SendMessageAsync and asserts that Error is the client's Failure. +Its complete implementation is in ConversationEngineTests.cs.source. + +Existing feedback +None. diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/existing-question.txt b/eng/skill-evals/review-pull-request/fixtures/catch-policy/existing-question.txt new file mode 100644 index 000000000000..5fe17f7e0a42 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/catch-policy/existing-question.txt @@ -0,0 +1,23 @@ +Selected scenario +Construct ConversationEngine with FailingClient and ThrowingDiagnosticSink. +Register StatusObserver.OnStatusChanged, then await SendMessageAsync. +These are the only implementations in scope for this bounded scenario. + +Originating issue +Report conversation-processing failures through the configured diagnostic sink. + +Target-base contract +Processing failures are exposed in Error and the Error status; notify status observers. +No target-base policy specifies whether diagnostic sink failures must propagate or +be suppressed. No additional primary contract evidence is available. + +PR rationale and test +The author says the nested catch preserves successful task completion. +A new test awaits SendMessageAsync and asserts that Error is the client's Failure. +Its complete implementation is in ConversationEngineTests.cs.source. + +Existing feedback +Thread feedback-17, on the newly added inner catch in ConversationEngine.cs: +"This empty handler swallows any exception thrown by the diagnostic sink, so the +caller never observes a sink failure. Should sink failures propagate instead?" +No reply or resolution is available. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-06/head.source b/eng/skill-evals/review-pull-request/fixtures/catch-policy/head/ConversationEngine.cs.source similarity index 100% rename from eng/skill-evals/review-pull-request/fixtures/case-06/head.source rename to eng/skill-evals/review-pull-request/fixtures/catch-policy/head/ConversationEngine.cs.source index e8d30b309c04..4330356e319a 100644 --- a/eng/skill-evals/review-pull-request/fixtures/case-06/head.source +++ b/eng/skill-evals/review-pull-request/fixtures/catch-policy/head/ConversationEngine.cs.source @@ -26,7 +26,6 @@ public sealed class ConversationEngine { Error = processingError; Status = "Error"; - StatusChanged?.Invoke(Status); try { _sink.Write(processingError); @@ -34,6 +33,7 @@ public sealed class ConversationEngine catch (Exception) { } + StatusChanged?.Invoke(Status); return; } } diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/nonthrowing.txt b/eng/skill-evals/review-pull-request/fixtures/catch-policy/nonthrowing.txt new file mode 100644 index 000000000000..ef162676fe48 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/catch-policy/nonthrowing.txt @@ -0,0 +1,24 @@ +Selected scenario +Construct ConversationEngine with FailingClient and RecordingDiagnosticSink. +Register StatusObserver.OnStatusChanged, then await SendMessageAsync. +These are the only implementations in scope for this bounded scenario. +ThrowingDiagnosticSink is not registered, selected, or called in this scenario. + +Originating issue +Report conversation-processing failures through the configured diagnostic sink. + +Target-base contract +Processing failures are exposed in Error and the Error status. +If the configured diagnostic sink fails during error reporting, the returned task +must fault with that sink failure. This applies to newly introduced reporting call +sites as well as existing ones. + +PR rationale and test +The author says the nested catch preserves successful task completion. +A new test awaits SendMessageAsync and asserts that Error is the client's Failure. +Its complete implementation is in ConversationEngineTests.cs.source. That separate +test configures ThrowingDiagnosticSink, not the RecordingDiagnosticSink selected +above. It is not evidence that the throwing sink is selected in this scenario. + +Existing feedback +None. diff --git a/eng/skill-evals/review-pull-request/fixtures/case-06/mergeBase.source b/eng/skill-evals/review-pull-request/fixtures/catch-policy/old/ConversationEngine.cs.source similarity index 100% rename from eng/skill-evals/review-pull-request/fixtures/case-06/mergeBase.source rename to eng/skill-evals/review-pull-request/fixtures/catch-policy/old/ConversationEngine.cs.source diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/propagation.txt b/eng/skill-evals/review-pull-request/fixtures/catch-policy/propagation.txt new file mode 100644 index 000000000000..ea905f90c5a1 --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/catch-policy/propagation.txt @@ -0,0 +1,21 @@ +Selected scenario +Construct ConversationEngine with FailingClient and ThrowingDiagnosticSink. +Register StatusObserver.OnStatusChanged, then await SendMessageAsync. +These are the only implementations in scope for this bounded scenario. + +Originating issue +Report conversation-processing failures through the configured diagnostic sink. + +Target-base contract +Processing failures are exposed in Error and the Error status. +If the configured diagnostic sink fails during error reporting, the returned task +must fault with that sink failure. This applies to newly introduced reporting call +sites as well as existing ones. + +PR rationale and test +The author says the nested catch preserves successful task completion. +A new test awaits SendMessageAsync and asserts that Error is the client's Failure. +Its complete implementation is in ConversationEngineTests.cs.source. + +Existing feedback +None. diff --git a/eng/skill-evals/review-pull-request/fixtures/catch-policy/unspecified.txt b/eng/skill-evals/review-pull-request/fixtures/catch-policy/unspecified.txt new file mode 100644 index 000000000000..253934caaa5f --- /dev/null +++ b/eng/skill-evals/review-pull-request/fixtures/catch-policy/unspecified.txt @@ -0,0 +1,20 @@ +Selected scenario +Construct ConversationEngine with FailingClient and ThrowingDiagnosticSink. +Register StatusObserver.OnStatusChanged, then await SendMessageAsync. +These are the only implementations in scope for this bounded scenario. + +Originating issue +Report conversation-processing failures through the configured diagnostic sink. + +Target-base contract +Processing failures are exposed in Error and the Error status; notify status observers. +No target-base policy specifies whether diagnostic sink failures must propagate or +be suppressed. No additional primary contract evidence is available. + +PR rationale and test +The author says the nested catch preserves successful task completion. +A new test awaits SendMessageAsync and asserts that Error is the client's Failure. +Its complete implementation is in ConversationEngineTests.cs.source. + +Existing feedback +None. diff --git a/eng/skill-evals/review-smoke.experiment.yaml b/eng/skill-evals/review-smoke.experiment.yaml deleted file mode 100644 index 045edaf91133..000000000000 --- a/eng/skill-evals/review-smoke.experiment.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: review-smoke -evals: - - review-pull-request/eval.vally.yaml - -overrides: - runs: 1 - -vary: - - /environment/skills - - /environment/files - -baseline: baseline -variants: - baseline: - environment: - skills: [] - skilled: - environment: - skills: - - ../../.github/skills/review-pull-request - files: - - { src: ../../docs/CrossCuttingGuidance.md, dest: docs/CrossCuttingGuidance.md } - - { src: ../../docs/BlazorComponentsGuidance.md, dest: docs/BlazorComponentsGuidance.md } - - { src: ../../.github/agents/review-candidate-verifier.agent.md, dest: .github/agents/review-candidate-verifier.agent.md } - - { src: ../../.github/agents/review-guide-worker.agent.md, dest: .github/agents/review-guide-worker.agent.md } diff --git a/eng/skill-evals/review-vs-baseline.experiment.yaml b/eng/skill-evals/review-vs-baseline.experiment.yaml deleted file mode 100644 index 9e880d3afb26..000000000000 --- a/eng/skill-evals/review-vs-baseline.experiment.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: review-vs-baseline -evals: - - review-pull-request/eval.vally.yaml - -# The reviewer treatment includes its skill and the profiles referenced by it. -vary: - - /environment/skills - - /environment/files - -baseline: baseline -variants: - baseline: - environment: - skills: [] - skilled: - environment: - skills: - - ../../.github/skills/review-pull-request - files: - - { src: ../../docs/CrossCuttingGuidance.md, dest: docs/CrossCuttingGuidance.md } - - { src: ../../docs/BlazorComponentsGuidance.md, dest: docs/BlazorComponentsGuidance.md } - - { src: ../../.github/agents/review-candidate-verifier.agent.md, dest: .github/agents/review-candidate-verifier.agent.md } - - { src: ../../.github/agents/review-guide-worker.agent.md, dest: .github/agents/review-guide-worker.agent.md } diff --git a/eng/skill-evals/test_run.ps1 b/eng/skill-evals/test_run.ps1 index ee70c89e9446..8a5ec7cf8d43 100644 --- a/eng/skill-evals/test_run.ps1 +++ b/eng/skill-evals/test_run.ps1 @@ -160,8 +160,8 @@ stimuli: Read-Invocations | Where-Object { $_.Arguments[0] -eq 'experiment' } ) - Assert-True ($validateInvocations.Count -eq 4) ( - 'Default validation did not resolve generic and reviewer experiments.' + Assert-True ($validateInvocations.Count -eq 2) ( + 'Default validation did not resolve generic experiments.' ) foreach ($invocation in $validateInvocations) { Assert-True ($invocation.Arguments[1] -eq 'run') ( @@ -180,12 +180,6 @@ stimuli: Assert-True ($validateInvocations.Arguments -contains ( Join-Path $repoRoot 'eng/skill-evals/skills-smoke.experiment.yaml' )) 'Default validation did not resolve the smoke experiment.' - Assert-True ($validateInvocations.Arguments -contains ( - Join-Path $repoRoot 'eng/skill-evals/review-vs-baseline.experiment.yaml' - )) 'Default validation did not resolve the reviewer experiment.' - Assert-True ($validateInvocations.Arguments -contains ( - Join-Path $repoRoot 'eng/skill-evals/review-smoke.experiment.yaml' - )) 'Default validation did not resolve the reviewer smoke experiment.' Remove-Item $record & $runner Validate ` @@ -246,43 +240,6 @@ stimuli: Assert-True ($specializedInvocation[0] -eq 'eval') 'Specialized run did not use Vally eval.' Assert-True ($specializedInvocation -contains '--eval-spec') 'Specialized run omitted --eval-spec.' - Remove-Item $record - & $runner Validate ` - -Suite review-pull-request ` - -Vally $fakeVally ` - -VallyPrefix @() - $suiteInvocations = @(Read-Invocations) - $suiteLint = @($suiteInvocations | Where-Object { $_.Arguments[0] -eq 'lint' }) - Assert-True ($suiteLint.Count -eq 1) 'Suite validation linted unrelated specifications.' - Assert-True ($suiteLint[0].Arguments -contains ( - Join-Path $repoRoot 'eng/skill-evals/review-pull-request/eval.vally.yaml' - )) 'Suite validation did not lint the selected specification.' - $suitePlans = @($suiteInvocations | Where-Object { $_.Arguments[0] -eq 'experiment' }) - Assert-True ($suitePlans.Count -eq 2) 'Suite validation did not resolve both experiments.' - foreach ($invocation in $suitePlans) { - Assert-True ($invocation.Arguments -contains '--dry-run') 'Suite validation could invoke models.' - Assert-True ($invocation.Arguments -contains '--eval-filter') 'Suite validation omitted its filter.' - Assert-True ($invocation.Arguments -contains 'review-pull-request/eval.vally.yaml') 'Suite validation selected the wrong eval.' - } - - & $runner Run ` - -Suite review-pull-request ` - -Vally $fakeVally ` - -VallyPrefix @() ` - -OutputDirectory $output - $suiteRun = Read-Invocation - Assert-True ($suiteRun[0] -eq 'experiment') 'Suite run bypassed experiment skill ownership.' - Assert-True ($suiteRun -contains 'review-pull-request/eval.vally.yaml') 'Suite run selected the wrong eval.' - Assert-True ($suiteRun -contains (Join-Path $repoRoot 'eng/skill-evals/review-vs-baseline.experiment.yaml')) ( - 'Reviewer run used the generic treatment.' - ) - & $runner Run -Suite review-pull-request ` - -Experiment eng/skill-evals/skills-smoke.experiment.yaml ` - -Vally $fakeVally -VallyPrefix @() -OutputDirectory $output - Assert-True ((Read-Invocation) -contains (Join-Path $repoRoot 'eng/skill-evals/review-smoke.experiment.yaml')) ( - 'Reviewer smoke run used the generic treatment.' - ) - foreach ($smoke in @($false, $true)) { $componentOutput = Join-Path $testRoot "component-$smoke" New-Item -ItemType Directory -Path (Join-Path $componentOutput '2025-12-31T00-00-00') -Force | Out-Null @@ -301,15 +258,6 @@ stimuli: 'Component plan lost its per-case 4/5 disposition gate.' ) } - $componentOutput = Join-Path $testRoot 'component-review-smoke' - & $runner Run -Suite review-candidate-verifier ` - -Experiment eng/skill-evals/review-smoke.experiment.yaml ` - -Vally $fakeVally -VallyPrefix @() -OutputDirectory $componentOutput - $componentRun = Read-Invocation - Assert-True ($componentRun[([array]::IndexOf($componentRun, '--runs') + 1)] -eq '1') ( - 'Reviewer smoke selection unexpectedly ran the full component suite.' - ) - function Assert-CustomComponentPlan { param( [string]$Scenario, @@ -430,9 +378,6 @@ stimuli: Where-Object { Test-Path (Join-Path $_.FullName 'eval.vally.yaml') }).Count Assert-True ($allRuns.Count -eq $suiteCount) 'Default run omitted a standard suite.' Assert-True (($allRuns.Arguments -join ' ') -like '*review-candidate-verifier*') 'Default run omitted the component suite.' - Assert-True ($allRuns.Arguments -contains (Join-Path $repoRoot 'eng/skill-evals/review-vs-baseline.experiment.yaml')) ( - 'Default run omitted the reviewer comparison.' - ) foreach ($invalidSuite in @('../outside', '..', 'missing-suite')) { $rejected = $false diff --git a/eng/skill-evals/tests/test_review_fixtures.ps1 b/eng/skill-evals/tests/test_review_fixtures.ps1 index 36e7a0ab0c63..ad184c165ad2 100644 --- a/eng/skill-evals/tests/test_review_fixtures.ps1 +++ b/eng/skill-evals/tests/test_review_fixtures.ps1 @@ -3,18 +3,9 @@ $ErrorActionPreference = 'Stop' Set-StrictMode -Version 3 -$suiteRoot = (Resolve-Path (Join-Path $PSScriptRoot '../review-pull-request')).Path -$specPath = Join-Path $suiteRoot 'eval.vally.yaml' -$json = Get-Content $specPath -Raw | & npx ` - --yes ` - --registry=https://packagefeedproxy.microsoft.io/npm/ ` - 'yaml@2.9.1' --json --single --strict -if ($LASTEXITCODE -ne 0) { - throw 'Could not parse the review fixture specification.' -} -$spec = $json | ConvertFrom-Json -AsHashtable -Depth 100 +$componentRoot = (Resolve-Path (Join-Path $PSScriptRoot '../review-candidate-verifier')).Path +$repoRoot = (Resolve-Path (Join-Path $componentRoot '../../..')).Path $script:checks = 0 -$componentRoot = Join-Path (Split-Path $suiteRoot -Parent) 'review-candidate-verifier' function Assert-True { param([bool]$Condition, [string]$Message) @@ -31,212 +22,10 @@ function Test-FileHash { return (Get-FileHash $Path -Algorithm SHA256).Hash -eq $Hash } -Assert-True ($spec.stimuli.Count -eq 6) 'The suite must retain five PR cases and one catch-policy case.' -Assert-True (-not (Test-Path (Join-Path $suiteRoot 'catch-policy.vally.yaml'))) ( - 'The superseded standalone catch-policy specification remains.' -) -Assert-True (-not (Test-Path (Join-Path $suiteRoot 'fixtures/catch-policy'))) ( - 'The superseded standalone catch-policy fixtures remain.' -) -Assert-True ( - @(Get-ChildItem (Join-Path $suiteRoot 'fixtures') -Recurse -File -Filter '*.txt').Count -eq 0 -) 'The synthetic text fixtures remain.' foreach ($package in 'package-a', 'package-b', 'package-c') { $bundleIndex = Get-Content (Join-Path $componentRoot "fixtures/$package/bundle-index.json") -Raw Assert-True (-not $bundleIndex.Contains('\')) "The $package bundle index contains non-portable backslash separators." } - -$neutralDispositionDefinitions = @( - 'verified: a real defect established by the supplied evidence.' - 'EXISTING_FEEDBACK_COVERAGE: the claim is already raised in existing feedback.' - 'UNRESOLVED: the claim is not resolved by the supplied evidence.' - 'DISCARDED: the claim is ruled out as a material defect by the supplied evidence.' -) -function Test-NeutralDispositionDefinitions { - param([string]$Prompt) - - $lines = @($Prompt -split '\r?\n' | ForEach-Object { $_.Trim() }) - $headingIndexes = @( - for ($index = 0; $index -lt $lines.Count; $index++) { - if ($lines[$index] -ceq 'Disposition label meanings:') { - $index - } - } - ) - if ($headingIndexes.Count -ne 1) { - return $false - } - - $block = [Collections.Generic.List[string]]::new() - for ($index = $headingIndexes[0] + 1; - $index -lt $lines.Count -and -not [string]::IsNullOrWhiteSpace($lines[$index]); - $index++) { - $block.Add($lines[$index]) - } - if ($block.Count -ne $neutralDispositionDefinitions.Count) { - return $false - } - for ($index = 0; $index -lt $neutralDispositionDefinitions.Count; $index++) { - if ($block[$index] -cne $neutralDispositionDefinitions[$index] -or - @($lines | Where-Object { $_ -ceq $neutralDispositionDefinitions[$index] }).Count -ne 1) { - return $false - } - } - return $true -} - -$exactDefinitionPrompt = @" -Disposition label meanings: -$($neutralDispositionDefinitions -join "`n") - -Continue with neutral formatting instructions. -"@ -Assert-True (Test-NeutralDispositionDefinitions $exactDefinitionPrompt) ( - 'The exact neutral disposition definition block was rejected.' -) -$substitutedDefinitionPrompt = $exactDefinitionPrompt.Replace( - $neutralDispositionDefinitions[0], - 'verified: select NEW_FINDINGS when the treatment verifier returns KEEP.' -) -Assert-True (-not (Test-NeutralDispositionDefinitions $substitutedDefinitionPrompt)) ( - 'A treatment-only substituted disposition definition was accepted.' -) -$appendedDefinitionPrompt = $exactDefinitionPrompt.Replace( - $neutralDispositionDefinitions[-1], - "$($neutralDispositionDefinitions[-1])`nselection rule: map verifier external downgrades to UNRESOLVED." -) -Assert-True (-not (Test-NeutralDispositionDefinitions $appendedDefinitionPrompt)) ( - 'A treatment-only appended disposition rule was accepted.' -) - -$neutralCoordinatorText = "so apply SKILL.md's coordinator disposition rules rather than raw subordinate worker/verifier outputs." -foreach ($stimulus in $spec.stimuli) { - $normalizedPrompt = ($stimulus.prompt -replace '\s+', ' ').Trim() - Assert-True ( - $normalizedPrompt.Contains($neutralCoordinatorText, [StringComparison]::Ordinal) - ) "$($stimulus.name) does not use the neutral SKILL.md coordinator instruction." - Assert-True ( - -not $normalizedPrompt.Contains( - 'mapping verifier external downgrades and unestablished drops to UNRESOLVED', - [StringComparison]::Ordinal - ) - ) "$($stimulus.name) leaks the expected coordinator disposition mapping." - Assert-True ( - $normalizedPrompt.Contains( - 'When confidence is unresolved or discarded, prefix the inline entry', - [StringComparison]::Ordinal - ) -and - $normalizedPrompt.Contains( - 'include Why unresolved: or Why discarded:.', - [StringComparison]::Ordinal - ) - ) "$($stimulus.name) lost its allowed disposition format instructions." - Assert-True (Test-NeutralDispositionDefinitions $stimulus.prompt) ( - "$($stimulus.name) does not contain exactly the neutral disposition label definitions." - ) -} - -$supportFiles = @($spec.agent_environment.files) -Assert-True ( - @($supportFiles | Where-Object { $_.src -match 'SKILL\.md$|\.agent\.md$' }).Count -eq 0 -) 'The standard suite stages treatment instructions into its baseline.' -Assert-True ($spec.scoring.weights.program -eq 1) 'Disposition is not the primary deterministic gate.' -foreach ($key in 'skill-invocation', 'tool-calls', 'prompt') { - Assert-True ($spec.scoring.weights[$key] -eq 0) "The $key grader confounds disposition quality." -} - -foreach ($stimulus in $spec.stimuli) { - $caseRoot = Join-Path $suiteRoot "fixtures/$($stimulus.name)" - $provenance = Get-Content (Join-Path $caseRoot 'provenance.json') -Raw | - ConvertFrom-Json -AsHashtable -Depth 100 - Assert-True ($stimulus.name -match '^case-\d\d$') 'A stimulus name reveals its source or answer.' - Assert-True ($provenance.repository -eq 'dotnet/aspnetcore') 'A fixture comes from another repository.' - if ($stimulus.name -ne 'case-06') { - Assert-True ( - @($provenance.sourceRoles.Keys | Sort-Object) -join ',' -eq 'baseTip,head,mergeBase' - ) 'A frozen source role is missing.' - } else { - Assert-True ($provenance.fixtureKind -like 'synthetic public*') 'The catch example is misrepresented as production source.' - foreach ($caseFile in Get-ChildItem $caseRoot -File) { - $text = Get-Content $caseFile.FullName -Raw - Assert-True ( - $text -notmatch 'No target-base policy|No additional primary contract|unspecified\.txt|suppression-policy absence' - ) "The catch case file $($caseFile.Name) includes an answer hint." - } - foreach ($fileName in 'head.source', 'change.diff') { - $text = Get-Content (Join-Path $caseRoot $fileName) -Raw - $notificationIndex = $text.IndexOf('StatusChanged?.Invoke(Status);', [StringComparison]::Ordinal) - $sinkIndex = $text.IndexOf('_sink.Write(processingError);', [StringComparison]::Ordinal) - Assert-True ($notificationIndex -ge 0 -and $sinkIndex -gt $notificationIndex) ( - "The catch case $fileName must notify observers before invoking the diagnostic sink." - ) - } - } - - foreach ($file in $provenance.files) { - $path = Join-Path $caseRoot $file.file - Assert-True (Test-FileHash $path $file.sha256) "Frozen fixture hash mismatch: $path." - if ($file.ContainsKey('sources')) { - foreach ($source in $file.sources) { - Assert-True ( - $source.commit -eq $provenance.sourceRoles[$source.role] - ) "Source role mismatch: $path." - Assert-True ( - $source.blob -match '^[0-9a-f]{40}$' -and $source.ranges.Count -gt 0 - ) "Source blob or ranges are missing: $path." - } - } - } - - $trialFiles = @($supportFiles) + @($stimulus.agent_environment.files) - $requiredReads = @( - $stimulus.graders | - Where-Object { $_.type -eq 'tool-calls' } | - ForEach-Object { $_.config.required } - ) - foreach ($file in $trialFiles) { - $path = Join-Path $suiteRoot $file.src - $content = Get-Content $path -Raw - $matchingReads = @($requiredReads | Where-Object { - $file.dest -match $_.pattern -and $content -match $_.result - }) - Assert-True ($matchingReads.Count -gt 0) "No actual-byte read guard covers $($stimulus.name)/$($file.dest)." - } - Assert-True ( - @($requiredReads | Where-Object { - $_.pattern -eq 'review-pull-request' -and $_.result -eq 'Return result; never publish' - }).Count -eq 1 - ) 'The skill acquisition needs one real-content receipt, not two conjunctive tool choices.' -} - -$sampleRoot = Join-Path $suiteRoot 'fixtures/case-01' -$sample = Get-Content (Join-Path $sampleRoot 'provenance.json') -Raw | - ConvertFrom-Json -AsHashtable -Depth 100 -$file = $sample.files[0] -Assert-True ( - -not (Test-FileHash (Join-Path $sampleRoot $file.file) ('0' * 64)) -) 'A wrong snapshot hash passes the integrity check.' - -$repoRoot = (Resolve-Path (Join-Path $suiteRoot '../../..')).Path -$evalRoot = Split-Path $suiteRoot -Parent -foreach ($experimentName in 'review-vs-baseline', 'review-smoke') { - $experimentText = Get-Content (Join-Path $evalRoot "$experimentName.experiment.yaml") -Raw | - & npx --yes --registry=https://packagefeedproxy.microsoft.io/npm/ 'yaml@2.9.1' --json --single --strict - if ($LASTEXITCODE -ne 0) { - throw "Could not parse $experimentName." - } - $experiment = $experimentText | ConvertFrom-Json -AsHashtable -Depth 100 - $baseline = $experiment.variants.baseline.environment - $skilled = $experiment.variants.skilled.environment - Assert-True ($baseline.skills.Count -eq 0 -and -not $baseline.ContainsKey('files')) ( - 'Baseline receives additional treatment files.' - ) - Assert-True ($skilled.skills.Count -eq 1) 'The skilled variant lacks its skill.' - Assert-True (@($skilled.files | Where-Object dest -like '*.agent.md').Count -eq 2) ( - 'Only the skilled variant must receive both reviewer profiles.' - ) -} - $componentText = Get-Content (Join-Path $componentRoot 'eval.vally.yaml') -Raw | & npx --yes --registry=https://packagefeedproxy.microsoft.io/npm/ 'yaml@2.9.1' --json --single --strict if ($LASTEXITCODE -ne 0) { @@ -265,26 +54,6 @@ $checkoutRoot = Join-Path ([IO.Path]::GetTempPath()) ( ) New-Item -ItemType Directory -Path $checkoutRoot | Out-Null try { - $fixturePaths = @( - Get-ChildItem (Join-Path $suiteRoot 'fixtures') -Recurse -File -Force | - ForEach-Object { [IO.Path]::GetRelativePath($repoRoot, $_.FullName).Replace('\', '/') } - ) - & git -C $repoRoot -c core.autocrlf=true checkout-index ` - "--prefix=$checkoutRoot$([IO.Path]::DirectorySeparatorChar)" -- @fixturePaths - if ($LASTEXITCODE -ne 0) { - throw 'Could not materialize the tracked fixture files through Git.' - } - foreach ($stimulus in $spec.stimuli) { - $relativeRoot = "eng/skill-evals/review-pull-request/fixtures/$($stimulus.name)" - $checkedOutRoot = Join-Path $checkoutRoot $relativeRoot - $provenance = Get-Content (Join-Path $checkedOutRoot 'provenance.json') -Raw | - ConvertFrom-Json -AsHashtable -Depth 100 - foreach ($file in $provenance.files) { - Assert-True ( - Test-FileHash (Join-Path $checkedOutRoot $file.file) $file.sha256 - ) "Git checkout changed the frozen bytes of $relativeRoot/$($file.file)." - } - } $componentRelative = 'eng/skill-evals/review-candidate-verifier/fixtures' $componentPaths = @( Get-ChildItem (Join-Path $componentRoot 'fixtures') -Recurse -File -Force | From 749d850d29006e598a948efd90f2bca4b14e450c Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Fri, 13 Nov 2026 11:05:23 -0600 Subject: [PATCH 09/23] Fix skill-eval staging and disposition edge cases Restore trusted reviewer experiments, reject shadowed grader configuration and malformed dispositions, and preserve runner result checks. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/grade_disposition.mjs | 5 +- eng/skill-evals/review-smoke.experiment.yaml | 25 +++++++++ .../review-vs-baseline.experiment.yaml | 23 ++++++++ eng/skill-evals/run.ps1 | 19 +++++-- eng/skill-evals/stage_run.ps1 | 6 +- eng/skill-evals/test_disposition.mjs | 56 ++++++++++++++++++- eng/skill-evals/test_run.ps1 | 44 ++++++++++----- eng/skill-evals/test_stage_run.ps1 | 54 ++++++++++++++++++ 8 files changed, 208 insertions(+), 24 deletions(-) create mode 100644 eng/skill-evals/review-smoke.experiment.yaml create mode 100644 eng/skill-evals/review-vs-baseline.experiment.yaml diff --git a/eng/skill-evals/grade_disposition.mjs b/eng/skill-evals/grade_disposition.mjs index 1e09acbcdc44..9cb4844a71d0 100644 --- a/eng/skill-evals/grade_disposition.mjs +++ b/eng/skill-evals/grade_disposition.mjs @@ -62,7 +62,8 @@ function gradeComponent(name, output) // Inapplicable fields may be omitted, null, or explicitly marked none. return ['downgradeKind', 'dropBasis', 'contradictedLink'] .filter(key => !(key in expected)) - .every(key => actual[key] == null || ['', 'none', 'n/a'].includes(normalized(key))); + .every(key => actual[key] == null || + (typeof actual[key] === 'string' && ['', 'none', 'n/a'].includes(normalized(key)))); } const targetSections = ['NEW_FINDINGS', 'EXISTING_FEEDBACK_COVERAGE', 'UNRESOLVED', 'DISCARDED']; @@ -101,7 +102,7 @@ function isNegativeC1Line(line) .trim() .replace(/^(?:[-*+]|\d+[.)])\s+/, '') .trim(); - const explicitAbsence = /^(?:none|n\/a)\b|^no(?:\s+(?:findings|items|candidates|entries|unresolved|discarded|existing\s+feedback)\b|\s+C1[.!]?\s*$|[.!]?\s*$)/i; + const explicitAbsence = /^(?:none(?:\s+(?:applicable|covered|found|reported|identified))?[.!]?\s*$|n\/a[.!]?\s*$|no(?:\s+(?:findings|items|candidates|entries|unresolved|discarded|existing\s+feedback)\b|\s+C1[.!]?\s*$|[.!]?\s*$))/i; if (!clean || explicitAbsence.test(clean)) { return true; diff --git a/eng/skill-evals/review-smoke.experiment.yaml b/eng/skill-evals/review-smoke.experiment.yaml new file mode 100644 index 000000000000..045edaf91133 --- /dev/null +++ b/eng/skill-evals/review-smoke.experiment.yaml @@ -0,0 +1,25 @@ +name: review-smoke +evals: + - review-pull-request/eval.vally.yaml + +overrides: + runs: 1 + +vary: + - /environment/skills + - /environment/files + +baseline: baseline +variants: + baseline: + environment: + skills: [] + skilled: + environment: + skills: + - ../../.github/skills/review-pull-request + files: + - { src: ../../docs/CrossCuttingGuidance.md, dest: docs/CrossCuttingGuidance.md } + - { src: ../../docs/BlazorComponentsGuidance.md, dest: docs/BlazorComponentsGuidance.md } + - { src: ../../.github/agents/review-candidate-verifier.agent.md, dest: .github/agents/review-candidate-verifier.agent.md } + - { src: ../../.github/agents/review-guide-worker.agent.md, dest: .github/agents/review-guide-worker.agent.md } diff --git a/eng/skill-evals/review-vs-baseline.experiment.yaml b/eng/skill-evals/review-vs-baseline.experiment.yaml new file mode 100644 index 000000000000..9e880d3afb26 --- /dev/null +++ b/eng/skill-evals/review-vs-baseline.experiment.yaml @@ -0,0 +1,23 @@ +name: review-vs-baseline +evals: + - review-pull-request/eval.vally.yaml + +# The reviewer treatment includes its skill and the profiles referenced by it. +vary: + - /environment/skills + - /environment/files + +baseline: baseline +variants: + baseline: + environment: + skills: [] + skilled: + environment: + skills: + - ../../.github/skills/review-pull-request + files: + - { src: ../../docs/CrossCuttingGuidance.md, dest: docs/CrossCuttingGuidance.md } + - { src: ../../docs/BlazorComponentsGuidance.md, dest: docs/BlazorComponentsGuidance.md } + - { src: ../../.github/agents/review-candidate-verifier.agent.md, dest: .github/agents/review-candidate-verifier.agent.md } + - { src: ../../.github/agents/review-guide-worker.agent.md, dest: .github/agents/review-guide-worker.agent.md } diff --git a/eng/skill-evals/run.ps1 b/eng/skill-evals/run.ps1 index e394e94b7151..5a5200210f17 100644 --- a/eng/skill-evals/run.ps1 +++ b/eng/skill-evals/run.ps1 @@ -85,6 +85,7 @@ $selectedExperiment = if ($hasExplicitExperiment) { $script:vallyInitialized = $false $reviewExperiment = Join-Path $evalRoot 'review-vs-baseline.experiment.yaml' $reviewSmokeExperiment = Join-Path $evalRoot 'review-smoke.experiment.yaml' +$reviewEval = Join-Path $evalRoot 'review-pull-request/eval.vally.yaml' function Resolve-Eval { if (-not $Eval) { @@ -310,13 +311,13 @@ switch ($Action) { # Component specs have no skill treatment. Lint validates their schema. } elseif ($hasExplicitExperiment) { Invoke-VallyExperimentDryRun $selectedExperiment - } elseif ($Suite -eq 'review-pull-request' -and (Test-Path $reviewExperiment)) { + } elseif ($Suite -eq 'review-pull-request' -and (Test-Path $reviewEval)) { Invoke-VallyExperimentDryRun $reviewExperiment Invoke-VallyExperimentDryRun $reviewSmokeExperiment } else { Invoke-VallyExperimentDryRun $standardExperiment Invoke-VallyExperimentDryRun $smokeExperiment - if (Test-Path $reviewExperiment) { + if (Test-Path $reviewEval) { Invoke-VallyExperimentDryRun $reviewExperiment Invoke-VallyExperimentDryRun $reviewSmokeExperiment } @@ -365,6 +366,7 @@ switch ($Action) { throw "The '$($directory.Name)' suite run failed." } & (Join-Path $PSScriptRoot 'assert_results.ps1') -OutputDirectory $suiteOutput + $global:LASTEXITCODE = 0 Write-Warning "Vally exited with code 1 for '$($directory.Name)'. Complete primary trials passed the applicable result-set checks." } } @@ -423,10 +425,19 @@ switch ($Action) { } $runs = $parsedRuns } else { - $threshold = [double]$value - if (-not [double]::IsFinite($threshold) -or $threshold -lt 0 -or $threshold -gt 1) { + $parsedThreshold = 0.0 + if ([string]::IsNullOrWhiteSpace($value) -or + -not [double]::TryParse( + $value, + [Globalization.NumberStyles]::Float, + [Globalization.CultureInfo]::InvariantCulture, + [ref]$parsedThreshold + ) -or + -not [double]::IsFinite($parsedThreshold) -or + $parsedThreshold -lt 0 -or $parsedThreshold -gt 1) { throw '--threshold must be between 0 and 1.' } + $threshold = $parsedThreshold } } } diff --git a/eng/skill-evals/stage_run.ps1 b/eng/skill-evals/stage_run.ps1 index 302e35ec4810..cec1d241cc80 100644 --- a/eng/skill-evals/stage_run.ps1 +++ b/eng/skill-evals/stage_run.ps1 @@ -141,11 +141,11 @@ function Find-ForbiddenEvalField { if ($DispositionMode -and $Node['type'] -ceq 'program') { $config = $Node['config'] - if ($config -isnot [Collections.IDictionary] -or $config.Count -ne 3 -or + if ($config -isnot [Collections.IDictionary] -or $config.PSBase.Count -ne 3 -or $config['program'] -cne 'node' -or $config['args'] -isnot [Collections.IEnumerable] -or $config['args'] -is [string] -or @($config['args']).Count -ne 1 -or $config['args'][0] -cne 'grade_disposition.mjs' -or - $config['env'] -isnot [Collections.IDictionary] -or $config['env'].Count -ne 1 -or + $config['env'] -isnot [Collections.IDictionary] -or $config['env'].PSBase.Count -ne 1 -or $config['env']['DISPOSITION_MODE'] -cne $DispositionMode) { return "declares a forbidden program grader; use only node grade_disposition.mjs with DISPOSITION_MODE=$DispositionMode." } @@ -160,7 +160,7 @@ function Find-ForbiddenEvalField { } } - foreach ($value in $Node.Values) { + foreach ($value in $Node.PSBase.Values) { $found = Find-ForbiddenEvalField $value $DispositionMode if ($found) { return $found diff --git a/eng/skill-evals/test_disposition.mjs b/eng/skill-evals/test_disposition.mjs index 1b1ec9692b00..41ec20039ea6 100644 --- a/eng/skill-evals/test_disposition.mjs +++ b/eng/skill-evals/test_disposition.mjs @@ -87,7 +87,7 @@ None.`), 1); - \`UNRESOLVED\`: **C1:** Missing target-base policy contract. - __DISCARDED__: -None. **C1 is unresolved rather than discarded.** +None. TEST_BOUNDARY Offline review of C1 only. LIMITATIONS @@ -187,6 +187,34 @@ test('ReviewDispositionDistinguishesNoProseFromSectionAbsence', async context => } }); +test('ReviewDispositionDistinguishesSubstantiveNoneFromAbsenceMarkers', async context => +{ + for (const [name, caseName, output, expected] of [ + ['unresolved-none-of', 'case-06', review('UNRESOLVED', 'unresolved') + .replace('C1 missing target-base contract.', 'C1: None of the frozen contracts establishes whether failures propagate.'), 1], + ['discarded-none-of', 'case-01', review('DISCARDED', 'discarded') + .replace('C1 old and head match.', 'C1: None of the compared lines changes request behavior.'), 1], + ['conflicting-none-of', 'case-02', review('NEW_FINDINGS', 'verified') + .replace('UNRESOLVED\nNone.', 'UNRESOLVED\nC1: None of the frozen contracts establishes whether failures propagate.'), 0], + ['conflicting-none-applicable-prose', 'case-02', review('NEW_FINDINGS', 'verified') + .replace('UNRESOLVED\nNone.', 'UNRESOLVED\nC1: None applicable. C1 is unresolved.'), 0], + ]) + { + await context.test(name, () => + { + assert.equal(score(caseName, output), expected); + }); + } + + for (const marker of ['None.', 'None applicable.', 'None covered.', 'None found.', + 'None reported.', 'None identified.', 'n/a', 'N/A.']) + { + const output = review('NEW_FINDINGS', 'verified') + .replace('UNRESOLVED\nNone.', `UNRESOLVED\nC1: ${marker}`); + assert.equal(score('case-02', output), 1, marker); + } +}); + test('ExistingFeedbackRequiresThreadAndRejectsDuplicateInline', () => { const good = `STATUS: NO_FINDINGS @@ -237,3 +265,29 @@ test('ComponentDispositionNormalizesOnlyApplicableFields', () => assert.equal(score('a', output, 'component'), 0, output); } }); + +test('ComponentDispositionRejectsNonStringInapplicableFields', async context => +{ + for (const [name, value] of [ + ['dropBasis-number', { dropBasis: 123 }], + ['contradictedLink-object', { contradictedLink: {} }], + ['downgradeKind-false', { downgradeKind: false }], + ['dropBasis-array', { dropBasis: [] }], + ]) + { + await context.test(name, () => + { + assert.equal(score('b', JSON.stringify({ decision: 'KEEP', ...value }), 'component'), 0); + }); + } + + for (const sentinel of [null, '', 'none', 'n/a']) + { + assert.equal(score('b', JSON.stringify({ + decision: 'KEEP', + downgradeKind: sentinel, + dropBasis: sentinel, + contradictedLink: sentinel, + }), 'component'), 1, String(sentinel)); + } +}); diff --git a/eng/skill-evals/test_run.ps1 b/eng/skill-evals/test_run.ps1 index 8a5ec7cf8d43..aed946266d7d 100644 --- a/eng/skill-evals/test_run.ps1 +++ b/eng/skill-evals/test_run.ps1 @@ -129,8 +129,7 @@ stimuli: - name: beta '@ | Set-Content (Join-Path $customComponentDirectory 'eval.vally.yaml') $allComponentDirectory = Join-Path $allSuiteRoot 'eng/skill-evals/review-candidate-verifier' - $allNextDirectory = Join-Path $allSuiteRoot 'eng/skill-evals/z-next' - New-Item -ItemType Directory -Path $allComponentDirectory, $allNextDirectory -Force | Out-Null + New-Item -ItemType Directory -Path $allComponentDirectory -Force | Out-Null @' name: review-candidate-verifier defaults: @@ -142,11 +141,6 @@ stimuli: - name: b - name: c '@ | Set-Content (Join-Path $allComponentDirectory 'eval.vally.yaml') - @' -name: z-next -stimuli: - - name: next -'@ | Set-Content (Join-Path $allNextDirectory 'eval.vally.yaml') $env:SKILL_EVAL_RUNNER_RECORD = $record $env:SKILL_EVAL_VALLY = $fakeVally @@ -262,6 +256,7 @@ stimuli: param( [string]$Scenario, [int]$ExpectedRuns, + [double]$ExpectedThreshold = 0.65, [string[]]$RunArguments = @() ) @@ -279,7 +274,7 @@ stimuli: Assert-True ($plan.evals[0].plannedStimulusCount -eq 2) ( "$Scenario component plan did not derive its stimulus count from the selected YAML." ) - Assert-True ([Math]::Abs([double]$plan.evals[0].threshold - 0.65) -lt 0.000001) ( + Assert-True ([Math]::Abs([double]$plan.evals[0].threshold - $ExpectedThreshold) -lt 0.000001) ( "$Scenario component plan did not derive its threshold from the selected YAML." ) Assert-True ($plan.evals[0].runs -eq $ExpectedRuns) ( @@ -331,6 +326,9 @@ stimuli: Assert-True ([string]::IsNullOrWhiteSpace($message)) ( "A complete passing primary result set did not continue after Vally exit 1: $message" ) + Assert-True ($LASTEXITCODE -eq 0) ( + 'A tolerated final-suite Vally exit code remained after successful result assertions.' + ) } else { Assert-True ($message -like "*$ExpectedFailure*") ( "$Scenario did not abort through the trusted result gate. Error: $message" @@ -340,15 +338,10 @@ stimuli: Read-Invocations | Where-Object { $_.Arguments[0] -in @('experiment', 'eval') } ) - $expectedCount = if ($ShouldContinue) { 2 } else { 1 } + $expectedCount = 1 Assert-True ($runInvocations.Count -eq $expectedCount) ( "$Scenario invoked $($runInvocations.Count) suites; expected $expectedCount." ) - if ($ShouldContinue) { - Assert-True (($runInvocations[-1].Arguments -join ' ') -like '*z-next*') ( - 'All-suite execution did not continue to the suite after the validated exit-1 result.' - ) - } } Invoke-AllSuiteExitOneScenario -Scenario 'complete-passing' -ShouldContinue $true @@ -362,6 +355,29 @@ stimuli: -RunArguments @('--runs', '2') Assert-CustomComponentPlan -Scenario 'EqualsRunsOverride' -ExpectedRuns 3 ` -RunArguments @('--runs=3') + Assert-CustomComponentPlan -Scenario 'ZeroThresholdBoundary' -ExpectedRuns 7 ` + -ExpectedThreshold 0 -RunArguments @('--threshold=0') + Assert-CustomComponentPlan -Scenario 'OneThresholdBoundary' -ExpectedRuns 7 ` + -ExpectedThreshold 1 -RunArguments @('--threshold', '1') + + foreach ($case in @( + @{ Name = 'EmptyThreshold'; Arguments = @('--threshold=') }, + @{ Name = 'WhitespaceThreshold'; Arguments = @('--threshold', ' ') }, + @{ Name = 'InvalidThreshold'; Arguments = @('--threshold=not-a-number') } + )) { + $message = '' + try { + & $runner Run -Root $customRoot -Suite review-candidate-verifier ` + -Vally $fakeVally -VallyPrefix @() ` + -OutputDirectory (Join-Path $testRoot "invalid-$($case.Name)") ` + @($case.Arguments) + } catch { + $message = $_.Exception.Message + } + Assert-True ($message -eq '--threshold must be between 0 and 1.') ( + "$($case.Name) was not rejected by the threshold parser. Error: $message" + ) + } Remove-Item $record & $runner Validate -Eval eng/skill-evals/review-candidate-verifier/eval.vally.yaml ` diff --git a/eng/skill-evals/test_stage_run.ps1 b/eng/skill-evals/test_stage_run.ps1 index a4a00bd4906d..dbdd85f9cefb 100644 --- a/eng/skill-evals/test_stage_run.ps1 +++ b/eng/skill-evals/test_stage_run.ps1 @@ -13,6 +13,7 @@ $destination = Join-Path $testRoot 'staged' $trustedMarker = 'TRUSTED_CONTROL_MARKER' $candidateControlMarker = 'CANDIDATE_CONTROL_CANARY_MUST_NOT_APPEAR' $candidateDataMarker = 'CANDIDATE_DATA_MARKER' +$repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '../..')).Path function Assert-True { param([bool]$Condition, [string]$Message) @@ -70,6 +71,20 @@ function Write-ControlPlane { Set-Content (Join-Path $evalRoot 'skills-smoke.experiment.yaml') $Marker } +foreach ($relativePath in @( + 'eng/skill-evals/run.ps1' + 'eng/skill-evals/assert_results.ps1' + 'eng/skill-evals/skills-vs-baseline.experiment.yaml' + 'eng/skill-evals/skills-smoke.experiment.yaml' + 'eng/skill-evals/grade_disposition.mjs' + 'eng/skill-evals/review-vs-baseline.experiment.yaml' + 'eng/skill-evals/review-smoke.experiment.yaml' +)) { + Assert-True (Test-Path (Join-Path $repoRoot $relativePath) -PathType Leaf) ( + "Real trusted control-plane file '$relativePath' is missing." + ) +} + New-Item -ItemType Directory -Path $trustedRoot, $candidateRoot | Out-Null try { Write-ControlPlane $trustedRoot $trustedMarker @@ -271,6 +286,21 @@ stimuli: -Destination (Join-Path $testRoot 'restricted-agent-environment') } "forbidden 'agent_environment.commands' field" + New-RestrictedCandidate 'restricted-values-shadow' @' +Values: [] +stimuli: + - agent_environment: + commands: + - candidate-command +'@ + Assert-Throws { + & $stageRun ` + -TrustedRoot $trustedRoot ` + -CandidateRoot $candidateRoot ` + -EvalName restricted-values-shadow ` + -Destination (Join-Path $testRoot 'restricted-values-shadow') + } "forbidden 'agent_environment.commands' field" + New-RestrictedCandidate 'restricted-flow-mapping' @' stimuli: - environment: { commands: ["chmod +x .eval-gh/gh"] } @@ -406,6 +436,16 @@ stimuli: -EvalName review-pull-request ` -Destination $reviewDestination + $realTrustedReviewDestination = Join-Path $testRoot 'staged-review-real-control-plane' + & $stageRun ` + -TrustedRoot $repoRoot ` + -CandidateRoot $candidateRoot ` + -EvalName review-pull-request ` + -Destination $realTrustedReviewDestination + Assert-True ( + Test-Path (Join-Path $realTrustedReviewDestination 'eng/skill-evals/review-pull-request/eval.vally.yaml') + ) 'Candidate L1 spec did not stage with the real trusted control plane.' + $stagedReviewFiles = @( Get-ChildItem $reviewDestination -Recurse -File -Force | ForEach-Object { @@ -619,6 +659,20 @@ stimuli: " program: node`n timeout: 1" ) }, + @{ + Name = 'ComponentCountShadowsProgramConfig' + Spec = $canonicalComponentSpec.Replace( + ' program: node', + " program: node`n Count: 3`n timeout: 1" + ) + }, + @{ + Name = 'ComponentCountShadowsProgramEnvironment' + Spec = $canonicalComponentSpec.Replace( + ' DISPOSITION_MODE: component', + " DISPOSITION_MODE: component`n Count: 1`n CANDIDATE_OVERRIDE: enabled" + ) + }, @{ Name = 'ComponentInvalidAdditionalProgramGrader' Spec = $canonicalComponentSpec + @' From fe3f4ca4c779eb843f74f9453798508ebe94fdcd Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Fri, 13 Nov 2026 12:04:18 -0600 Subject: [PATCH 10/23] Restructure verifier fixtures into shared and per-case folders Move files used by more than one case to fixtures/shared and case-only files to fixtures/case-a, case-b, and case-c. Only src paths change; every staged dest path and byte stays identical. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/README.md | 35 +++++----- .../review-candidate-verifier/eval.vally.yaml | 46 ++++++------- .../{package-a => case-a}/bundle-index.json | 0 .../{package-b => case-b}/bundle-index.json | 0 .../{ => case-b}/contracts/api-behavior.txt | 0 .../{package-c => case-c}/bundle-index.json | 0 .../{package-c => case-c}/candidate.json | 0 .../{package-c => case-c}/changed-files.json | 0 .../{package-c => case-c}/changes.diff | 0 .../fixtures/{ => case-c}/observations.json | 0 .../source/head/src/Engine/Conversation.mjs | 0 .../mergeBase/src/Engine/Conversation.mjs | 0 .../fixtures/{ => shared}/candidate.json | 0 .../fixtures/{ => shared}/changed-files.json | 0 .../fixtures/{ => shared}/changes.diff | 0 .../baseTip/docs/CrossCuttingGuidance.md | 0 .../Components/AI/src/Blocks/ContentBlock.cs | 0 .../AI/src/Blocks/IInteractiveBlock.cs | 0 .../AI/src/Components/MessageInput.cs | 0 .../Components/AI/src/Engine/AgentContext.cs | 0 .../AI/src/Engine/ConversationStatus.cs | 0 .../AI/src/Engine/ConversationTurn.cs | 0 .../src/Components/AI/src/Engine/UIAgent.cs | 0 .../Components/AI/src/Engine/UIAgentLog.cs | 0 .../AI/src/Pipeline/BlockMappingPipeline.cs | 0 .../Components/AI/src/Blocks/ContentBlock.cs | 0 .../AI/src/Blocks/IInteractiveBlock.cs | 0 .../AI/src/Components/MessageInput.cs | 0 .../Components/AI/src/Engine/AgentContext.cs | 0 .../AI/src/Engine/ConversationStatus.cs | 0 .../AI/src/Engine/ConversationTurn.cs | 0 .../src/Components/AI/src/Engine/UIAgent.cs | 0 .../Components/AI/src/Engine/UIAgentLog.cs | 0 .../AI/src/Pipeline/BlockMappingPipeline.cs | 0 .../review-candidate-verifier/provenance.json | 64 +++++++++---------- .../tests/test_review_fixtures.ps1 | 2 +- 36 files changed, 74 insertions(+), 73 deletions(-) rename eng/skill-evals/review-candidate-verifier/fixtures/{package-a => case-a}/bundle-index.json (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{package-b => case-b}/bundle-index.json (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => case-b}/contracts/api-behavior.txt (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{package-c => case-c}/bundle-index.json (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{package-c => case-c}/candidate.json (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{package-c => case-c}/changed-files.json (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{package-c => case-c}/changes.diff (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => case-c}/observations.json (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => case-c}/source/head/src/Engine/Conversation.mjs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => case-c}/source/mergeBase/src/Engine/Conversation.mjs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/candidate.json (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/changed-files.json (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/changes.diff (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/baseTip/docs/CrossCuttingGuidance.md (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/head/src/Components/AI/src/Blocks/ContentBlock.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/head/src/Components/AI/src/Components/MessageInput.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/head/src/Components/AI/src/Engine/AgentContext.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/head/src/Components/AI/src/Engine/ConversationStatus.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/head/src/Components/AI/src/Engine/ConversationTurn.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/head/src/Components/AI/src/Engine/UIAgent.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/head/src/Components/AI/src/Engine/UIAgentLog.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs (100%) rename eng/skill-evals/review-candidate-verifier/fixtures/{ => shared}/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs (100%) diff --git a/eng/skill-evals/README.md b/eng/skill-evals/README.md index 999570f5fba9..2fa4fb2346f1 100644 --- a/eng/skill-evals/README.md +++ b/eng/skill-evals/README.md @@ -84,7 +84,8 @@ Paths in this table are relative to `review-candidate-verifier\fixtures`. Cases a and b share the C# slice. Case b adds one synthetic contract. Case c uses separate JavaScript evidence. The eval stages each case's index, candidate, diff, and changed-file list under -the same destination names. A file at the fixture root is not necessarily shared. +the same destination names. `shared` holds files that more than one case uses. +Each `case-` folder holds files that only that case uses. | Case | Purpose | Expected answer | |---|---|---| @@ -95,24 +96,24 @@ the same destination names. A file at the fixture root is not necessarily shared | Fixture file or path | Cases | Purpose | |---|---|---| | `.gitattributes` | a, b, c (checkout only) | Preserve frozen bytes and line endings. | -| `candidate.json` | a, b | Shared catch-policy candidate. | -| `changes.diff` | a, b | Shared `AgentContext.cs` change. | -| `changed-files.json` | a, b | Metadata for that one-file diff. | -| `package-a\bundle-index.json` | a | Source roots, revision IDs, and assigned evidence paths. | -| `package-b\bundle-index.json` | b | Same index scope, plus the synthetic propagation contract. | -| `contracts\api-behavior.txt` | b only | Synthetic rule requiring secondary failures to propagate. | -| `package-c\bundle-index.json` | c | Synthetic source hashes, evidence paths, and observation hash. | -| `package-c\candidate.json` | c | Callback-failure candidate. | -| `package-c\changes.diff` | c | Synthetic JavaScript change. | -| `package-c\changed-files.json` | c | Metadata for that JavaScript diff. | -| `observations.json` | c only | Immutable callback-failure observation. | -| `source\baseTip\docs\CrossCuttingGuidance.md` | a, b, c | Frozen base-tip catch guidance. | -| `source\head\src\Engine\Conversation.mjs` | c | Synthetic head implementation. | -| `source\mergeBase\src\Engine\Conversation.mjs` | c | Synthetic earlier implementation. | +| `shared\candidate.json` | a, b | Shared catch-policy candidate. | +| `shared\changes.diff` | a, b | Shared `AgentContext.cs` change. | +| `shared\changed-files.json` | a, b | Metadata for that one-file diff. | +| `shared\source\baseTip\docs\CrossCuttingGuidance.md` | a, b, c | Frozen base-tip catch guidance. | +| `case-a\bundle-index.json` | a | Source roots, revision IDs, and assigned evidence paths. | +| `case-b\bundle-index.json` | b | Same index scope, plus the synthetic propagation contract. | +| `case-b\contracts\api-behavior.txt` | b | Synthetic rule requiring secondary failures to propagate. | +| `case-c\bundle-index.json` | c | Synthetic source hashes, evidence paths, and observation hash. | +| `case-c\candidate.json` | c | Callback-failure candidate. | +| `case-c\changes.diff` | c | Synthetic JavaScript change. | +| `case-c\changed-files.json` | c | Metadata for that JavaScript diff. | +| `case-c\observations.json` | c | Immutable callback-failure observation. | +| `case-c\source\head\src\Engine\Conversation.mjs` | c | Synthetic head implementation. | +| `case-c\source\mergeBase\src\Engine\Conversation.mjs` | c | Synthetic earlier implementation. | The following nine files appear under -`source\head\src\Components\AI\src` and -`source\mergeBase\src\Components\AI\src`. +`shared\source\head\src\Components\AI\src` and +`shared\source\mergeBase\src\Components\AI\src`. Both cases a and b receive all nine files at both revisions. | C# file relative to either source directory | Cases | Purpose | diff --git a/eng/skill-evals/review-candidate-verifier/eval.vally.yaml b/eng/skill-evals/review-candidate-verifier/eval.vally.yaml index 321dd1552b50..233f5b45fbf1 100644 --- a/eng/skill-evals/review-candidate-verifier/eval.vally.yaml +++ b/eng/skill-evals/review-candidate-verifier/eval.vally.yaml @@ -29,19 +29,19 @@ stimuli: Do not fetch, execute target code, modify files, publish, or delegate. agent_environment: files: - - src: fixtures/source/head/src/Components/AI/src + - src: fixtures/shared/source/head/src/Components/AI/src dest: source/head/src/Components/AI/src - - src: fixtures/source/mergeBase/src/Components/AI/src + - src: fixtures/shared/source/mergeBase/src/Components/AI/src dest: source/mergeBase/src/Components/AI/src - - src: fixtures/source/baseTip/docs/CrossCuttingGuidance.md + - src: fixtures/shared/source/baseTip/docs/CrossCuttingGuidance.md dest: source/baseTip/docs/CrossCuttingGuidance.md - - src: fixtures/changes.diff + - src: fixtures/shared/changes.diff dest: changes.diff - - src: fixtures/changed-files.json + - src: fixtures/shared/changed-files.json dest: changed-files.json - - src: fixtures/candidate.json + - src: fixtures/shared/candidate.json dest: candidate.json - - src: fixtures/package-a/bundle-index.json + - src: fixtures/case-a/bundle-index.json dest: bundle-index.json graders: - type: program @@ -87,21 +87,21 @@ stimuli: Do not fetch, execute target code, modify files, publish, or delegate. agent_environment: files: - - src: fixtures/source/head/src/Components/AI/src + - src: fixtures/shared/source/head/src/Components/AI/src dest: source/head/src/Components/AI/src - - src: fixtures/source/mergeBase/src/Components/AI/src + - src: fixtures/shared/source/mergeBase/src/Components/AI/src dest: source/mergeBase/src/Components/AI/src - - src: fixtures/source/baseTip/docs/CrossCuttingGuidance.md + - src: fixtures/shared/source/baseTip/docs/CrossCuttingGuidance.md dest: source/baseTip/docs/CrossCuttingGuidance.md - - src: fixtures/changes.diff + - src: fixtures/shared/changes.diff dest: changes.diff - - src: fixtures/changed-files.json + - src: fixtures/shared/changed-files.json dest: changed-files.json - - src: fixtures/candidate.json + - src: fixtures/shared/candidate.json dest: candidate.json - - src: fixtures/contracts/api-behavior.txt + - src: fixtures/case-b/contracts/api-behavior.txt dest: contracts/api-behavior.txt - - src: fixtures/package-b/bundle-index.json + - src: fixtures/case-b/bundle-index.json dest: bundle-index.json graders: - type: program @@ -150,21 +150,21 @@ stimuli: Do not fetch, execute target code, modify files, publish, or delegate. agent_environment: files: - - src: fixtures/source/head/src/Engine/Conversation.mjs + - src: fixtures/case-c/source/head/src/Engine/Conversation.mjs dest: source/head/src/Engine/Conversation.mjs - - src: fixtures/source/mergeBase/src/Engine/Conversation.mjs + - src: fixtures/case-c/source/mergeBase/src/Engine/Conversation.mjs dest: source/mergeBase/src/Engine/Conversation.mjs - - src: fixtures/source/baseTip/docs/CrossCuttingGuidance.md + - src: fixtures/shared/source/baseTip/docs/CrossCuttingGuidance.md dest: source/baseTip/docs/CrossCuttingGuidance.md - - src: fixtures/package-c/candidate.json + - src: fixtures/case-c/candidate.json dest: candidate.json - - src: fixtures/package-c/changes.diff + - src: fixtures/case-c/changes.diff dest: changes.diff - - src: fixtures/package-c/changed-files.json + - src: fixtures/case-c/changed-files.json dest: changed-files.json - - src: fixtures/observations.json + - src: fixtures/case-c/observations.json dest: observations.json - - src: fixtures/package-c/bundle-index.json + - src: fixtures/case-c/bundle-index.json dest: bundle-index.json graders: - type: program diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/package-a/bundle-index.json b/eng/skill-evals/review-candidate-verifier/fixtures/case-a/bundle-index.json similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/package-a/bundle-index.json rename to eng/skill-evals/review-candidate-verifier/fixtures/case-a/bundle-index.json diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/package-b/bundle-index.json b/eng/skill-evals/review-candidate-verifier/fixtures/case-b/bundle-index.json similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/package-b/bundle-index.json rename to eng/skill-evals/review-candidate-verifier/fixtures/case-b/bundle-index.json diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/contracts/api-behavior.txt b/eng/skill-evals/review-candidate-verifier/fixtures/case-b/contracts/api-behavior.txt similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/contracts/api-behavior.txt rename to eng/skill-evals/review-candidate-verifier/fixtures/case-b/contracts/api-behavior.txt diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/package-c/bundle-index.json b/eng/skill-evals/review-candidate-verifier/fixtures/case-c/bundle-index.json similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/package-c/bundle-index.json rename to eng/skill-evals/review-candidate-verifier/fixtures/case-c/bundle-index.json diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/package-c/candidate.json b/eng/skill-evals/review-candidate-verifier/fixtures/case-c/candidate.json similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/package-c/candidate.json rename to eng/skill-evals/review-candidate-verifier/fixtures/case-c/candidate.json diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/package-c/changed-files.json b/eng/skill-evals/review-candidate-verifier/fixtures/case-c/changed-files.json similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/package-c/changed-files.json rename to eng/skill-evals/review-candidate-verifier/fixtures/case-c/changed-files.json diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/package-c/changes.diff b/eng/skill-evals/review-candidate-verifier/fixtures/case-c/changes.diff similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/package-c/changes.diff rename to eng/skill-evals/review-candidate-verifier/fixtures/case-c/changes.diff diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/observations.json b/eng/skill-evals/review-candidate-verifier/fixtures/case-c/observations.json similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/observations.json rename to eng/skill-evals/review-candidate-verifier/fixtures/case-c/observations.json diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Engine/Conversation.mjs b/eng/skill-evals/review-candidate-verifier/fixtures/case-c/source/head/src/Engine/Conversation.mjs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Engine/Conversation.mjs rename to eng/skill-evals/review-candidate-verifier/fixtures/case-c/source/head/src/Engine/Conversation.mjs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Engine/Conversation.mjs b/eng/skill-evals/review-candidate-verifier/fixtures/case-c/source/mergeBase/src/Engine/Conversation.mjs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Engine/Conversation.mjs rename to eng/skill-evals/review-candidate-verifier/fixtures/case-c/source/mergeBase/src/Engine/Conversation.mjs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/candidate.json b/eng/skill-evals/review-candidate-verifier/fixtures/shared/candidate.json similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/candidate.json rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/candidate.json diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/changed-files.json b/eng/skill-evals/review-candidate-verifier/fixtures/shared/changed-files.json similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/changed-files.json rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/changed-files.json diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/changes.diff b/eng/skill-evals/review-candidate-verifier/fixtures/shared/changes.diff similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/changes.diff rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/changes.diff diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/baseTip/docs/CrossCuttingGuidance.md b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/baseTip/docs/CrossCuttingGuidance.md similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/baseTip/docs/CrossCuttingGuidance.md rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/baseTip/docs/CrossCuttingGuidance.md diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Blocks/ContentBlock.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/ContentBlock.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Blocks/ContentBlock.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageInput.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Components/MessageInput.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Components/MessageInput.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Components/MessageInput.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Engine/AgentContext.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/AgentContext.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Engine/AgentContext.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/ConversationStatus.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Engine/ConversationStatus.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/ConversationStatus.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Engine/ConversationStatus.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/ConversationTurn.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Engine/ConversationTurn.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/ConversationTurn.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Engine/ConversationTurn.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgent.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Engine/UIAgent.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgent.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Engine/UIAgent.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentLog.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Engine/UIAgentLog.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Engine/UIAgentLog.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Engine/UIAgentLog.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs similarity index 100% rename from eng/skill-evals/review-candidate-verifier/fixtures/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs rename to eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs diff --git a/eng/skill-evals/review-candidate-verifier/provenance.json b/eng/skill-evals/review-candidate-verifier/provenance.json index 9b2ea4b0af1f..e8946f3e09ae 100644 --- a/eng/skill-evals/review-candidate-verifier/provenance.json +++ b/eng/skill-evals/review-candidate-verifier/provenance.json @@ -13,131 +13,131 @@ }, "files": [ { - "file": "candidate.json", + "file": "shared/candidate.json", "sha256": "2925e9529ca2884a99e1f6ef6a4bc166d7d422852ba00546f62fda9c828859a0" }, { - "file": "changed-files.json", + "file": "shared/changed-files.json", "sha256": "06eaa182b93948037b2a9b105f2f10fa8e37f3f74b2b8ed4dfdd8837cc1f1a24" }, { - "file": "changes.diff", + "file": "shared/changes.diff", "sha256": "4f1712f87a413c06dc2c763136911a84c14c2f2dc9109dc0680467afb111ebd0" }, { - "file": "contracts/api-behavior.txt", + "file": "case-b/contracts/api-behavior.txt", "sha256": "bff28d4062f66d3545b9b76530789592cf4be7de22c0b9ee42ad1d9a5f412fff" }, { - "file": "observations.json", + "file": "case-c/observations.json", "sha256": "a4355b34aaf0927946a5c5791fafcdeaca05d4d85f247976d289c1626c0cc5f8" }, { - "file": "package-a/bundle-index.json", + "file": "case-a/bundle-index.json", "sha256": "11d98c866d0664a0d8290481dc19a2931fb09f589a06b4ca84c2d3241735fdc3" }, { - "file": "package-b/bundle-index.json", + "file": "case-b/bundle-index.json", "sha256": "09e6f4e6679e5a4b566cc096832144d13d2bad099fbf82fe391be2567e26df55" }, { - "file": "package-c/bundle-index.json", + "file": "case-c/bundle-index.json", "sha256": "91d337316cf75897daf7a5873771fe77048bd42c1450d60acdf1bc12028a0631" }, { - "file": "package-c/candidate.json", + "file": "case-c/candidate.json", "sha256": "6ec7c0e8d35ad42dfe2c58e43aa33f1b194e33aa2a1c790b43a0c69dcd916d90" }, { - "file": "package-c/changed-files.json", + "file": "case-c/changed-files.json", "sha256": "93dd39cc3699523242cc571bd40bd96727e15a071dfb64e5fd8f92b1cf25deea" }, { - "file": "package-c/changes.diff", + "file": "case-c/changes.diff", "sha256": "0afde6935c8bfc044be5931f02bd264ea3b3a42353cb980422bc0bd24c612276" }, { - "file": "source/baseTip/docs/CrossCuttingGuidance.md", + "file": "shared/source/baseTip/docs/CrossCuttingGuidance.md", "sha256": "4aac99289d9812ac59c50e5eb702c0226c0afee26ba14d68366a82a55ab0feef" }, { - "file": "source/head/src/Components/AI/src/Blocks/ContentBlock.cs", + "file": "shared/source/head/src/Components/AI/src/Blocks/ContentBlock.cs", "sha256": "7cab62ac70d7faa70dacbdb4bd36723b4061612ab921b9f7d7d019d3ba905261" }, { - "file": "source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs", + "file": "shared/source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs", "sha256": "0f6c4f9e859a917755b75bcf335273c37461525fc72d7e5564ba2594c99ba90f" }, { - "file": "source/head/src/Components/AI/src/Components/MessageInput.cs", + "file": "shared/source/head/src/Components/AI/src/Components/MessageInput.cs", "sha256": "d0ddd1d72a79945463c3ddf92b2861b4e2b05d47fb4bebcbc7feef5685397091" }, { - "file": "source/head/src/Components/AI/src/Engine/AgentContext.cs", + "file": "shared/source/head/src/Components/AI/src/Engine/AgentContext.cs", "sha256": "cbabd18763571b3ad936002d1d54ea35d6f2c537f7df131655bca0334f2c3ccd" }, { - "file": "source/head/src/Components/AI/src/Engine/ConversationStatus.cs", + "file": "shared/source/head/src/Components/AI/src/Engine/ConversationStatus.cs", "sha256": "b44fd1f2cbb45c401f14a695f3ef8c7dac6f1d2a66f6e9622f15a2c2099546f9" }, { - "file": "source/head/src/Components/AI/src/Engine/ConversationTurn.cs", + "file": "shared/source/head/src/Components/AI/src/Engine/ConversationTurn.cs", "sha256": "3a5dbc73c955c5dec1fa04e195c35387477287a0b5e78013b2c91d65477295ea" }, { - "file": "source/head/src/Components/AI/src/Engine/UIAgent.cs", + "file": "shared/source/head/src/Components/AI/src/Engine/UIAgent.cs", "sha256": "15f260ac18c35efde79d4822641961f0ea002bfe398d366b123ad5887b1ea919" }, { - "file": "source/head/src/Components/AI/src/Engine/UIAgentLog.cs", + "file": "shared/source/head/src/Components/AI/src/Engine/UIAgentLog.cs", "sha256": "8f20da705a199ebf56ece8f9e073107a9a7ec8404884c69e4c748fd5f1224061" }, { - "file": "source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs", + "file": "shared/source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs", "sha256": "3efb30f16570e2754c38b579e3fdb4dc4d5b9d750b3a9408c7fa1238c11258ee" }, { - "file": "source/head/src/Engine/Conversation.mjs", + "file": "case-c/source/head/src/Engine/Conversation.mjs", "sha256": "13e383993dd60d8548089196ada34afcf791c7995ffda48104bbe23bf15cff11" }, { - "file": "source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs", + "file": "shared/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs", "sha256": "7cab62ac70d7faa70dacbdb4bd36723b4061612ab921b9f7d7d019d3ba905261" }, { - "file": "source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs", + "file": "shared/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs", "sha256": "0f6c4f9e859a917755b75bcf335273c37461525fc72d7e5564ba2594c99ba90f" }, { - "file": "source/mergeBase/src/Components/AI/src/Components/MessageInput.cs", + "file": "shared/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs", "sha256": "d0ddd1d72a79945463c3ddf92b2861b4e2b05d47fb4bebcbc7feef5685397091" }, { - "file": "source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs", + "file": "shared/source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs", "sha256": "61ca1e7434f6046328435ec8df5bd069c3198af8bb6b2db9912ff4c66cf7b084" }, { - "file": "source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs", + "file": "shared/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs", "sha256": "b44fd1f2cbb45c401f14a695f3ef8c7dac6f1d2a66f6e9622f15a2c2099546f9" }, { - "file": "source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs", + "file": "shared/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs", "sha256": "3a5dbc73c955c5dec1fa04e195c35387477287a0b5e78013b2c91d65477295ea" }, { - "file": "source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs", + "file": "shared/source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs", "sha256": "63783e5da3d7b6fbf0c339d2e3a2298498b2b455a587e79f5f25431bf9812943" }, { - "file": "source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs", + "file": "shared/source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs", "sha256": "f7eb199a984d4b163a972c13e709de02e203789b8e0e834793b94487344e2df7" }, { - "file": "source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs", + "file": "shared/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs", "sha256": "3efb30f16570e2754c38b579e3fdb4dc4d5b9d750b3a9408c7fa1238c11258ee" }, { - "file": "source/mergeBase/src/Engine/Conversation.mjs", + "file": "case-c/source/mergeBase/src/Engine/Conversation.mjs", "sha256": "2c59edf3be93947a250c4c0a2787d103775265058fe3dbc533014932e2012deb" } ] diff --git a/eng/skill-evals/tests/test_review_fixtures.ps1 b/eng/skill-evals/tests/test_review_fixtures.ps1 index ad184c165ad2..9d92207ff236 100644 --- a/eng/skill-evals/tests/test_review_fixtures.ps1 +++ b/eng/skill-evals/tests/test_review_fixtures.ps1 @@ -22,7 +22,7 @@ function Test-FileHash { return (Get-FileHash $Path -Algorithm SHA256).Hash -eq $Hash } -foreach ($package in 'package-a', 'package-b', 'package-c') { +foreach ($package in 'case-a', 'case-b', 'case-c') { $bundleIndex = Get-Content (Join-Path $componentRoot "fixtures/$package/bundle-index.json") -Raw Assert-True (-not $bundleIndex.Contains('\')) "The $package bundle index contains non-portable backslash separators." } From 5cc174324e5310b2369fa0557ea4692b09674fb7 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Fri, 13 Nov 2026 12:12:11 -0600 Subject: [PATCH 11/23] Move review fixture self-test beside the other skill-eval tests Delete the tests/test_stage_run.ps1 forwarding shim and move test_review_fixtures.ps1 to eng/skill-evals, where the other self-tests live. Update run.ps1 Test and the README. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/README.md | 2 -- eng/skill-evals/run.ps1 | 2 +- eng/skill-evals/{tests => }/test_review_fixtures.ps1 | 2 +- eng/skill-evals/tests/test_stage_run.ps1 | 4 ---- 4 files changed, 2 insertions(+), 8 deletions(-) rename eng/skill-evals/{tests => }/test_review_fixtures.ps1 (97%) delete mode 100644 eng/skill-evals/tests/test_stage_run.ps1 diff --git a/eng/skill-evals/README.md b/eng/skill-evals/README.md index 2fa4fb2346f1..367236a4d1fd 100644 --- a/eng/skill-evals/README.md +++ b/eng/skill-evals/README.md @@ -143,8 +143,6 @@ Run these commands from any directory: ./eng/skill-evals/run.ps1 Validate -Suite review-candidate-verifier # Run infrastructure self-tests plus the selected suite's fixture checks. ./eng/skill-evals/run.ps1 Test -Suite review-candidate-verifier -# The original staging self-test also has this forwarding entry point. -./eng/skill-evals/tests/test_stage_run.ps1 # Strict Vally parsing/schema lint; does not call a model ./eng/skill-evals/run.ps1 Lint diff --git a/eng/skill-evals/run.ps1 b/eng/skill-evals/run.ps1 index 5a5200210f17..71bfb650e1a5 100644 --- a/eng/skill-evals/run.ps1 +++ b/eng/skill-evals/run.ps1 @@ -330,7 +330,7 @@ switch ($Action) { & (Join-Path $PSScriptRoot 'test_stage_run.ps1') & (Join-Path $PSScriptRoot 'test_workflow.ps1') if (-not $Suite -or $Suite -in @('review-pull-request', 'review-candidate-verifier')) { - & (Join-Path $PSScriptRoot 'tests/test_review_fixtures.ps1') + & (Join-Path $PSScriptRoot 'test_review_fixtures.ps1') } if (Test-Path (Join-Path $PSScriptRoot 'test_disposition.mjs')) { & node --test (Join-Path $PSScriptRoot 'test_disposition.mjs') diff --git a/eng/skill-evals/tests/test_review_fixtures.ps1 b/eng/skill-evals/test_review_fixtures.ps1 similarity index 97% rename from eng/skill-evals/tests/test_review_fixtures.ps1 rename to eng/skill-evals/test_review_fixtures.ps1 index 9d92207ff236..f2d347a51314 100644 --- a/eng/skill-evals/tests/test_review_fixtures.ps1 +++ b/eng/skill-evals/test_review_fixtures.ps1 @@ -3,7 +3,7 @@ $ErrorActionPreference = 'Stop' Set-StrictMode -Version 3 -$componentRoot = (Resolve-Path (Join-Path $PSScriptRoot '../review-candidate-verifier')).Path +$componentRoot = (Resolve-Path (Join-Path $PSScriptRoot 'review-candidate-verifier')).Path $repoRoot = (Resolve-Path (Join-Path $componentRoot '../../..')).Path $script:checks = 0 diff --git a/eng/skill-evals/tests/test_stage_run.ps1 b/eng/skill-evals/tests/test_stage_run.ps1 deleted file mode 100644 index e567f52f1965..000000000000 --- a/eng/skill-evals/tests/test_stage_run.ps1 +++ /dev/null @@ -1,4 +0,0 @@ -#requires -Version 7.0 - -$ErrorActionPreference = 'Stop' -& (Join-Path $PSScriptRoot '../test_stage_run.ps1') @args From 500ce87e1f8df3d6ad0eed3e34c79df1410737e5 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Fri, 13 Nov 2026 12:59:15 -0600 Subject: [PATCH 12/23] Harden skill-eval result validation Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/assert_results.ps1 | 23 +++++++++++- eng/skill-evals/grade_disposition.mjs | 4 +- eng/skill-evals/run.ps1 | 13 +++++-- eng/skill-evals/stage_run.ps1 | 3 ++ eng/skill-evals/test_assert_results.ps1 | 49 +++++++++++++++++++++++++ eng/skill-evals/test_disposition.mjs | 10 +++++ eng/skill-evals/test_run.ps1 | 42 +++++++++++++++++++++ eng/skill-evals/test_stage_run.ps1 | 11 ++++++ 8 files changed, 148 insertions(+), 7 deletions(-) diff --git a/eng/skill-evals/assert_results.ps1 b/eng/skill-evals/assert_results.ps1 index b3d8295fc58c..ccbc65005a34 100644 --- a/eng/skill-evals/assert_results.ps1 +++ b/eng/skill-evals/assert_results.ps1 @@ -41,6 +41,13 @@ foreach ($variant in $variants) { } $plan = $plans[0] + if (-not $plan.PSObject.Properties['threshold'] -or + ($plan.threshold -isnot [int] -and $plan.threshold -isnot [long] -and + $plan.threshold -isnot [double] -and $plan.threshold -isnot [decimal]) -or + -not [double]::IsFinite([double]$plan.threshold) -or + $plan.threshold -lt 0 -or $plan.threshold -gt 1) { + throw "The '$variant' plan has an invalid threshold." + } $names = @($plan.plannedStimulusNames) if ($names.Count -lt 1 -or $names.Count -ne [int]$plan.plannedStimulusCount -or @($names | Sort-Object -Unique).Count -ne $names.Count -or @@ -56,7 +63,13 @@ foreach ($variant in $variants) { $results = @( Get-Content $resultsPath | Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | - ForEach-Object { $_ | ConvertFrom-Json -Depth 100 } + ForEach-Object { + $record = ConvertFrom-Json -InputObject $_ -Depth 100 -NoEnumerate + if ($null -eq $record -or $record.GetType() -ne [System.Management.Automation.PSCustomObject]) { + throw "Each JSONL line must be an object in '$resultsPath'." + } + $record + } ) $completion = $null if ($variant -eq 'current') { @@ -147,7 +160,13 @@ foreach ($variant in $variants) { } $dispositions = @($gradeResultProperty.Value.details | Where-Object { $_.PSObject.Properties['configuredName'] -and $_.configuredName -eq "disposition-$($result.stimulus)" }) - if ($dispositions.Count -ne 1 -or $dispositions[0].score -ne $score -or + if ($dispositions.Count -ne 1 -or + ($dispositions[0].score -isnot [int] -and $dispositions[0].score -isnot [long] -and + $dispositions[0].score -isnot [double] -and $dispositions[0].score -isnot [decimal]) -or + $dispositions[0].score -ne $score -or + $dispositions[0].score -notin @(0, 1) -or + $dispositions[0].passed -isnot [bool] -or + $dispositions[0].passed -ne ($dispositions[0].score -eq 1) -or ($dispositions[0].PSObject.Properties['status'] -and $dispositions[0].status -eq 'error')) { throw "The '$variant' trial lacks a valid primary disposition result." } diff --git a/eng/skill-evals/grade_disposition.mjs b/eng/skill-evals/grade_disposition.mjs index 9cb4844a71d0..69bc201dd107 100644 --- a/eng/skill-evals/grade_disposition.mjs +++ b/eng/skill-evals/grade_disposition.mjs @@ -23,9 +23,9 @@ function normalizedResult(output) { const text = output.trim().replace(/^```(?:json)?\s*\n([\s\S]*?)\n```\s*$/i, '$1'); const parsed = JSON.parse(text); - if (parsed && Array.isArray(parsed.results)) + if (parsed && typeof parsed === 'object' && 'results' in parsed) { - return parsed.results.length === 1 ? parsed.results[0] : null; + return Array.isArray(parsed.results) && parsed.results.length === 1 ? parsed.results[0] : null; } return parsed; } diff --git a/eng/skill-evals/run.ps1 b/eng/skill-evals/run.ps1 index 71bfb650e1a5..f7c2abe16aa7 100644 --- a/eng/skill-evals/run.ps1 +++ b/eng/skill-evals/run.ps1 @@ -317,7 +317,7 @@ switch ($Action) { } else { Invoke-VallyExperimentDryRun $standardExperiment Invoke-VallyExperimentDryRun $smokeExperiment - if (Test-Path $reviewEval) { + if (-not $Suite -and (Test-Path $reviewEval)) { Invoke-VallyExperimentDryRun $reviewExperiment Invoke-VallyExperimentDryRun $reviewSmokeExperiment } @@ -402,8 +402,15 @@ switch ($Action) { } else { 1 } - $threshold = if ($componentScoring -is [Collections.IDictionary] -and $null -ne $componentScoring['threshold']) { - [double]$componentScoring['threshold'] + $threshold = if ($componentScoring -is [Collections.IDictionary] -and $componentScoring.Contains('threshold')) { + $specifiedThreshold = $componentScoring['threshold'] + if (($specifiedThreshold -isnot [int] -and $specifiedThreshold -isnot [long] -and + $specifiedThreshold -isnot [double] -and $specifiedThreshold -isnot [decimal]) -or + -not [double]::IsFinite([double]$specifiedThreshold) -or + $specifiedThreshold -lt 0 -or $specifiedThreshold -gt 1) { + throw 'The component threshold must be between 0 and 1.' + } + [double]$specifiedThreshold } else { 1 } diff --git a/eng/skill-evals/stage_run.ps1 b/eng/skill-evals/stage_run.ps1 index cec1d241cc80..5fc2a52e76d5 100644 --- a/eng/skill-evals/stage_run.ps1 +++ b/eng/skill-evals/stage_run.ps1 @@ -194,6 +194,9 @@ function Assert-EvalSpecIsRestricted { throw "$Description $violation" } if ($dispositionMode) { + if ($parsed -isnot [Collections.IDictionary] -or $parsed['name'] -cne $EvalName) { + throw "$Description must have name '$EvalName'." + } if ($parsed -isnot [Collections.IDictionary] -or $parsed['grading_environment'] -isnot [Collections.IDictionary] -or -not $parsed['grading_environment'].Contains('files')) { diff --git a/eng/skill-evals/test_assert_results.ps1 b/eng/skill-evals/test_assert_results.ps1 index f20e7bba7c91..5d2ffdf9bd18 100644 --- a/eng/skill-evals/test_assert_results.ps1 +++ b/eng/skill-evals/test_assert_results.ps1 @@ -305,9 +305,11 @@ try { param($rows) $rows[3].gradeResult.score = 0 $rows[3].gradeResult.details[1].score = 0 + $rows[3].gradeResult.details[1].passed = $false foreach ($row in $rows | Where-Object stimulus -ne 'a') { $row.gradeResult.score = 1 $row.gradeResult.details[1].score = 1 + $row.gradeResult.details[1].passed = $true } } } @{ Name = 'DuplicateTrial'; Expected = 'duplicate trial identity'; Mutation = { @@ -338,6 +340,18 @@ try { param($rows) $rows[0].gradeResult.score = 0.9 } } + @{ Name = 'PrimaryPassedMustMatchScore'; Expected = 'valid primary disposition'; Mutation = { + param($rows) + $rows[0].gradeResult.details[1].passed = $false + } } + @{ Name = 'PrimaryPassedMustBeBoolean'; Expected = 'valid primary disposition'; Mutation = { + param($rows) + $rows[0].gradeResult.details[1].passed = 'true' + } } + @{ Name = 'PrimaryScoreMustBeNumeric'; Expected = 'valid primary disposition'; Mutation = { + param($rows) + $rows[0].gradeResult.details[1].score = '1' + } } @{ Name = 'MissingReadIntegrity'; Expected = 'lacks read-integrity'; Mutation = { param($rows) $rows[0].gradeResult.Remove('details') @@ -367,6 +381,29 @@ try { Write-ComponentResults $control.Mutation Assert-Throws { & $assertResults -OutputDirectory $output } $control.Expected $control.Name } + foreach ($threshold in @($null, '', 'NaN', -0.01, 1.01)) { + Write-ComponentResults + $plan = Get-Content (Join-Path $run 'plan-snapshot.json') -Raw | ConvertFrom-Json + $plan.evals[0].threshold = $threshold + $plan | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $run 'plan-snapshot.json') + Assert-Throws { & $assertResults -OutputDirectory $output } 'invalid threshold' ( + "Invalid threshold '$threshold' was accepted." + ) + } + foreach ($threshold in @(0, 1)) { + Write-ComponentResults { + param($rows) + foreach ($row in $rows) { + $row.gradeResult.score = 1 + $row.gradeResult.details[1].score = 1 + $row.gradeResult.details[1].passed = $true + } + } + $plan = Get-Content (Join-Path $run 'plan-snapshot.json') -Raw | ConvertFrom-Json + $plan.evals[0].threshold = $threshold + $plan | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $run 'plan-snapshot.json') + & $assertResults -OutputDirectory $output + } Write-ComponentResults -CompletionMutation { param($completion) $completion.hadExecutionErrors = $true @@ -383,6 +420,18 @@ try { ) Write-ComponentResults $componentLines = @(Get-Content (Join-Path $run 'results.jsonl')) + $componentArray = @($componentLines | ForEach-Object { $_ | ConvertFrom-Json }) + ConvertTo-Json -InputObject $componentArray -Depth 10 -Compress | + Set-Content (Join-Path $run 'results.jsonl') + Assert-Throws { & $assertResults -OutputDirectory $output } 'JSONL line must be an object' ( + 'A JSON array was accepted as a JSONL record.' + ) + foreach ($nonObject in @('null', 'true', '1', '"text"')) { + @($componentLines) + $nonObject | Set-Content (Join-Path $run 'results.jsonl') + Assert-Throws { & $assertResults -OutputDirectory $output } 'JSONL line must be an object' ( + "The JSONL scalar '$nonObject' was accepted." + ) + } $componentLines[0..13] + $componentLines[-1] | Set-Content (Join-Path $run 'results.jsonl') Assert-Throws { & $assertResults -OutputDirectory $output } "15 'current' trial results; found 14" ( diff --git a/eng/skill-evals/test_disposition.mjs b/eng/skill-evals/test_disposition.mjs index 41ec20039ea6..44bc561474ac 100644 --- a/eng/skill-evals/test_disposition.mjs +++ b/eng/skill-evals/test_disposition.mjs @@ -266,6 +266,16 @@ test('ComponentDispositionNormalizesOnlyApplicableFields', () => } }); +test('ComponentDispositionRejectsMalformedResultsWrapper', () => +{ + for (const results of [null, 'invalid', {}, 1, true]) + { + assert.equal(score('b', JSON.stringify({ decision: 'KEEP', results }), 'component'), 0); + } + assert.equal(score('b', '{"decision":"KEEP"}', 'component'), 1); + assert.equal(score('b', '{"results":[{"decision":"KEEP"}]}', 'component'), 1); +}); + test('ComponentDispositionRejectsNonStringInapplicableFields', async context => { for (const [name, value] of [ diff --git a/eng/skill-evals/test_run.ps1 b/eng/skill-evals/test_run.ps1 index aed946266d7d..85f8c670614e 100644 --- a/eng/skill-evals/test_run.ps1 +++ b/eng/skill-evals/test_run.ps1 @@ -194,6 +194,29 @@ stimuli: 'Custom validation could invoke models.' ) + $validationRoot = Join-Path $testRoot 'validation-root' + $validationEvalRoot = Join-Path $validationRoot 'eng/skill-evals' + New-Item -ItemType Directory -Force -Path ` + (Join-Path $validationEvalRoot 'review-public-api'), ` + (Join-Path $validationEvalRoot 'review-pull-request'), ` + (Join-Path $validationRoot '.github/skills/review-public-api') | Out-Null + Set-Content (Join-Path $validationEvalRoot 'review-public-api/eval.vally.yaml') 'name: review-public-api' + Set-Content (Join-Path $validationEvalRoot 'review-pull-request/eval.vally.yaml') 'name: review-pull-request' + Set-Content (Join-Path $validationRoot '.github/skills/review-public-api/SKILL.md') 'skill' + Set-Content (Join-Path $validationEvalRoot 'skills-vs-baseline.experiment.yaml') 'standard' + Set-Content (Join-Path $validationEvalRoot 'skills-smoke.experiment.yaml') 'smoke' + & git init -q $validationRoot + & git -C $validationRoot add eng/skill-evals/review-public-api/eval.vally.yaml + if ($LASTEXITCODE -ne 0) { + throw 'Could not set up the validation fixture.' + } + Remove-Item $record + & $runner Validate -Root $validationRoot -Suite review-public-api -Vally $fakeVally -VallyPrefix @() + $genericValidation = @(Read-Invocations | Where-Object { $_.Arguments[0] -eq 'experiment' }) + Assert-True ($genericValidation.Count -eq 2) ( + 'Generic suite validation planned the unrelated review experiments.' + ) + & $runner Run ` -Eval eng/skill-evals/review-public-api/eval.vally.yaml ` -Vally $fakeVally ` @@ -360,6 +383,25 @@ stimuli: Assert-CustomComponentPlan -Scenario 'OneThresholdBoundary' -ExpectedRuns 7 ` -ExpectedThreshold 1 -RunArguments @('--threshold', '1') + $componentSpecPath = Join-Path $customComponentDirectory 'eval.vally.yaml' + $validComponentSpec = Get-Content $componentSpecPath -Raw + foreach ($invalidThreshold in @('null', '""', '"NaN"', '-0.1', '1.1')) { + Set-Content $componentSpecPath ($validComponentSpec.Replace('threshold: 0.65', "threshold: $invalidThreshold")) + $message = '' + try { + & $runner Run -Root $customRoot -Suite review-candidate-verifier ` + -Vally $fakeVally -VallyPrefix @() ` + -OutputDirectory (Join-Path $testRoot 'invalid-yaml-threshold') + } catch { + $message = $_.Exception.Message + } finally { + Set-Content $componentSpecPath $validComponentSpec + } + Assert-True ($message -like '*threshold must be between 0 and 1*') ( + "Invalid YAML threshold '$invalidThreshold' was accepted. Error: $message" + ) + } + foreach ($case in @( @{ Name = 'EmptyThreshold'; Arguments = @('--threshold=') }, @{ Name = 'WhitespaceThreshold'; Arguments = @('--threshold', ' ') }, diff --git a/eng/skill-evals/test_stage_run.ps1 b/eng/skill-evals/test_stage_run.ps1 index dbdd85f9cefb..163741c451cd 100644 --- a/eng/skill-evals/test_stage_run.ps1 +++ b/eng/skill-evals/test_stage_run.ps1 @@ -394,6 +394,7 @@ stimuli: -Destination (Join-Path $testRoot 'allowed-prompt-text') $canonicalReviewSpec = @' +name: review-pull-request grading_environment: files: - src: ../grade_disposition.mjs @@ -436,6 +437,15 @@ stimuli: -EvalName review-pull-request ` -Destination $reviewDestination + New-RestrictedCandidate 'review-pull-request' $canonicalReviewSpec.Replace( + 'name: review-pull-request', 'name: renamed-review' + ) + Assert-Throws { + & $stageRun -TrustedRoot $trustedRoot -CandidateRoot $candidateRoot ` + -EvalName review-pull-request -Destination (Join-Path $testRoot 'renamed-review') + } "must have name 'review-pull-request'" + New-RestrictedCandidate 'review-pull-request' $canonicalReviewSpec + $realTrustedReviewDestination = Join-Path $testRoot 'staged-review-real-control-plane' & $stageRun ` -TrustedRoot $repoRoot ` @@ -496,6 +506,7 @@ stimuli: } $canonicalComponentSpec = @' +name: review-candidate-verifier grading_environment: files: - src: ../grade_disposition.mjs From b64951214785a5d826b6ddb1f76927a20f709fa6 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Sat, 14 Nov 2026 18:12:11 -0600 Subject: [PATCH 13/23] Assert every skill-eval run and validate run inputs Run now checks each new experiment or direct component run directory with assert_results.ps1, and the all-suite dispatch stops on any failed child. assert_results rejects non-boolean or errored receipt graders, stage_run rejects empty or unnamed stimuli in component suites, and Run validates the trial count. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/README.md | 6 +- eng/skill-evals/assert_results.ps1 | 23 +++-- eng/skill-evals/run.ps1 | 50 ++++++++--- eng/skill-evals/stage_run.ps1 | 11 ++- eng/skill-evals/test_assert_results.ps1 | 8 ++ eng/skill-evals/test_run.ps1 | 111 ++++++++++++++++++++---- eng/skill-evals/test_stage_run.ps1 | 22 +++++ 7 files changed, 191 insertions(+), 40 deletions(-) diff --git a/eng/skill-evals/README.md b/eng/skill-evals/README.md index 367236a4d1fd..0364815d64eb 100644 --- a/eng/skill-evals/README.md +++ b/eng/skill-evals/README.md @@ -157,8 +157,10 @@ Run these commands from any directory: Without a suite or explicit experiment, `Run` dispatches each standard suite into its own output subdirectory. This includes the direct verifier component suite. -`assert_results.ps1` checks that combined output recursively. An exit code of 1 does not stop dispatch when the complete primary -results pass those checks. A direct component run writes a plan beside Vally's +Each experiment or direct component `Run` checks its own new run directory with +`assert_results.ps1` before it returns. A Vally exit code of 1 is accepted only +after those checks pass; any failed check stops the run, including in the +all-suite dispatch. A direct component run writes a plan beside Vally's timestamped `results.jsonl`; it does not invent an experiment variant directory. That plan reflects the selected YAML and CLI runs/threshold overrides. For the verifier suite, smoke selects one repeat per case and checks trial diff --git a/eng/skill-evals/assert_results.ps1 b/eng/skill-evals/assert_results.ps1 index ccbc65005a34..01b6cee0e2b6 100644 --- a/eng/skill-evals/assert_results.ps1 +++ b/eng/skill-evals/assert_results.ps1 @@ -1,15 +1,22 @@ #requires -Version 7.0 param( - [Parameter(Mandatory = $true)] - [string]$OutputDirectory + [Parameter(Mandatory = $true, ParameterSetName = 'Output')] + [string]$OutputDirectory, + + [Parameter(Mandatory = $true, ParameterSetName = 'Run')] + [string]$RunDirectory ) $ErrorActionPreference = 'Stop' Set-StrictMode -Version 3 -$resolvedOutput = (Resolve-Path $OutputDirectory).Path -$runDirectories = @(Get-ChildItem $resolvedOutput -Directory) -if ($runDirectories.Count -gt 0 -and +if ($RunDirectory) { + $runDirectories = @(Get-Item -LiteralPath (Resolve-Path $RunDirectory).Path) +} else { + $resolvedOutput = (Resolve-Path $OutputDirectory).Path + $runDirectories = @(Get-ChildItem $resolvedOutput -Directory) +} +if (-not $RunDirectory -and $runDirectories.Count -gt 0 -and @($runDirectories | Where-Object { Test-Path (Join-Path $_.FullName 'plan-snapshot.json') }).Count -eq 0) { foreach ($directory in $runDirectories) { & $PSCommandPath -OutputDirectory $directory.FullName @@ -174,7 +181,11 @@ foreach ($variant in $variants) { $details = @($gradeResultProperty.Value.details | Where-Object { $_.PSObject.Properties['configuredName'] -and $_.configuredName -eq $receipt }) if ($details.Count -ne 1 -or $details[0].passed -isnot [bool] -or - -not $details[0].passed -or $details[0].score -is [string] -or $details[0].score -ne 1) { + -not $details[0].passed -or + ($details[0].score -isnot [int] -and $details[0].score -isnot [long] -and + $details[0].score -isnot [double] -and $details[0].score -isnot [decimal]) -or + $details[0].score -ne 1 -or + ($details[0].PSObject.Properties['status'] -and $details[0].status -eq 'error')) { throw "The '$variant' trial '$($result.stimulus):$trialIndex' failed read integrity: $receipt." } } diff --git a/eng/skill-evals/run.ps1 b/eng/skill-evals/run.ps1 index f7c2abe16aa7..078d0de9a91e 100644 --- a/eng/skill-evals/run.ps1 +++ b/eng/skill-evals/run.ps1 @@ -120,7 +120,10 @@ if ($Eval -and -not $Suite) { } function Invoke-Vally { - param([string[]]$VallyArguments) + param( + [string[]]$VallyArguments, + [switch]$TolerateExitOne + ) $command = Get-Command $Vally -ErrorAction SilentlyContinue if (-not $command) { @@ -147,6 +150,10 @@ function Invoke-Vally { & $Vally @VallyPrefix @VallyArguments $invocationSucceeded = $? $invocationExitCode = $LASTEXITCODE + $script:vallyExitCode = $invocationExitCode + if ($TolerateExitOne -and $invocationExitCode -eq 1) { + return + } if (-not $invocationSucceeded -or $invocationExitCode -ne 0) { if ($invocationExitCode -eq 0) { $invocationExitCode = 1 @@ -169,7 +176,10 @@ function Invoke-VallyLint { } function Invoke-VallyIsolated { - param([string[]]$VallyArguments) + param( + [string[]]$VallyArguments, + [switch]$TolerateExitOne + ) $workDirectory = Join-Path ([IO.Path]::GetTempPath()) ( 'aspnetcore-skill-evals-' + [guid]::NewGuid().ToString('N') @@ -177,7 +187,7 @@ function Invoke-VallyIsolated { New-Item -ItemType Directory -Path $workDirectory | Out-Null try { Push-Location $workDirectory - Invoke-Vally $VallyArguments + Invoke-Vally $VallyArguments -TolerateExitOne:$TolerateExitOne } finally { Pop-Location Remove-Item -Recurse -Force $workDirectory @@ -362,12 +372,7 @@ switch ($Action) { -OutputDirectory $suiteOutput ` -Vally $Vally -VallyPrefix $VallyPrefix @Arguments if (-not $? -or $LASTEXITCODE -ne 0) { - if ($LASTEXITCODE -ne 1) { - throw "The '$($directory.Name)' suite run failed." - } - & (Join-Path $PSScriptRoot 'assert_results.ps1') -OutputDirectory $suiteOutput - $global:LASTEXITCODE = 0 - Write-Warning "Vally exited with code 1 for '$($directory.Name)'. Complete primary trials passed the applicable result-set checks." + throw "The '$($directory.Name)' suite run failed." } } } @@ -398,7 +403,12 @@ switch ($Action) { $runs = if ($selectedExperiment -in @($smokeExperiment, $reviewSmokeExperiment)) { 1 } elseif ($componentDefaults -is [Collections.IDictionary] -and $null -ne $componentDefaults['runs']) { - [int]$componentDefaults['runs'] + $specifiedRuns = $componentDefaults['runs'] + if (($specifiedRuns -isnot [int] -and $specifiedRuns -isnot [long]) -or + $specifiedRuns -lt 1 -or $specifiedRuns -gt [int]::MaxValue) { + throw 'The component defaults.runs must be a positive integer.' + } + [int]$specifiedRuns } else { 1 } @@ -477,15 +487,17 @@ switch ($Action) { } $vallyArguments += $Arguments + $assertsResults = ($selectedSuite -eq 'review-candidate-verifier' -or $vallyArguments[0] -eq 'experiment') -and + $Arguments -notcontains '--dry-run' $existingRunDirectoryNames = [Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal) - if ($selectedSuite -eq 'review-candidate-verifier' -and (Test-Path $output -PathType Container)) { + if (($selectedSuite -eq 'review-candidate-verifier' -or $assertsResults) -and (Test-Path $output -PathType Container)) { foreach ($directory in Get-ChildItem $output -Directory -ErrorAction SilentlyContinue) { [void]$existingRunDirectoryNames.Add($directory.Name) } } $invocationCompleted = $false try { - Invoke-VallyIsolated $vallyArguments + Invoke-VallyIsolated $vallyArguments -TolerateExitOne:$assertsResults $invocationCompleted = $true } finally { if ($selectedSuite -eq 'review-candidate-verifier') { @@ -509,5 +521,19 @@ switch ($Action) { } } } + if ($assertsResults) { + $newRunDirectories = @( + Get-ChildItem $output -Directory -ErrorAction SilentlyContinue | + Where-Object { -not $existingRunDirectoryNames.Contains($_.Name) } + ) + if ($newRunDirectories.Count -ne 1) { + throw "Expected one new Vally run directory under '$output'; found $($newRunDirectories.Count)." + } + & (Join-Path $PSScriptRoot 'assert_results.ps1') -RunDirectory $newRunDirectories[0].FullName + if ($script:vallyExitCode -eq 1) { + Write-Warning 'Vally exited with code 1. Complete primary trials passed the applicable result-set checks.' + } + $global:LASTEXITCODE = 0 + } } } diff --git a/eng/skill-evals/stage_run.ps1 b/eng/skill-evals/stage_run.ps1 index 5fc2a52e76d5..bf834413763b 100644 --- a/eng/skill-evals/stage_run.ps1 +++ b/eng/skill-evals/stage_run.ps1 @@ -202,7 +202,16 @@ function Assert-EvalSpecIsRestricted { -not $parsed['grading_environment'].Contains('files')) { throw "$Description must declare the trusted grading_environment.files mapping." } - foreach ($stimulus in @($parsed['stimuli'])) { + $stimuli = $parsed['stimuli'] + if ($stimuli -isnot [Collections.IList] -or $stimuli.Count -eq 0 -or + @($stimuli | Where-Object { + $_ -isnot [Collections.IDictionary] -or + $_['name'] -isnot [string] -or + [string]::IsNullOrWhiteSpace($_['name']) + }).Count -gt 0) { + throw "$Description must declare a non-empty stimuli list of named stimuli." + } + foreach ($stimulus in $stimuli) { $primary = @($stimulus['graders'] | Where-Object { $_ -is [Collections.IDictionary] -and $_['name'] -ceq "disposition-$($stimulus['name'])" diff --git a/eng/skill-evals/test_assert_results.ps1 b/eng/skill-evals/test_assert_results.ps1 index 5d2ffdf9bd18..a3b785e1e259 100644 --- a/eng/skill-evals/test_assert_results.ps1 +++ b/eng/skill-evals/test_assert_results.ps1 @@ -368,6 +368,14 @@ try { param($rows) $rows[0].gradeResult.details += $rows[0].gradeResult.details[0] } } + @{ Name = 'BooleanReceiptScore'; Expected = 'failed read integrity'; Mutation = { + param($rows) + $rows[0].gradeResult.details[0].score = $true + } } + @{ Name = 'ReceiptGraderError'; Expected = 'failed read integrity'; Mutation = { + param($rows) + $rows[0].gradeResult.details[0].status = 'error' + } } @{ Name = 'DispositionGraderError'; Expected = 'valid primary disposition'; Mutation = { param($rows) $rows[0].gradeResult.details[1].status = 'error' diff --git a/eng/skill-evals/test_run.ps1 b/eng/skill-evals/test_run.ps1 index 85f8c670614e..75b1eaaebe8c 100644 --- a/eng/skill-evals/test_run.ps1 +++ b/eng/skill-evals/test_run.ps1 @@ -68,17 +68,37 @@ if ($env:SKILL_EVAL_FAKE_FAILURE) { } | ConvertTo-Json -Compress | Add-Content $env:SKILL_EVAL_RUNNER_RECORD +if ($args[0] -eq 'experiment' -and $args -notcontains '--dry-run') { + $output = $args[([array]::IndexOf($args, '--output-dir') + 1)] + $run = Join-Path $output ('experiment-' + [guid]::NewGuid().ToString('N')) + New-Item -ItemType Directory -Path $run -Force | Out-Null + @{ + evals = @('baseline', 'skilled' | ForEach-Object { + @{ variant = $_; plannedStimulusNames = @('s'); plannedStimulusCount = 1; runs = 1; threshold = 0 } + }) + } | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $run 'plan-snapshot.json') + foreach ($variant in 'baseline', 'skilled') { + New-Item -ItemType Directory -Path (Join-Path $run $variant) | Out-Null + @{ type = 'trial-result'; variant = $variant; stimulus = 's'; status = 'success'; gradeResult = @{ score = 1 } } | + ConvertTo-Json -Depth 10 -Compress | + Set-Content (Join-Path $run "$variant/results.jsonl") + } +} if ($args[0] -eq 'eval' -and ($args -join ' ') -like '*review-candidate-verifier*') { $output = $args[([array]::IndexOf($args, '--output-dir') + 1)] $run = Join-Path $output '2026-01-01T00-00-00' New-Item -ItemType Directory -Path $run -Force | Out-Null - if ($env:SKILL_EVAL_FAKE_EXIT_MODE) { + if ($env:SKILL_EVAL_FAKE_RESULTS -ne 'empty') { + $runs = [int]$args[([array]::IndexOf($args, '--runs') + 1)] + $names = @(Get-Content $args[([array]::IndexOf($args, '--eval-spec') + 1)] | + Where-Object { $_ -match '^ - name: (\S+)$' } | + ForEach-Object { $Matches[1] }) $rows = [Collections.Generic.List[object]]::new() - foreach ($name in 'a', 'b', 'c') { - foreach ($trial in 0..4) { + foreach ($name in $names) { + foreach ($trial in 0..($runs - 1)) { $score = if ( $env:SKILL_EVAL_FAKE_EXIT_MODE -eq 'failed-gate' -and - $name -eq 'a' -and $trial -ge 3 + $name -eq $names[0] -and $trial -ge 3 ) { 0 } else { 1 } $rows.Add(@{ type = 'trial-result' @@ -89,7 +109,11 @@ if ($args[0] -eq 'eval' -and ($args -join ' ') -like '*review-candidate-verifier gradeResult = @{ score = $score details = @( - @{ configuredName = "evidence-reads-$name"; passed = $true; score = 1 }, + @{ + configuredName = "evidence-reads-$name" + passed = -not ($env:SKILL_EVAL_FAKE_EXIT_MODE -eq 'failed-receipt' -and $name -eq $names[0] -and $trial -eq 0) + score = 1 + }, @{ configuredName = "disposition-$name"; passed = $score -eq 1; score = $score } ) } @@ -106,13 +130,13 @@ if ($args[0] -eq 'eval' -and ($args -join ' ') -like '*review-candidate-verifier }) $rows | ForEach-Object { $_ | ConvertTo-Json -Depth 10 -Compress } | Set-Content (Join-Path $run 'results.jsonl') - exit 1 - } - Set-Content (Join-Path $run 'results.jsonl') '' - if ($env:SKILL_EVAL_FAKE_EXIT) { - exit 1 + } else { + Set-Content (Join-Path $run 'results.jsonl') '' } } +if ($env:SKILL_EVAL_FAKE_EXIT_CODE) { + exit [int]$env:SKILL_EVAL_FAKE_EXIT_CODE +} '@ | Set-Content $fakeVally Set-Content $specialized "name: specialized`n" Set-Content $customExperiment "name: custom`n" @@ -317,14 +341,59 @@ stimuli: ) } - $env:SKILL_EVAL_FAKE_EXIT = 'true' - $failedOutput = Join-Path $testRoot 'component-exit-one' - & $runner Run -Suite review-candidate-verifier -Vally $fakeVally -VallyPrefix @() -OutputDirectory $failedOutput - Assert-True ($LASTEXITCODE -eq 1) 'Component Vally exit code was not propagated.' - Assert-True (Test-Path (Join-Path $failedOutput '2026-01-01T00-00-00/plan-snapshot.json')) ( - 'A failed component run lost its plan snapshot.' - ) - Remove-Item Env:SKILL_EVAL_FAKE_EXIT + function Invoke-ComponentFailure { + param([string]$Scenario, [hashtable]$Environment, [string]$ExpectedFailure) + + foreach ($entry in $Environment.GetEnumerator()) { + Set-Item "Env:$($entry.Key)" $entry.Value + } + $scenarioOutput = Join-Path $testRoot "component-failure-$Scenario" + $message = '' + try { + & $runner Run -Suite review-candidate-verifier -Vally $fakeVally -VallyPrefix @() -OutputDirectory $scenarioOutput + } catch { + $message = $_.Exception.Message + } finally { + foreach ($key in $Environment.Keys) { + Remove-Item "Env:$key" -ErrorAction SilentlyContinue + } + } + Assert-True ($message -like "*$ExpectedFailure*") ( + "$Scenario direct component run did not fail through the result gate. Error: $message" + ) + Assert-True (Test-Path (Join-Path $scenarioOutput '2026-01-01T00-00-00/plan-snapshot.json')) ( + "$Scenario component run lost its plan snapshot." + ) + } + + Invoke-ComponentFailure -Scenario 'ExitOneEmpty' ` + -Environment @{ SKILL_EVAL_FAKE_EXIT_CODE = '1'; SKILL_EVAL_FAKE_RESULTS = 'empty' } ` + -ExpectedFailure 'invalid or missing completion summary' + Invoke-ComponentFailure -Scenario 'ExitZeroFailedGate' ` + -Environment @{ SKILL_EVAL_FAKE_EXIT_MODE = 'failed-gate' } ` + -ExpectedFailure "stimulus 'a' score 0.6 is below threshold 0.8" + Invoke-ComponentFailure -Scenario 'ExitZeroFailedReceipt' ` + -Environment @{ SKILL_EVAL_FAKE_EXIT_MODE = 'failed-receipt' } ` + -ExpectedFailure "'a:0' failed read integrity: evidence-reads-a" + + foreach ($invalidRuns in @('0', '1.5', '"5"')) { + $componentSpecPath = Join-Path $customComponentDirectory 'eval.vally.yaml' + $validComponentSpec = Get-Content $componentSpecPath -Raw + Set-Content $componentSpecPath ($validComponentSpec.Replace('runs: 7', "runs: $invalidRuns")) + $message = '' + try { + & $runner Run -Root $customRoot -Suite review-candidate-verifier ` + -Vally $fakeVally -VallyPrefix @() ` + -OutputDirectory (Join-Path $testRoot 'invalid-yaml-runs') + } catch { + $message = $_.Exception.Message + } finally { + Set-Content $componentSpecPath $validComponentSpec + } + Assert-True ($message -eq 'The component defaults.runs must be a positive integer.') ( + "Invalid YAML runs '$invalidRuns' was not rejected clearly. Error: $message" + ) + } function Invoke-AllSuiteExitOneScenario { param( @@ -335,6 +404,7 @@ stimuli: Remove-Item $record -ErrorAction SilentlyContinue $env:SKILL_EVAL_FAKE_EXIT_MODE = $Scenario + $env:SKILL_EVAL_FAKE_EXIT_CODE = '1' $message = '' try { & $runner Run -Root $allSuiteRoot -Vally $fakeVally -VallyPrefix @() ` @@ -343,6 +413,7 @@ stimuli: $message = $_.Exception.Message } finally { Remove-Item Env:SKILL_EVAL_FAKE_EXIT_MODE -ErrorAction SilentlyContinue + Remove-Item Env:SKILL_EVAL_FAKE_EXIT_CODE -ErrorAction SilentlyContinue } if ($ShouldContinue) { @@ -467,7 +538,8 @@ stimuli: } finally { Remove-Item Env:SKILL_EVAL_RUNNER_RECORD -ErrorAction SilentlyContinue Remove-Item Env:SKILL_EVAL_FAKE_FAILURE -ErrorAction SilentlyContinue - Remove-Item Env:SKILL_EVAL_FAKE_EXIT -ErrorAction SilentlyContinue + Remove-Item Env:SKILL_EVAL_FAKE_EXIT_CODE -ErrorAction SilentlyContinue + Remove-Item Env:SKILL_EVAL_FAKE_RESULTS -ErrorAction SilentlyContinue Remove-Item Env:SKILL_EVAL_FAKE_EXIT_MODE -ErrorAction SilentlyContinue if ($hadPreviousVally) { $env:SKILL_EVAL_VALLY = $previousVally @@ -475,4 +547,5 @@ stimuli: Remove-Item Env:SKILL_EVAL_VALLY -ErrorAction SilentlyContinue } Remove-Item -Recurse -Force $testRoot + Remove-Item -Recurse -Force (Join-Path $repoRoot $relativeOutput) -ErrorAction SilentlyContinue } diff --git a/eng/skill-evals/test_stage_run.ps1 b/eng/skill-evals/test_stage_run.ps1 index 163741c451cd..ecedb061ed44 100644 --- a/eng/skill-evals/test_stage_run.ps1 +++ b/eng/skill-evals/test_stage_run.ps1 @@ -708,6 +708,28 @@ stimuli: -Scenario $case.Name -EvalSpec $case.Spec } + $componentStimuliSpecs = @( + @{ + Name = 'ComponentEmptyStimuli' + Spec = $canonicalComponentSpec -replace '(?ms)^stimuli:.*\z', 'stimuli: []' + } + ) + foreach ($case in $componentStimuliSpecs) { + if ($env:SKILL_EVAL_STAGE_RESTRICTION -and + $env:SKILL_EVAL_STAGE_RESTRICTION -ne $case.Name) { + continue + } + Set-Content (Join-Path $componentEval 'eval.vally.yaml') $case.Spec + $rejectedDestination = Join-Path $testRoot "rejected-$($case.Name)" + Assert-Throws { + & $stageRun -TrustedRoot $trustedRoot -CandidateRoot $candidateRoot ` + -EvalName review-candidate-verifier -Destination $rejectedDestination + } 'must declare a non-empty stimuli list of named stimuli' + Assert-True (-not (Test-Path $rejectedDestination)) ( + "Stimuli scenario '$($case.Name)' left a partial staged tree." + ) + } + Write-Host 'Trusted skill-eval staging self-test passed.' } finally { Remove-Item $testRoot -Recurse -Force From 9f5307ed9055da644792c02281a586a35db971f1 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Sat, 14 Nov 2026 18:12:15 -0600 Subject: [PATCH 14/23] Anchor review-mode C1 absence markers An absence phrase must now cover the whole rest of the C1 line, so prose such as 'No existing feedback resolves...' counts as a C1 entry. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/grade_disposition.mjs | 4 ++-- eng/skill-evals/test_disposition.mjs | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/eng/skill-evals/grade_disposition.mjs b/eng/skill-evals/grade_disposition.mjs index 69bc201dd107..63fda8d2a882 100644 --- a/eng/skill-evals/grade_disposition.mjs +++ b/eng/skill-evals/grade_disposition.mjs @@ -102,14 +102,14 @@ function isNegativeC1Line(line) .trim() .replace(/^(?:[-*+]|\d+[.)])\s+/, '') .trim(); - const explicitAbsence = /^(?:none(?:\s+(?:applicable|covered|found|reported|identified))?[.!]?\s*$|n\/a[.!]?\s*$|no(?:\s+(?:findings|items|candidates|entries|unresolved|discarded|existing\s+feedback)\b|\s+C1[.!]?\s*$|[.!]?\s*$))/i; + const explicitAbsence = /^(?:none(?:\s+(?:applicable|covered|found|reported|identified))?[.!]?\s*$|n\/a[.!]?\s*$|no(?:\s+(?:findings|items|candidates|entries|unresolved|discarded|existing\s+feedback)[.!]?\s*$|\s+C1[.!]?\s*$|[.!]?\s*$))/i; if (!clean || explicitAbsence.test(clean)) { return true; } const afterC1 = clean.replace(/^C1\b\s*(?:[-:—–]|\s)*/i, ''); return afterC1 !== clean && (explicitAbsence.test(afterC1) || - /^(?:(?:is\s+|was\s+)?not\s+(?:covered|unresolved|discarded|applicable)|has\s+no\s+existing\s+feedback|(?:is\s+|was\s+)?omitted)\b/i.test(afterC1)); + /^(?:(?:is\s+|was\s+)?not\s+(?:covered(?:\s+by\s+(?:any\s+)?(?:existing\s+)?feedback(?:\s+in\s+[^.!;,]*)?)?|unresolved|discarded|applicable)|has\s+no\s+existing\s+feedback|(?:is\s+|was\s+)?omitted)[.!]?\s*$/i.test(afterC1)); } function hasPositiveC1(sectionText) diff --git a/eng/skill-evals/test_disposition.mjs b/eng/skill-evals/test_disposition.mjs index 44bc561474ac..30d7e116a88f 100644 --- a/eng/skill-evals/test_disposition.mjs +++ b/eng/skill-evals/test_disposition.mjs @@ -198,6 +198,18 @@ test('ReviewDispositionDistinguishesSubstantiveNoneFromAbsenceMarkers', async co .replace('UNRESOLVED\nNone.', 'UNRESOLVED\nC1: None of the frozen contracts establishes whether failures propagate.'), 0], ['conflicting-none-applicable-prose', 'case-02', review('NEW_FINDINGS', 'verified') .replace('UNRESOLVED\nNone.', 'UNRESOLVED\nC1: None applicable. C1 is unresolved.'), 0], + ['conflicting-no-existing-feedback-prose', 'case-02', review('NEW_FINDINGS', 'verified') + .replace('UNRESOLVED\nNone.', 'UNRESOLVED\nC1: No existing feedback resolves whether failures propagate.'), 0], + ['conflicting-not-covered-prose', 'case-02', review('NEW_FINDINGS', 'verified') + .replace('UNRESOLVED\nNone.', 'UNRESOLVED\nC1: Not covered by the head tests, so propagation is unknown.'), 0], + ['conflicting-omitted-prose', 'case-02', review('NEW_FINDINGS', 'verified') + .replace('DISCARDED\nNone.', 'DISCARDED\nC1: Omitted guard causes the old and head paths to match.'), 0], + ['absence-and-prose-in-different-sections', 'case-02', review('NEW_FINDINGS', 'verified') + .replace('UNRESOLVED\nNone.', 'UNRESOLVED\nC1: None.') + .replace('DISCARDED\nNone.', 'DISCARDED\nC1: Not covered by the head tests, so propagation is unknown.'), 0], + ['absence-in-one-section-only', 'case-02', review('NEW_FINDINGS', 'verified') + .replace('UNRESOLVED\nNone.', 'UNRESOLVED\nC1: None.') + .replace('DISCARDED\nNone.', 'DISCARDED\nC1 omitted.'), 1], ]) { await context.test(name, () => From 95bca692c8c65182777e0adc348db69cbd4ccd1c Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Sat, 14 Nov 2026 18:12:16 -0600 Subject: [PATCH 15/23] Store unchanged verifier fixtures once Six source files are identical at both revisions. Keep one copy under head and map it to both destinations. The realized files for each case are unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/README.md | 7 +- .../review-candidate-verifier/eval.vally.yaml | 24 +++ .../Components/AI/src/Blocks/ContentBlock.cs | 73 ------- .../AI/src/Blocks/IInteractiveBlock.cs | 19 -- .../AI/src/Components/MessageInput.cs | 169 ---------------- .../AI/src/Engine/ConversationStatus.cs | 31 --- .../AI/src/Engine/ConversationTurn.cs | 44 ----- .../AI/src/Pipeline/BlockMappingPipeline.cs | 182 ------------------ .../review-candidate-verifier/provenance.json | 24 --- 9 files changed, 28 insertions(+), 545 deletions(-) delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs delete mode 100644 eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs diff --git a/eng/skill-evals/README.md b/eng/skill-evals/README.md index 0364815d64eb..13d328e1c337 100644 --- a/eng/skill-evals/README.md +++ b/eng/skill-evals/README.md @@ -111,10 +111,11 @@ Each `case-` folder holds files that only that case uses. | `case-c\source\head\src\Engine\Conversation.mjs` | c | Synthetic head implementation. | | `case-c\source\mergeBase\src\Engine\Conversation.mjs` | c | Synthetic earlier implementation. | -The following nine files appear under -`shared\source\head\src\Components\AI\src` and +Cases a and b receive all nine files at both revisions. Six files are unchanged +between the revisions, so only `shared\source\head\src\Components\AI\src` stores +them, and the spec maps each one to both revisions. Only `AgentContext.cs`, +`UIAgent.cs`, and `UIAgentLog.cs` are also stored under `shared\source\mergeBase\src\Components\AI\src`. -Both cases a and b receive all nine files at both revisions. | C# file relative to either source directory | Cases | Purpose | |---|---|---| diff --git a/eng/skill-evals/review-candidate-verifier/eval.vally.yaml b/eng/skill-evals/review-candidate-verifier/eval.vally.yaml index 233f5b45fbf1..77e3b873b626 100644 --- a/eng/skill-evals/review-candidate-verifier/eval.vally.yaml +++ b/eng/skill-evals/review-candidate-verifier/eval.vally.yaml @@ -33,6 +33,18 @@ stimuli: dest: source/head/src/Components/AI/src - src: fixtures/shared/source/mergeBase/src/Components/AI/src dest: source/mergeBase/src/Components/AI/src + - src: fixtures/shared/source/head/src/Components/AI/src/Blocks/ContentBlock.cs + dest: source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs + - src: fixtures/shared/source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs + dest: source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs + - src: fixtures/shared/source/head/src/Components/AI/src/Components/MessageInput.cs + dest: source/mergeBase/src/Components/AI/src/Components/MessageInput.cs + - src: fixtures/shared/source/head/src/Components/AI/src/Engine/ConversationStatus.cs + dest: source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs + - src: fixtures/shared/source/head/src/Components/AI/src/Engine/ConversationTurn.cs + dest: source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs + - src: fixtures/shared/source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs + dest: source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs - src: fixtures/shared/source/baseTip/docs/CrossCuttingGuidance.md dest: source/baseTip/docs/CrossCuttingGuidance.md - src: fixtures/shared/changes.diff @@ -91,6 +103,18 @@ stimuli: dest: source/head/src/Components/AI/src - src: fixtures/shared/source/mergeBase/src/Components/AI/src dest: source/mergeBase/src/Components/AI/src + - src: fixtures/shared/source/head/src/Components/AI/src/Blocks/ContentBlock.cs + dest: source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs + - src: fixtures/shared/source/head/src/Components/AI/src/Blocks/IInteractiveBlock.cs + dest: source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs + - src: fixtures/shared/source/head/src/Components/AI/src/Components/MessageInput.cs + dest: source/mergeBase/src/Components/AI/src/Components/MessageInput.cs + - src: fixtures/shared/source/head/src/Components/AI/src/Engine/ConversationStatus.cs + dest: source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs + - src: fixtures/shared/source/head/src/Components/AI/src/Engine/ConversationTurn.cs + dest: source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs + - src: fixtures/shared/source/head/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs + dest: source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs - src: fixtures/shared/source/baseTip/docs/CrossCuttingGuidance.md dest: source/baseTip/docs/CrossCuttingGuidance.md - src: fixtures/shared/changes.diff diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs deleted file mode 100644 index d0fccaa4f9bb..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Base class for a unit of conversation content that the UI renders and that can be -/// updated while the model response is still streaming. -/// -/// -/// Subscribe to updates while a block streams: -/// -/// using var subscription = block.OnChanged(() => StateHasChanged()); -/// -/// -public abstract class ContentBlock -{ - private readonly List _callbacks = new(); - - /// - /// Gets the identifier of this block. Blocks produced by the same model message share the same identifier. - /// - public string Id { get; internal set; } = string.Empty; - - /// - /// Gets the current lifecycle state of this block. - /// - public BlockLifecycleState LifecycleState { get; internal set; } - - /// - /// Gets the role of the conversation participant that produced this block. - /// - public ChatRole? Role { get; internal set; } - - /// - /// Gets the name of the author that produced this block, when the model provides one. - /// - public string? AuthorName { get; internal set; } - - /// - /// Registers a callback that runs whenever this block changes. - /// - /// The callback to invoke when the block changes. - /// A subscription that removes the callback when disposed. - public ContentBlockChangedSubscription OnChanged(Action callback) - { - ArgumentNullException.ThrowIfNull(callback); - _callbacks.Add(callback); - return new ContentBlockChangedSubscription(this, callback); - } - - /// - /// Notifies subscribers that this block changed. - /// - protected void NotifyChanged() - { - // Snapshot the callbacks to allow safe removal during iteration - var snapshot = _callbacks.ToArray(); - for (var i = 0; i < snapshot.Length; i++) - { - snapshot[i](); - } - } - - internal void InvokeNotifyChanged() => NotifyChanged(); - - internal void RemoveCallback(Action callback) - { - _callbacks.Remove(callback); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs deleted file mode 100644 index 2a67244ace0c..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Represents a content block that pauses a conversation until the user supplies a result. -/// -public interface IInteractiveBlock -{ - /// - /// Waits for the user-supplied result. - /// - /// A token that cancels the wait. - /// The content used to continue the conversation. - Task GetResultAsync(CancellationToken cancellationToken = default); -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs deleted file mode 100644 index b61db3c99167..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs +++ /dev/null @@ -1,169 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.AspNetCore.Components.Web; -using Microsoft.Extensions.AI; - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// Text input that sends messages to the cascaded and disables -/// itself while a response streams. -/// -public class MessageInput : IComponent, IDisposable -{ - private RenderHandle _renderHandle; - private AgentContext _agentContext = default!; - private string? _placeholder; - private RenderFragment? _leadingActions; - private RenderFragment? _trailingActions; - private string _text = ""; - private bool _isDisabled; - private IDisposable? _statusSub; - - /// - /// Gets or sets the conversation this input sends messages to. - /// - [CascadingParameter] - public AgentContext AgentContext { get; set; } = default!; - - /// - /// Gets or sets the placeholder text of the input. - /// - [Parameter] - public string? Placeholder { get; set; } - - /// - /// Gets or sets the content rendered before the text area. - /// - [Parameter] - public RenderFragment? LeadingActions { get; set; } - - /// - /// Gets or sets the content rendered after the text area. Replaces the default send button. - /// - [Parameter] - public RenderFragment? TrailingActions { get; set; } - - void IComponent.Attach(RenderHandle renderHandle) - { - _renderHandle = renderHandle; - } - - Task IComponent.SetParametersAsync(ParameterView parameters) - { - parameters.SetParameterProperties(this); - _agentContext = AgentContext - ?? throw new InvalidOperationException( - "MessageInput must be inside an AgentBoundary."); - _placeholder = Placeholder; - _leadingActions = LeadingActions; - _trailingActions = TrailingActions; - - // Register once. The AgentContext cascade is fixed for the lifetime of the component, - // so re-registering on every parameter set would accumulate handlers and retain the - // component on each parent re-render. - _statusSub ??= _agentContext.RegisterOnStatusChanged(status => - { - _isDisabled = status is ConversationStatus.Streaming or ConversationStatus.AwaitingInput; - Render(); - }); - - Render(); - return Task.CompletedTask; - } - - private void Render() - { - _renderHandle.Render(builder => - { - builder.OpenElement(0, "div"); - builder.AddAttribute(1, "class", "sc-ai-input"); - - if (_leadingActions is not null) - { - builder.AddContent(2, _leadingActions); - } - - builder.OpenElement(3, "div"); - builder.AddAttribute(4, "class", "sc-ai-input__body"); - - builder.OpenElement(10, "textarea"); - builder.AddAttribute(11, "class", "sc-ai-input__textarea"); - builder.AddAttribute(12, "placeholder", _placeholder ?? "Type a message..."); - builder.AddAttribute(13, "disabled", _isDisabled); - builder.AddAttribute(14, "value", _text); - builder.AddAttribute(15, "aria-label", _placeholder ?? "Type a message..."); - builder.AddAttribute(16, "oninput", - EventCallback.Factory.Create( - this, e => - { - _text = e.Value?.ToString() ?? ""; - // Re-render so the component's rendered value tracks the DOM value. - // Without this, clearing _text on submit produces no diff (the last - // rendered value was already empty) and the textarea is never cleared. - Render(); - })); - builder.SetUpdatesAttributeName("value"); - builder.AddAttribute(17, "onkeydown", - EventCallback.Factory.Create(this, OnKeyDown)); - builder.CloseElement(); // textarea - - builder.CloseElement(); // input body - - if (_trailingActions is not null) - { - builder.AddContent(50, _trailingActions); - } - else - { - builder.OpenElement(50, "button"); - builder.AddAttribute(51, "type", "button"); - builder.AddAttribute(52, "class", "sc-ai-input__send"); - builder.AddAttribute(53, "disabled", _isDisabled); - builder.AddAttribute(54, "aria-label", "Send message"); - builder.AddAttribute(55, "onclick", - EventCallback.Factory.Create(this, SubmitAsync)); - - // Send icon SVG - builder.AddMarkupContent(56, - ""); - - builder.CloseElement(); - } - - builder.CloseElement(); // div - }); - } - - private async Task OnKeyDown(KeyboardEventArgs e) - { - if (e.Key == "Enter" && !e.ShiftKey && !_isDisabled) - { - await SubmitAsync(); - } - } - - private async Task SubmitAsync() - { - if (_isDisabled || string.IsNullOrWhiteSpace(_text)) - { - return; - } - - var text = _text; - _text = ""; - Render(); - - await _agentContext.SendMessageAsync(new ChatMessage(ChatRole.User, text)); - } - - /// - /// Removes the status subscription this input registered on the conversation. - /// - public void Dispose() - { - _statusSub?.Dispose(); - GC.SuppressFinalize(this); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs deleted file mode 100644 index 01cf29c7a29a..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// The state of a conversation driven by an . -/// -public enum ConversationStatus -{ - /// - /// No response is in flight; the user can send a message. - /// - Idle, - - /// - /// A model response is streaming. - /// - Streaming, - - /// - /// The conversation is waiting for the user to interact with the current response. - /// - AwaitingInput, - - /// - /// The last turn failed. holds the exception and - /// replays the turn. - /// - Error -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs deleted file mode 100644 index 736383376c53..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Microsoft.AspNetCore.Components.AI; - -/// -/// A single exchange in a conversation: the blocks produced by the user's message and the -/// blocks produced by the response to it. -/// -public class ConversationTurn -{ - private readonly List _requestBlocks = new(); - private readonly List _responseBlocks = new(); - - /// - /// Gets the identifier of this turn. - /// - public string Id { get; internal set; } = string.Empty; - - /// - /// Gets the blocks produced by the message that started this turn. - /// - public IReadOnlyList RequestBlocks => _requestBlocks; - - /// - /// Gets the blocks produced by the response to this turn. - /// - public IReadOnlyList ResponseBlocks => _responseBlocks; - - internal void AddRequestBlock(ContentBlock block) - { - _requestBlocks.Add(block); - } - - internal void AddResponseBlock(ContentBlock block) - { - _responseBlocks.Add(block); - } - - internal void ClearResponseBlocks() - { - _responseBlocks.Clear(); - } -} diff --git a/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs b/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs deleted file mode 100644 index 46228004cf49..000000000000 --- a/eng/skill-evals/review-candidate-verifier/fixtures/shared/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs +++ /dev/null @@ -1,182 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Linq; -using System.Runtime.CompilerServices; -using Microsoft.Extensions.AI; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; - -namespace Microsoft.AspNetCore.Components.AI; - -// Routes model updates to handlers in two phases: -// 1. Blocks that are still active get first refusal on the update, most recent first. -// This keeps a streaming block accumulating instead of emitting a new block per token. -// 2. Whatever is left is offered to inactive handlers, which may emit new blocks. -internal class BlockMappingPipeline -{ - private readonly List _handlers = new(); - private readonly List _activeStack = new(); - private readonly ILogger _logger; - - internal BlockMappingPipeline(UIAgentOptions options, ILogger? logger = null) - { - _logger = logger ?? NullLogger.Instance; - - // User-registered handlers go first so they can customize behavior - foreach (var registration in options.HandlerRegistrations) - { - _handlers.Add(registration.CreateEntry()); - } - - if (options.UIActions.Count > 0) - { - _handlers.Add(new HandlerEntry( - new UIActionHandler(options.UIActions))); - } - - _handlers.Add(new HandlerEntry( - new FunctionApprovalHandler())); - - _handlers.Add(new HandlerEntry( - new FunctionInvocationHandler())); - - // Structured snapshots take precedence over the plain-text fallback. - _handlers.Add(new HandlerEntry(new RichTextContentHandler())); - - // Built-in plain-text handler is always last (fallback). - _handlers.Add(new HandlerEntry(new TextBlockHandler())); - } - - internal async IAsyncEnumerable Process( - ChatResponseUpdate update, -#pragma warning disable IDE0060 // cancellationToken reserved for future use - [EnumeratorCancellation] CancellationToken cancellationToken = default) -#pragma warning restore IDE0060 - { - var contentTypes = string.Join(", ", update.Contents.Select(c => c.GetType().Name)); - BlockMappingPipelineLog.ProcessingUpdate(_logger, update.Role?.Value, update.Contents.Count, contentTypes); - - var context = new BlockMappingContext(update, _handlers); - - // Phase 1: Active entries get priority (most recent first) - for (var i = _activeStack.Count - 1; i >= 0; i--) - { - if (context.AllHandled) - { - break; - } - - var active = _activeStack[i]; - var result = active.Invoke(context); - - BlockMappingPipelineLog.ActiveHandlerResult(_logger, active.Block.GetType().Name, result.Kind.ToString(), active.Block.Id); - - switch (result.Kind) - { - case HandleResult.ResultKind.Pass: - break; - - case HandleResult.ResultKind.Update: - active.Block.InvokeNotifyChanged(); - break; - - case HandleResult.ResultKind.Complete: - active.Block.LifecycleState = BlockLifecycleState.Inactive; - active.Block.InvokeNotifyChanged(); - _activeStack.RemoveAt(i); - break; - } - } - - // Phase 2: Inactive handlers try to claim remaining content - if (!context.AllHandled) - { - for (var i = 0; i < _handlers.Count; i++) - { - if (context.AllHandled) - { - break; - } - - var handler = _handlers[i]; - BlockMappingPipelineLog.TryingInactiveHandler(_logger, handler.GetType().Name); - - while (!context.AllHandled) - { - var progressBefore = context.HandledProgress; - var activeEntry = handler.TryHandle(context); - if (activeEntry is null) - { - break; - } - - var emitBlock = activeEntry.Block; - emitBlock.Role = update.Role; - emitBlock.AuthorName = update.AuthorName; - emitBlock.LifecycleState = BlockLifecycleState.Active; - ThrowIfIdMissing(emitBlock); - - var keepActive = true; - if (emitBlock is FunctionInvocationContentBlock) - { - var catchUpResult = activeEntry.Invoke(context); - - BlockMappingPipelineLog.ActiveHandlerResult(_logger, emitBlock.GetType().Name, catchUpResult.Kind.ToString(), emitBlock.Id); - - if (catchUpResult.Kind == HandleResult.ResultKind.Complete) - { - emitBlock.LifecycleState = BlockLifecycleState.Inactive; - keepActive = false; - } - } - - if (keepActive) - { - _activeStack.Add(activeEntry); - } - - BlockMappingPipelineLog.EmittingBlock(_logger, emitBlock.GetType().Name, emitBlock.Id, emitBlock.Role?.Value); - - yield return emitBlock; - - // If the handler emitted without consuming any content, stop - // re-invoking it to prevent infinite loops. - if (context.HandledProgress == progressBefore) - { - break; - } - } - } - } - else - { - BlockMappingPipelineLog.AllContentHandledAfterPhase1(_logger); - } - - await Task.CompletedTask; - } - - internal IReadOnlyList Finalize() - { - BlockMappingPipelineLog.Finalizing(_logger, _activeStack.Count); - - foreach (var active in _activeStack) - { - active.Block.LifecycleState = BlockLifecycleState.Inactive; - active.Block.InvokeNotifyChanged(); - } - _activeStack.Clear(); - - return Array.Empty(); - } - - private static void ThrowIfIdMissing(ContentBlock block) - { - if (string.IsNullOrEmpty(block.Id)) - { - throw new InvalidOperationException( - $"Block handler emitted a {block.GetType().Name} without assigning an Id."); - } - } -} diff --git a/eng/skill-evals/review-candidate-verifier/provenance.json b/eng/skill-evals/review-candidate-verifier/provenance.json index e8946f3e09ae..583d5c165598 100644 --- a/eng/skill-evals/review-candidate-verifier/provenance.json +++ b/eng/skill-evals/review-candidate-verifier/provenance.json @@ -100,30 +100,10 @@ "file": "case-c/source/head/src/Engine/Conversation.mjs", "sha256": "13e383993dd60d8548089196ada34afcf791c7995ffda48104bbe23bf15cff11" }, - { - "file": "shared/source/mergeBase/src/Components/AI/src/Blocks/ContentBlock.cs", - "sha256": "7cab62ac70d7faa70dacbdb4bd36723b4061612ab921b9f7d7d019d3ba905261" - }, - { - "file": "shared/source/mergeBase/src/Components/AI/src/Blocks/IInteractiveBlock.cs", - "sha256": "0f6c4f9e859a917755b75bcf335273c37461525fc72d7e5564ba2594c99ba90f" - }, - { - "file": "shared/source/mergeBase/src/Components/AI/src/Components/MessageInput.cs", - "sha256": "d0ddd1d72a79945463c3ddf92b2861b4e2b05d47fb4bebcbc7feef5685397091" - }, { "file": "shared/source/mergeBase/src/Components/AI/src/Engine/AgentContext.cs", "sha256": "61ca1e7434f6046328435ec8df5bd069c3198af8bb6b2db9912ff4c66cf7b084" }, - { - "file": "shared/source/mergeBase/src/Components/AI/src/Engine/ConversationStatus.cs", - "sha256": "b44fd1f2cbb45c401f14a695f3ef8c7dac6f1d2a66f6e9622f15a2c2099546f9" - }, - { - "file": "shared/source/mergeBase/src/Components/AI/src/Engine/ConversationTurn.cs", - "sha256": "3a5dbc73c955c5dec1fa04e195c35387477287a0b5e78013b2c91d65477295ea" - }, { "file": "shared/source/mergeBase/src/Components/AI/src/Engine/UIAgent.cs", "sha256": "63783e5da3d7b6fbf0c339d2e3a2298498b2b455a587e79f5f25431bf9812943" @@ -132,10 +112,6 @@ "file": "shared/source/mergeBase/src/Components/AI/src/Engine/UIAgentLog.cs", "sha256": "f7eb199a984d4b163a972c13e709de02e203789b8e0e834793b94487344e2df7" }, - { - "file": "shared/source/mergeBase/src/Components/AI/src/Pipeline/BlockMappingPipeline.cs", - "sha256": "3efb30f16570e2754c38b579e3fdb4dc4d5b9d750b3a9408c7fa1238c11258ee" - }, { "file": "case-c/source/mergeBase/src/Engine/Conversation.mjs", "sha256": "2c59edf3be93947a250c4c0a2787d103775265058fe3dbc533014932e2012deb" From 6a2d381accfe5863f139c13efa062df0aa761966 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Sat, 14 Nov 2026 18:12:17 -0600 Subject: [PATCH 16/23] Drop stage tests that Vally already enforces Vally rejects grading_environment commands and mcpServers, and duplicate grader file destinations, during lint. Remove the stage tests that only repeated those checks and fix the extended canonical spec so Vally accepts it. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/test_stage_run.ps1 | 38 +----------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/eng/skill-evals/test_stage_run.ps1 b/eng/skill-evals/test_stage_run.ps1 index ecedb061ed44..fee89150deb3 100644 --- a/eng/skill-evals/test_stage_run.ps1 +++ b/eng/skill-evals/test_stage_run.ps1 @@ -239,39 +239,6 @@ stimuli: -Destination (Join-Path $testRoot 'restricted-mcp') } "forbidden 'environment.mcpServers' field" - if (-not $env:SKILL_EVAL_STAGE_RESTRICTION) { - New-RestrictedCandidate 'restricted-grading-commands' @' -grading_environment: - commands: - - node candidate-grader.mjs -stimuli: - - name: case -'@ - Assert-Throws { - & $stageRun ` - -TrustedRoot $trustedRoot ` - -CandidateRoot $candidateRoot ` - -EvalName restricted-grading-commands ` - -Destination (Join-Path $testRoot 'restricted-grading-commands') - } "forbidden 'grading_environment.commands' field" - - New-RestrictedCandidate 'restricted-grading-mcp' @' -stimuli: - - name: case - grading_environment: - mcpServers: - candidate: - command: node -'@ - Assert-Throws { - & $stageRun ` - -TrustedRoot $trustedRoot ` - -CandidateRoot $candidateRoot ` - -EvalName restricted-grading-mcp ` - -Destination (Join-Path $testRoot 'restricted-grading-mcp') - } "forbidden 'grading_environment.mcpServers' field" - } - New-RestrictedCandidate 'restricted-agent-environment' @' stimuli: - agent_environment: @@ -539,10 +506,7 @@ stimuli: Test-Path (Join-Path $componentDestination '.github/agents/review-candidate-verifier.agent.md') ) 'The component verifier profile is missing.' - $extendedCanonicalComponentSpec = $canonicalComponentSpec.Replace( - ' - name: component-case', - " - name: component-case`n grading_environment:`n files:`n - src: ../grade_disposition.mjs`n dest: grade_disposition.mjs" - ) + @' + $extendedCanonicalComponentSpec = $canonicalComponentSpec + @' - type: program name: secondary-component-case From f0825be8f7743607f1a6d343c4a190c562627db4 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Sat, 14 Nov 2026 18:12:18 -0600 Subject: [PATCH 17/23] Remove unrelated skill-evals dispatch choices Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/skill-evals.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/skill-evals.yml b/.github/workflows/skill-evals.yml index 036d55ce0d3d..9742fc1fb905 100644 --- a/.github/workflows/skill-evals.yml +++ b/.github/workflows/skill-evals.yml @@ -39,8 +39,6 @@ on: required: true default: review-public-api options: - - port-components-platform-api - - pr-attention-queue - review-public-api - review-candidate-verifier - validate-blazor-feature From b16534822bf19ed8a9a5b9e03ac7f4c3685deb46 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Sun, 15 Nov 2026 12:53:10 -0600 Subject: [PATCH 18/23] Bound review disposition absence scopes Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/grade_disposition.mjs | 2 +- eng/skill-evals/test_disposition.mjs | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/eng/skill-evals/grade_disposition.mjs b/eng/skill-evals/grade_disposition.mjs index 63fda8d2a882..59e87cccb667 100644 --- a/eng/skill-evals/grade_disposition.mjs +++ b/eng/skill-evals/grade_disposition.mjs @@ -109,7 +109,7 @@ function isNegativeC1Line(line) } const afterC1 = clean.replace(/^C1\b\s*(?:[-:—–]|\s)*/i, ''); return afterC1 !== clean && (explicitAbsence.test(afterC1) || - /^(?:(?:is\s+|was\s+)?not\s+(?:covered(?:\s+by\s+(?:any\s+)?(?:existing\s+)?feedback(?:\s+in\s+[^.!;,]*)?)?|unresolved|discarded|applicable)|has\s+no\s+existing\s+feedback|(?:is\s+|was\s+)?omitted)[.!]?\s*$/i.test(afterC1)); + /^(?:(?:is\s+|was\s+)?not\s+(?:covered(?:\s+by\s+(?:any\s+)?(?:existing\s+)?feedback(?:\s+in\s+(?:the\s+)?(?:supplied\s+|frozen\s+|existing\s+)*(?:(?:pr|review|evidence)\s+)*(?:evidence|bundle|pr|review|threads?|comments?|feedback))?)?|unresolved|discarded|applicable)|has\s+no\s+existing\s+feedback|(?:is\s+|was\s+)?omitted)[.!]?\s*$/i.test(afterC1)); } function hasPositiveC1(sectionText) diff --git a/eng/skill-evals/test_disposition.mjs b/eng/skill-evals/test_disposition.mjs index 30d7e116a88f..a54d7f056728 100644 --- a/eng/skill-evals/test_disposition.mjs +++ b/eng/skill-evals/test_disposition.mjs @@ -227,6 +227,27 @@ test('ReviewDispositionDistinguishesSubstantiveNoneFromAbsenceMarkers', async co } }); +test('ReviewDispositionRejectsContradictoryFeedbackScopeProse', () => +{ + const output = review('NEW_FINDINGS', 'verified') + .replace('UNRESOLVED\nNone.', 'UNRESOLVED\nC1: Not covered by feedback in base-tip docs — propagation contract is unestablished.'); + assert.equal(score('case-02', output), 0); +}); + +test('ReviewDispositionAcceptsUnresolvedFeedbackScopeProse', () => +{ + const output = review('UNRESOLVED', 'unresolved') + .replace('C1 missing target-base contract.', 'C1: Not covered by existing feedback in the supplied docs so propagation is unresolved.'); + assert.equal(score('case-06', output), 1); +}); + +test('ReviewDispositionAcceptsReviewThreadsAbsenceScope', () => +{ + const output = review('NEW_FINDINGS', 'verified') + .replace('UNRESOLVED\nNone.', 'UNRESOLVED\nC1: Not covered by existing feedback in the review threads.'); + assert.equal(score('case-02', output), 1); +}); + test('ExistingFeedbackRequiresThreadAndRejectsDuplicateInline', () => { const good = `STATUS: NO_FINDINGS From 6e83dcfb5c6fe79fbbbe0745c79645ab765d7841 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Sun, 15 Nov 2026 12:53:11 -0600 Subject: [PATCH 19/23] Use literal paths for evaluation result discovery Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/assert_results.ps1 | 20 ++++++++++++-------- eng/skill-evals/run.ps1 | 12 ++++++------ eng/skill-evals/test_assert_results.ps1 | 9 +++++++++ eng/skill-evals/test_run.ps1 | 8 ++++---- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/eng/skill-evals/assert_results.ps1 b/eng/skill-evals/assert_results.ps1 index 01b6cee0e2b6..febefc1bf36c 100644 --- a/eng/skill-evals/assert_results.ps1 +++ b/eng/skill-evals/assert_results.ps1 @@ -11,13 +11,17 @@ $ErrorActionPreference = 'Stop' Set-StrictMode -Version 3 if ($RunDirectory) { - $runDirectories = @(Get-Item -LiteralPath (Resolve-Path $RunDirectory).Path) + $resolvedOutput = (Resolve-Path -LiteralPath $RunDirectory).Path + if (-not (Test-Path -LiteralPath $resolvedOutput -PathType Container)) { + throw "RunDirectory must be a directory: '$resolvedOutput'." + } + $runDirectories = @(Get-Item -LiteralPath $resolvedOutput) } else { - $resolvedOutput = (Resolve-Path $OutputDirectory).Path - $runDirectories = @(Get-ChildItem $resolvedOutput -Directory) + $resolvedOutput = (Resolve-Path -LiteralPath $OutputDirectory).Path + $runDirectories = @(Get-ChildItem -LiteralPath $resolvedOutput -Directory) } if (-not $RunDirectory -and $runDirectories.Count -gt 0 -and - @($runDirectories | Where-Object { Test-Path (Join-Path $_.FullName 'plan-snapshot.json') }).Count -eq 0) { + @($runDirectories | Where-Object { Test-Path -LiteralPath (Join-Path $_.FullName 'plan-snapshot.json') }).Count -eq 0) { foreach ($directory in $runDirectories) { & $PSCommandPath -OutputDirectory $directory.FullName } @@ -29,11 +33,11 @@ if ($runDirectories.Count -ne 1) { $runDirectory = $runDirectories[0].FullName $snapshotPath = Join-Path $runDirectory 'plan-snapshot.json' -if (-not (Test-Path $snapshotPath -PathType Leaf)) { +if (-not (Test-Path -LiteralPath $snapshotPath -PathType Leaf)) { throw "Missing Vally plan snapshot at '$snapshotPath'." } -$snapshot = Get-Content $snapshotPath -Raw | ConvertFrom-Json -Depth 100 +$snapshot = Get-Content -LiteralPath $snapshotPath -Raw | ConvertFrom-Json -Depth 100 $scoresByVariant = @{} $plansByVariant = @{} $variants = if ($snapshot.evals.Count -eq 1 -and $snapshot.evals[0].variant -eq 'current') { @@ -63,12 +67,12 @@ foreach ($variant in $variants) { } $plansByVariant[$variant] = $plan $resultsPath = Join-Path $runDirectory $(if ($variant -eq 'current') { 'results.jsonl' } else { "$variant/results.jsonl" }) - if (-not (Test-Path $resultsPath -PathType Leaf)) { + if (-not (Test-Path -LiteralPath $resultsPath -PathType Leaf)) { throw "Missing Vally results at '$resultsPath'." } $results = @( - Get-Content $resultsPath | + Get-Content -LiteralPath $resultsPath | Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | ForEach-Object { $record = ConvertFrom-Json -InputObject $_ -Depth 100 -NoEnumerate diff --git a/eng/skill-evals/run.ps1 b/eng/skill-evals/run.ps1 index 078d0de9a91e..c63c38bac04a 100644 --- a/eng/skill-evals/run.ps1 +++ b/eng/skill-evals/run.ps1 @@ -490,8 +490,8 @@ switch ($Action) { $assertsResults = ($selectedSuite -eq 'review-candidate-verifier' -or $vallyArguments[0] -eq 'experiment') -and $Arguments -notcontains '--dry-run' $existingRunDirectoryNames = [Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal) - if (($selectedSuite -eq 'review-candidate-verifier' -or $assertsResults) -and (Test-Path $output -PathType Container)) { - foreach ($directory in Get-ChildItem $output -Directory -ErrorAction SilentlyContinue) { + if (($selectedSuite -eq 'review-candidate-verifier' -or $assertsResults) -and (Test-Path -LiteralPath $output -PathType Container)) { + foreach ($directory in Get-ChildItem -LiteralPath $output -Directory -ErrorAction SilentlyContinue) { [void]$existingRunDirectoryNames.Add($directory.Name) } } @@ -502,11 +502,11 @@ switch ($Action) { } finally { if ($selectedSuite -eq 'review-candidate-verifier') { $runDirectories = @( - Get-ChildItem $output -Directory -ErrorAction SilentlyContinue | + Get-ChildItem -LiteralPath $output -Directory -ErrorAction SilentlyContinue | Where-Object { -not $existingRunDirectoryNames.Contains($_.Name) } ) if ($runDirectories.Count -eq 1 -and - (Test-Path (Join-Path $runDirectories[0].FullName 'results.jsonl'))) { + (Test-Path -LiteralPath (Join-Path $runDirectories[0].FullName 'results.jsonl'))) { @{ evals = @(@{ variant = 'current' @@ -515,7 +515,7 @@ switch ($Action) { runs = $runs threshold = $threshold }) - } | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $runDirectories[0].FullName 'plan-snapshot.json') + } | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath (Join-Path $runDirectories[0].FullName 'plan-snapshot.json') } elseif ($invocationCompleted) { throw 'Expected one completed component output directory with results.jsonl.' } @@ -523,7 +523,7 @@ switch ($Action) { } if ($assertsResults) { $newRunDirectories = @( - Get-ChildItem $output -Directory -ErrorAction SilentlyContinue | + Get-ChildItem -LiteralPath $output -Directory -ErrorAction SilentlyContinue | Where-Object { -not $existingRunDirectoryNames.Contains($_.Name) } ) if ($newRunDirectories.Count -ne 1) { diff --git a/eng/skill-evals/test_assert_results.ps1 b/eng/skill-evals/test_assert_results.ps1 index a3b785e1e259..379ff76549e6 100644 --- a/eng/skill-evals/test_assert_results.ps1 +++ b/eng/skill-evals/test_assert_results.ps1 @@ -112,6 +112,15 @@ try { throw 'A passing generic LLM suite no longer reports its aggregate threshold gate.' } + $literalRun = Join-Path $output 'run-[1]' + Move-Item -LiteralPath $run -Destination $literalRun + try { + & $assertResults -RunDirectory $literalRun + Write-Host 'LiteralRunDirectoryWithBrackets passed.' + } finally { + Move-Item -LiteralPath $literalRun -Destination $run + } + Reset-Results Write-Results -Variant skilled -Score 0.8 Assert-Throws { diff --git a/eng/skill-evals/test_run.ps1 b/eng/skill-evals/test_run.ps1 index 75b1eaaebe8c..dc6de9b9363f 100644 --- a/eng/skill-evals/test_run.ps1 +++ b/eng/skill-evals/test_run.ps1 @@ -129,9 +129,9 @@ if ($args[0] -eq 'eval' -and ($args -join ' ') -like '*review-candidate-verifier hadExecutionErrors = $false }) $rows | ForEach-Object { $_ | ConvertTo-Json -Depth 10 -Compress } | - Set-Content (Join-Path $run 'results.jsonl') + Set-Content -LiteralPath (Join-Path $run 'results.jsonl') } else { - Set-Content (Join-Path $run 'results.jsonl') '' + Set-Content -LiteralPath (Join-Path $run 'results.jsonl') '' } } if ($env:SKILL_EVAL_FAKE_EXIT_CODE) { @@ -282,7 +282,7 @@ stimuli: Assert-True ($specializedInvocation -contains '--eval-spec') 'Specialized run omitted --eval-spec.' foreach ($smoke in @($false, $true)) { - $componentOutput = Join-Path $testRoot "component-$smoke" + $componentOutput = Join-Path $testRoot "component-[$smoke]" New-Item -ItemType Directory -Path (Join-Path $componentOutput '2025-12-31T00-00-00') -Force | Out-Null $options = @{ Suite = 'review-candidate-verifier'; Vally = $fakeVally; VallyPrefix = @(); OutputDirectory = $componentOutput } if ($smoke) { @@ -291,7 +291,7 @@ stimuli: & $runner Run @options $componentRun = Read-Invocation Assert-True ($componentRun[0] -eq 'eval') 'Component run used a skill comparison experiment.' - $plan = Get-Content (Join-Path $componentOutput '2026-01-01T00-00-00/plan-snapshot.json') -Raw | ConvertFrom-Json + $plan = Get-Content -LiteralPath (Join-Path $componentOutput '2026-01-01T00-00-00/plan-snapshot.json') -Raw | ConvertFrom-Json $runs = if ($smoke) { 1 } else { 5 } Assert-True ($plan.evals[0].runs -eq $runs) 'Component plan has the wrong repeat count.' Assert-True ($componentRun[([array]::IndexOf($componentRun, '--runs') + 1)] -eq "$runs") 'Component invocation has the wrong repeat count.' From 89ac1574fd6bb4a9bef796a08753c89a103bdb15 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Sun, 15 Nov 2026 17:19:09 -0600 Subject: [PATCH 20/23] Assert only the selected evaluation variant Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/README.md | 2 ++ eng/skill-evals/assert_results.ps1 | 10 +++++++--- eng/skill-evals/run.ps1 | 17 ++++++++++++++++- eng/skill-evals/test_assert_results.ps1 | 21 +++++++++++++++++++++ eng/skill-evals/test_run.ps1 | 23 +++++++++++++++++++++-- 5 files changed, 67 insertions(+), 6 deletions(-) diff --git a/eng/skill-evals/README.md b/eng/skill-evals/README.md index 13d328e1c337..7ba8da3843a4 100644 --- a/eng/skill-evals/README.md +++ b/eng/skill-evals/README.md @@ -167,6 +167,8 @@ That plan reflects the selected YAML and CLI runs/threshold overrides. For the verifier suite, smoke selects one repeat per case and checks trial completion, grader scores, and read-integrity receipts without enforcing the multi-trial per-stimulus disposition threshold. +Experiment runs with `--variant skilled` or `--variant=skilled` check only the +selected variant; without this option, both baseline and skilled are required. ## Hosted entry point diff --git a/eng/skill-evals/assert_results.ps1 b/eng/skill-evals/assert_results.ps1 index febefc1bf36c..aad053a0ee60 100644 --- a/eng/skill-evals/assert_results.ps1 +++ b/eng/skill-evals/assert_results.ps1 @@ -4,7 +4,9 @@ param( [string]$OutputDirectory, [Parameter(Mandatory = $true, ParameterSetName = 'Run')] - [string]$RunDirectory + [string]$RunDirectory, + + [string]$Variant ) $ErrorActionPreference = 'Stop' @@ -23,7 +25,7 @@ if ($RunDirectory) { if (-not $RunDirectory -and $runDirectories.Count -gt 0 -and @($runDirectories | Where-Object { Test-Path -LiteralPath (Join-Path $_.FullName 'plan-snapshot.json') }).Count -eq 0) { foreach ($directory in $runDirectories) { - & $PSCommandPath -OutputDirectory $directory.FullName + & $PSCommandPath -OutputDirectory $directory.FullName -Variant $Variant } return } @@ -40,7 +42,9 @@ if (-not (Test-Path -LiteralPath $snapshotPath -PathType Leaf)) { $snapshot = Get-Content -LiteralPath $snapshotPath -Raw | ConvertFrom-Json -Depth 100 $scoresByVariant = @{} $plansByVariant = @{} -$variants = if ($snapshot.evals.Count -eq 1 -and $snapshot.evals[0].variant -eq 'current') { +$variants = if ($Variant) { + @($Variant) +} elseif ($snapshot.evals.Count -eq 1 -and $snapshot.evals[0].variant -eq 'current') { @('current') } else { @('baseline', 'skilled') diff --git a/eng/skill-evals/run.ps1 b/eng/skill-evals/run.ps1 index c63c38bac04a..77c12ab15a21 100644 --- a/eng/skill-evals/run.ps1 +++ b/eng/skill-evals/run.ps1 @@ -487,6 +487,21 @@ switch ($Action) { } $vallyArguments += $Arguments + $assertOptions = @{} + if ($vallyArguments[0] -eq 'experiment') { + for ($index = 0; $Arguments -and $index -lt $Arguments.Count; $index++) { + if ($Arguments[$index] -match '^--variant(?:=(.*))?$') { + $assertOptions.Variant = if ($Arguments[$index].Contains('=')) { + $Matches[1] + } else { + if (++$index -ge $Arguments.Count) { + throw 'Missing value for --variant.' + } + $Arguments[$index] + } + } + } + } $assertsResults = ($selectedSuite -eq 'review-candidate-verifier' -or $vallyArguments[0] -eq 'experiment') -and $Arguments -notcontains '--dry-run' $existingRunDirectoryNames = [Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal) @@ -529,7 +544,7 @@ switch ($Action) { if ($newRunDirectories.Count -ne 1) { throw "Expected one new Vally run directory under '$output'; found $($newRunDirectories.Count)." } - & (Join-Path $PSScriptRoot 'assert_results.ps1') -RunDirectory $newRunDirectories[0].FullName + & (Join-Path $PSScriptRoot 'assert_results.ps1') -RunDirectory $newRunDirectories[0].FullName @assertOptions if ($script:vallyExitCode -eq 1) { Write-Warning 'Vally exited with code 1. Complete primary trials passed the applicable result-set checks.' } diff --git a/eng/skill-evals/test_assert_results.ps1 b/eng/skill-evals/test_assert_results.ps1 index 379ff76549e6..3b6a1496e628 100644 --- a/eng/skill-evals/test_assert_results.ps1 +++ b/eng/skill-evals/test_assert_results.ps1 @@ -121,6 +121,27 @@ try { Move-Item -LiteralPath $literalRun -Destination $run } + $snapshotPath = Join-Path $run 'plan-snapshot.json' + $fullSnapshot = Get-Content -LiteralPath $snapshotPath -Raw + try { + $snapshot = $fullSnapshot | ConvertFrom-Json + $snapshot.evals = @($snapshot.evals | Where-Object variant -eq 'skilled') + $snapshot | ConvertTo-Json -Depth 10 | Set-Content -LiteralPath $snapshotPath + Assert-Throws { + & $assertResults -RunDirectory $run + } "Expected exactly one 'baseline' plan; found 0" 'A single variant was accepted without explicit selection.' + Write-Host 'SingleVariantRequiresSelection passed.' + & $assertResults -RunDirectory $run -Variant skilled + & $assertResults -OutputDirectory $output -Variant skilled + Write-Host 'SelectedSkilledVariant passed.' + Assert-Throws { + & $assertResults -RunDirectory $run -Variant baseline + } "Expected exactly one 'baseline' plan; found 0" 'A mismatched selected variant was accepted.' + Write-Host 'SelectedVariantMustMatchPlan passed.' + } finally { + Set-Content -LiteralPath $snapshotPath $fullSnapshot + } + Reset-Results Write-Results -Variant skilled -Score 0.8 Assert-Throws { diff --git a/eng/skill-evals/test_run.ps1 b/eng/skill-evals/test_run.ps1 index dc6de9b9363f..789c7fb4884c 100644 --- a/eng/skill-evals/test_run.ps1 +++ b/eng/skill-evals/test_run.ps1 @@ -72,12 +72,20 @@ if ($args[0] -eq 'experiment' -and $args -notcontains '--dry-run') { $output = $args[([array]::IndexOf($args, '--output-dir') + 1)] $run = Join-Path $output ('experiment-' + [guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $run -Force | Out-Null + $variants = @('baseline', 'skilled') + for ($index = 0; $index -lt $args.Count; $index++) { + if ($args[$index] -eq '--variant') { + $variants = @($args[++$index]) + } elseif ($args[$index] -like '--variant=*') { + $variants = @($args[$index].Substring('--variant='.Length)) + } + } @{ - evals = @('baseline', 'skilled' | ForEach-Object { + evals = @($variants | ForEach-Object { @{ variant = $_; plannedStimulusNames = @('s'); plannedStimulusCount = 1; runs = 1; threshold = 0 } }) } | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $run 'plan-snapshot.json') - foreach ($variant in 'baseline', 'skilled') { + foreach ($variant in $variants) { New-Item -ItemType Directory -Path (Join-Path $run $variant) | Out-Null @{ type = 'trial-result'; variant = $variant; stimulus = 's'; status = 'success'; gradeResult = @{ score = 1 } } | ConvertTo-Json -Depth 10 -Compress | @@ -218,6 +226,17 @@ stimuli: 'Custom validation could invoke models.' ) + foreach ($syntax in @('Separate', 'Equals')) { + $variantArguments = if ($syntax -eq 'Separate') { @('--variant', 'skilled') } else { @('--variant=skilled') } + & $runner Run -Suite review-public-api -Vally $fakeVally -VallyPrefix @() ` + -OutputDirectory (Join-Path $testRoot "selected-variant-$syntax") -Arguments $variantArguments + $invocation = Read-Invocation + foreach ($argument in $variantArguments) { + Assert-True ($invocation -contains $argument) 'Selected variant was not forwarded to Vally.' + } + Write-Host "SelectedVariant${syntax}Syntax passed." + } + $validationRoot = Join-Path $testRoot 'validation-root' $validationEvalRoot = Join-Path $validationRoot 'eng/skill-evals' New-Item -ItemType Directory -Force -Path ` From 5f4daf2e39a6d61c6fead6c2bd642f1559504555 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Mon, 16 Nov 2026 08:59:47 -0600 Subject: [PATCH 21/23] Limit result assertions to complete single-eval runs Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/README.md | 3 ++- eng/skill-evals/run.ps1 | 9 +++++-- eng/skill-evals/test_run.ps1 | 46 +++++++++++++++++++++++++++++++++++- 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/eng/skill-evals/README.md b/eng/skill-evals/README.md index 7ba8da3843a4..3a55a1950c7e 100644 --- a/eng/skill-evals/README.md +++ b/eng/skill-evals/README.md @@ -158,7 +158,7 @@ Run these commands from any directory: Without a suite or explicit experiment, `Run` dispatches each standard suite into its own output subdirectory. This includes the direct verifier component suite. -Each experiment or direct component `Run` checks its own new run directory with +Each single-eval experiment or direct component `Run` checks its own new run directory with `assert_results.ps1` before it returns. A Vally exit code of 1 is accepted only after those checks pass; any failed check stops the run, including in the all-suite dispatch. A direct component run writes a plan beside Vally's @@ -169,6 +169,7 @@ completion, grader scores, and read-integrity receipts without enforcing the multi-trial per-stimulus disposition threshold. Experiment runs with `--variant skilled` or `--variant=skilled` check only the selected variant; without this option, both baseline and skilled are required. +Experiments without `-Suite`/`-Eval`, or with `--eval-filter` or `--shard`, skip result-set checks and return Vally's exit status. ## Hosted entry point diff --git a/eng/skill-evals/run.ps1 b/eng/skill-evals/run.ps1 index 77c12ab15a21..f46435be21b8 100644 --- a/eng/skill-evals/run.ps1 +++ b/eng/skill-evals/run.ps1 @@ -502,10 +502,15 @@ switch ($Action) { } } } - $assertsResults = ($selectedSuite -eq 'review-candidate-verifier' -or $vallyArguments[0] -eq 'experiment') -and + $assertsResults = ($selectedSuite -eq 'review-candidate-verifier' -or + ($vallyArguments[0] -eq 'experiment' -and $resolvedEval -and + -not ($Arguments -match '^--(?:eval-filter|shard)(?:=|$)'))) -and $Arguments -notcontains '--dry-run' + if ($vallyArguments[0] -eq 'experiment' -and -not $assertsResults -and $Arguments -notcontains '--dry-run') { + Write-Warning "Result-set checks were not applied; Vally's exit status is returned. Use -Suite to check one eval; if --compare reports conflicting judge models, add --judge-model." + } $existingRunDirectoryNames = [Collections.Generic.HashSet[string]]::new([StringComparer]::Ordinal) - if (($selectedSuite -eq 'review-candidate-verifier' -or $assertsResults) -and (Test-Path -LiteralPath $output -PathType Container)) { + if ($assertsResults -and (Test-Path -LiteralPath $output -PathType Container)) { foreach ($directory in Get-ChildItem -LiteralPath $output -Directory -ErrorAction SilentlyContinue) { [void]$existingRunDirectoryNames.Add($directory.Name) } diff --git a/eng/skill-evals/test_run.ps1 b/eng/skill-evals/test_run.ps1 index 789c7fb4884c..3834f353c2fb 100644 --- a/eng/skill-evals/test_run.ps1 +++ b/eng/skill-evals/test_run.ps1 @@ -82,7 +82,7 @@ if ($args[0] -eq 'experiment' -and $args -notcontains '--dry-run') { } @{ evals = @($variants | ForEach-Object { - @{ variant = $_; plannedStimulusNames = @('s'); plannedStimulusCount = 1; runs = 1; threshold = 0 } + @{ variant = $_; plannedStimulusNames = @('s'); plannedStimulusCount = 1; runs = 1; threshold = $(if ($env:SKILL_EVAL_FAKE_EXPERIMENT_INVALID) { 'invalid' } else { 0 }) } }) } | ConvertTo-Json -Depth 10 | Set-Content (Join-Path $run 'plan-snapshot.json') foreach ($variant in $variants) { @@ -237,6 +237,50 @@ stimuli: Write-Host "SelectedVariant${syntax}Syntax passed." } + $experimentCheckFailures = [Collections.Generic.List[string]]::new() + foreach ($case in @( + @{ Name = 'UnselectedExperiment'; Selection = ''; Arguments = '@()' }, + @{ Name = 'SeparateEvalFilter'; Selection = '-Suite review-public-api'; Arguments = "@('--eval-filter', 'other/eval.vally.yaml')" }, + @{ Name = 'EqualsEvalFilter'; Selection = '-Suite review-public-api'; Arguments = "@('--eval-filter=other/eval.vally.yaml')" }, + @{ Name = 'SeparateShard'; Selection = '-Suite review-public-api'; Arguments = "@('--shard', '1/2', '--run-id', 'test')" }, + @{ Name = 'EqualsShard'; Selection = '-Suite review-public-api'; Arguments = "@('--shard=1/2', '--run-id=test')" }, + @{ Name = 'DryRunExperiment'; Selection = '-Suite review-public-api'; Arguments = "@('--dry-run')" }, + @{ Name = 'SelectedExperimentChecked'; Selection = '-Suite review-public-api'; Arguments = '@()'; Checked = $true }, + @{ Name = 'SelectedEvalChecked'; Selection = "-Eval 'eng/skill-evals/review-public-api/eval.vally.yaml'"; Arguments = '@()'; Checked = $true } + )) { + foreach ($exitCode in @(0, 1)) { + $env:SKILL_EVAL_FAKE_EXPERIMENT_INVALID = 'true' + $env:SKILL_EVAL_FAKE_EXIT_CODE = "$exitCode" + try { + $caseOutput = Join-Path $testRoot "$($case.Name)-$exitCode" + $command = "& '$runner' Run -Experiment '$customExperiment' $($case.Selection) " + + "-Vally '$fakeVally' -VallyPrefix @() -OutputDirectory '$caseOutput' " + + "-Arguments $($case.Arguments); exit `$LASTEXITCODE" + $messages = (& pwsh -NoProfile -Command $command 2>&1 | Out-String) + $actualExitCode = $LASTEXITCODE + } finally { + Remove-Item Env:SKILL_EVAL_FAKE_EXPERIMENT_INVALID + Remove-Item Env:SKILL_EVAL_FAKE_EXIT_CODE + } + $checked = $case.ContainsKey('Checked') + $expectedExitCode = if ($checked) { 1 } else { $exitCode } + $hasCheckFailure = $messages -like "*plan has an invalid threshold*" + $hasWarning = $messages -like '*result-set checks were not applied*' + $expectsWarning = -not $checked -and $case.Name -ne 'DryRunExperiment' + if ($actualExitCode -ne $expectedExitCode -or $hasCheckFailure -ne $checked -or + $hasWarning -ne $expectsWarning) { + $experimentCheckFailures.Add( + "$($case.Name)Exit$exitCode expected exit $expectedExitCode, checked=$checked, warning=$expectsWarning; " + + "got exit $actualExitCode, checked=$hasCheckFailure, warning=$hasWarning. $messages" + ) + Write-Host "$($case.Name)Exit$exitCode failed." + } else { + Write-Host "$($case.Name)Exit$exitCode passed." + } + } + } + Assert-True ($experimentCheckFailures.Count -eq 0) ($experimentCheckFailures -join "`n") + $validationRoot = Join-Path $testRoot 'validation-root' $validationEvalRoot = Join-Path $validationRoot 'eng/skill-evals' New-Item -ItemType Directory -Force -Path ` From f8a44b43bdd30065dd2388f86a4ff27cfbc2cf67 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Mon, 16 Nov 2026 09:08:40 -0600 Subject: [PATCH 22/23] Leave existing component output untouched during dry runs Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/run.ps1 | 2 +- eng/skill-evals/test_run.ps1 | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/eng/skill-evals/run.ps1 b/eng/skill-evals/run.ps1 index f46435be21b8..d4f25db9c7f6 100644 --- a/eng/skill-evals/run.ps1 +++ b/eng/skill-evals/run.ps1 @@ -520,7 +520,7 @@ switch ($Action) { Invoke-VallyIsolated $vallyArguments -TolerateExitOne:$assertsResults $invocationCompleted = $true } finally { - if ($selectedSuite -eq 'review-candidate-verifier') { + if ($selectedSuite -eq 'review-candidate-verifier' -and $assertsResults) { $runDirectories = @( Get-ChildItem -LiteralPath $output -Directory -ErrorAction SilentlyContinue | Where-Object { -not $existingRunDirectoryNames.Contains($_.Name) } diff --git a/eng/skill-evals/test_run.ps1 b/eng/skill-evals/test_run.ps1 index 3834f353c2fb..e788c828685e 100644 --- a/eng/skill-evals/test_run.ps1 +++ b/eng/skill-evals/test_run.ps1 @@ -92,7 +92,7 @@ if ($args[0] -eq 'experiment' -and $args -notcontains '--dry-run') { Set-Content (Join-Path $run "$variant/results.jsonl") } } -if ($args[0] -eq 'eval' -and ($args -join ' ') -like '*review-candidate-verifier*') { +if ($args[0] -eq 'eval' -and ($args -join ' ') -like '*review-candidate-verifier*' -and $args -notcontains '--dry-run') { $output = $args[([array]::IndexOf($args, '--output-dir') + 1)] $run = Join-Path $output '2026-01-01T00-00-00' New-Item -ItemType Directory -Path $run -Force | Out-Null @@ -362,6 +362,20 @@ stimuli: 'Component plan lost its per-case 4/5 disposition gate.' ) } + $componentDryRunOutput = Join-Path $testRoot 'component-dry-run' + $previousComponentRun = Join-Path $componentDryRunOutput 'previous-run' + New-Item -ItemType Directory -Path $previousComponentRun -Force | Out-Null + Set-Content (Join-Path $previousComponentRun 'results.jsonl') 'previous results' + $previousPlanPath = Join-Path $previousComponentRun 'plan-snapshot.json' + Set-Content $previousPlanPath 'previous plan' + $previousPlan = Get-Content $previousPlanPath -Raw + & $runner Run -Suite review-candidate-verifier -Vally $fakeVally -VallyPrefix @() ` + -OutputDirectory $componentDryRunOutput -Arguments @('--dry-run') + Assert-True ((Get-Content $previousPlanPath -Raw) -eq $previousPlan) ( + 'Component dry-run overwrote an existing plan snapshot.' + ) + Write-Host 'ComponentDryRunPreservesExistingPlan passed.' + function Assert-CustomComponentPlan { param( [string]$Scenario, From 22456047e888437a011522033917e6f4bb389505 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Mon, 16 Nov 2026 09:30:01 -0600 Subject: [PATCH 23/23] Reject experiment-only options before all-suite runs Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- eng/skill-evals/README.md | 1 + eng/skill-evals/run.ps1 | 9 +++++ eng/skill-evals/test_run.ps1 | 64 ++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/eng/skill-evals/README.md b/eng/skill-evals/README.md index 3a55a1950c7e..f160daa8c767 100644 --- a/eng/skill-evals/README.md +++ b/eng/skill-evals/README.md @@ -158,6 +158,7 @@ Run these commands from any directory: Without a suite or explicit experiment, `Run` dispatches each standard suite into its own output subdirectory. This includes the direct verifier component suite. +Experiment-only options require `-Suite` or `-Experiment` and are rejected before all-suite dispatch. Each single-eval experiment or direct component `Run` checks its own new run directory with `assert_results.ps1` before it returns. A Vally exit code of 1 is accepted only after those checks pass; any failed check stops the run, including in the diff --git a/eng/skill-evals/run.ps1 b/eng/skill-evals/run.ps1 index d4f25db9c7f6..0f3603f2674c 100644 --- a/eng/skill-evals/run.ps1 +++ b/eng/skill-evals/run.ps1 @@ -365,6 +365,15 @@ switch ($Action) { } if (-not $resolvedEval -and -not $hasExplicitExperiment) { + $experimentOnlyOptions = @( + $Arguments | + Where-Object { $_ -match '^--(?:variant|eval-filter|shard|shard-strategy|compare|dry-run)(?:=|$)' } | + ForEach-Object { ($_ -split '=', 2)[0] } | + Select-Object -Unique + ) + if ($experimentOnlyOptions.Count -gt 0) { + throw "Options $($experimentOnlyOptions -join ', ') require -Suite or -Experiment." + } foreach ($directory in Get-ChildItem $evalRoot -Directory) { if (Test-Path (Join-Path $directory.FullName 'eval.vally.yaml')) { $suiteOutput = Join-Path $output $directory.Name diff --git a/eng/skill-evals/test_run.ps1 b/eng/skill-evals/test_run.ps1 index e788c828685e..9249917f8f88 100644 --- a/eng/skill-evals/test_run.ps1 +++ b/eng/skill-evals/test_run.ps1 @@ -237,6 +237,70 @@ stimuli: Write-Host "SelectedVariant${syntax}Syntax passed." } + $allOptionsRoot = Join-Path $testRoot 'all-options-root' + $allOptionsEvalRoot = Join-Path $allOptionsRoot 'eng/skill-evals' + foreach ($suite in @('port-components-platform-api', 'review-candidate-verifier')) { + New-Item -ItemType Directory -Path (Join-Path $allOptionsEvalRoot $suite) -Force | Out-Null + } + Set-Content (Join-Path $allOptionsEvalRoot 'port-components-platform-api/eval.vally.yaml') 'name: port-components-platform-api' + Copy-Item (Join-Path $allComponentDirectory 'eval.vally.yaml') ( + Join-Path $allOptionsEvalRoot 'review-candidate-verifier/eval.vally.yaml' + ) + $allOptionsFailures = [Collections.Generic.List[string]]::new() + foreach ($option in @( + @{ Name = 'variant'; Value = 'skilled' }, + @{ Name = 'eval-filter'; Value = 'other/eval.vally.yaml' }, + @{ Name = 'shard'; Value = '1/2' }, + @{ Name = 'shard-strategy'; Value = 'by-stimulus' }, + @{ Name = 'compare'; Value = $null }, + @{ Name = 'dry-run'; Value = $null } + )) { + foreach ($syntax in @('Separate', 'Equals')) { + $optionArguments = if ($syntax -eq 'Equals') { + @("--$($option.Name)=$(if ($null -eq $option.Value) { 'true' } else { $option.Value })") + } elseif ($null -eq $option.Value) { + @("--$($option.Name)") + } else { + @("--$($option.Name)", $option.Value) + } + Remove-Item $record -ErrorAction SilentlyContinue + $message = '' + try { + & $runner Run -Root $allOptionsRoot -Vally $fakeVally -VallyPrefix @() ` + -OutputDirectory (Join-Path $testRoot "all-options-$($option.Name)-$syntax") ` + -Arguments $optionArguments + } catch { + $message = $_.Exception.Message + } + $caseName = "AllSuiteRejects$($option.Name)${syntax}Syntax" + if ($message -notlike "*--$($option.Name)*" -or + $message -notlike '*-Suite*' -or $message -notlike '*-Experiment*' -or + (Test-Path $record)) { + $allOptionsFailures.Add("$caseName did not reject the option before invoking Vally. Error: $message") + Write-Host "$caseName failed." + } else { + Write-Host "$caseName passed." + } + } + } + Assert-True ($allOptionsFailures.Count -eq 0) ($allOptionsFailures -join "`n") + + Remove-Item $record -ErrorAction SilentlyContinue + & $runner Run -Root $allOptionsRoot -Vally $fakeVally -VallyPrefix @() ` + -OutputDirectory (Join-Path $testRoot 'all-options-allowed') ` + -Arguments @('--judge-model', 'test-model') + $allOptionsInvocations = @(Read-Invocations) + Assert-True ($allOptionsInvocations.Count -eq 2 -and + $allOptionsInvocations[0].Arguments[0] -eq 'experiment' -and + $allOptionsInvocations[1].Arguments[0] -eq 'eval') ( + 'An allowed all-suite option did not reach both the experiment and component suites.' + ) + foreach ($invocation in $allOptionsInvocations) { + Assert-True ($invocation.Arguments -contains '--judge-model' -and + $invocation.Arguments -contains 'test-model') 'The allowed all-suite option was not forwarded.' + } + Write-Host 'AllSuiteAllowsJudgeModel passed.' + $experimentCheckFailures = [Collections.Generic.List[string]]::new() foreach ($case in @( @{ Name = 'UnselectedExperiment'; Selection = ''; Arguments = '@()' },