maf-workflow-smoke-tester
Skill14 starsChanged 3 months agoMITView on GitHub
Generates structural smoke tests for MAF 1.3.0 workflow patterns. Five categories: fan-out/fan-in completeness, session round-trip, streaming, structured output, tool invocation. Catches the silent runtime failures static analysis cannot.
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
When you call MafNewExecutor, the generated *Tests.cs already includes the reflection-based "fan-out handler returns Task<T>" structural …
- Very specific: line 147
All templates assume an IChatClient mock — no Azure credentials needed.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
workflow-smoke-tester
Purpose
dotnet build passing does not mean the code works. The fan-in starvation bug is the canonical example: builds green, runs silently wrong, no error. Smoke tests add a fast, credential-free runtime check for the class of failures that static analysis alone cannot catch.
These tests use mock chat clients — no Azure credentials required, no network calls. They verify structural correctness, not AI output quality.
⚡ The fastest path — use the MCP tools
The maf-autopilot MCP server now covers most of the smoke-test surface automatically. Prefer these:
| What you want to verify | Use this tool |
Every fan-out [MessageHandler] returns Task<T> | MafValidateFanOut(repoPath) |
| Workflow topology can complete (no silent starvation) | MafSimulateWorkflow(repoPath) |
| New agent/executor scaffold ships with smoke test | MafNewAgent / MafNewExecutor |
| Agent prompt quality (injection, refusals, bloat) | MafLintAgentPrompt(repoPath) |
| Single-command health letter | MafDoctor(repoPath) — covers all of above |
When you call MafNewExecutor, the generated *Tests.cs already includes the reflection-based "fan-out handler returns Task<T>" structural assertion — that's the canonical smoke-test pattern. It's compile-validated against AntiPatternScannerTool and FanOutValidatorTool by the project's own dogfood test suite.
When to use the manual templates below
Reach for them when:
- The MCP tools are unavailable.
- The codebase needs one of the patterns the tools don't yet cover (session round-trip, streaming, structured output, tool approval).
- You want to drop a snippet directly into a PR review.
Pattern detection
# Fan-out/fan-in pattern
Select-String -Path "src/**/*.cs" -Pattern "AddFanOutEdge" -Recurse -List
# Streaming
Select-String -Path "src/**/*.cs" -Pattern "RunStreamingAsync" -Recurse -List
# Structured output
Select-String -Path "src/**/*.cs" -Pattern "RunAsync<" -Recurse -List
# Tool invocation / approval
Select-String -Path "src/**/*.cs" -Pattern "ApprovalRequiredAIFunction|FunctionApprovalRequestContent" -Recurse -List
# Session round-trip
Select-String -Path "src/**/*.cs" -Pattern "CreateSessionAsync|SerializeSessionAsync" -Recurse -ListGenerate smoke tests only for patterns actually present.
Smoke test templates
⚠️ Templates below are illustrative. Only Template 1 (fan-out shape) is compile-validated automatically — the rest are reference snippets you must adapt to your project's exact types. If a template fails to compile against a future MAF minor, file a registry-suggestion issue.
Template 1 — Fan-out / fan-in structural smoke test (compile-validated equivalent: MafNewExecutor output)
[Fact]
public void FanOutHandlers_AllReturnGenericTask()
{
// Catches the silent-starvation pattern at build time via reflection.
// For full coverage, also run `MafValidateFanOut(repoPath)`.
var executorTypes = typeof(MyWorkflowMarker).Assembly.GetTypes()
.Where(t => typeof(Executor).IsAssignableFrom(t))
.ToList();
foreach (var t in executorTypes)
{
foreach (var method in t.GetMethods(BindingFlags.Public | BindingFlags.Instance))
{
if (method.GetCustomAttribute<MessageHandlerAttribute>() is null) continue;
var name = method.ReturnType.Name;
Assert.True(
name.StartsWith("Task`") || name.StartsWith("ValueTask`")
|| name.StartsWith("IAsyncEnumerable`"),
$"{t.Name}.{method.Name} returns {method.ReturnType.FullName} — fan-out handlers must return Task<T> / ValueTask<T> / IAsyncEnumerable<T>.");
}
}
}Template 2 — Session round-trip
[Fact]
public async Task Session_SerialisesAndRehydratesAsync()
{
var agent = BuildAgentWithMockClient();
var session = await agent.CreateSessionAsync();
var blob = await agent.SerializeSessionAsync(session);
Assert.False(string.IsNullOrEmpty(blob));
var restored = await agent.DeserializeSessionAsync(blob);
Assert.NotNull(restored);
}Template 3 — Streaming smoke test
[Fact]
public async Task RunStreamingAsync_YieldsAtLeastOneUpdate()
{
var agent = BuildAgentWithMockClient();
var updates = new List<AgentResponseUpdate>();
await foreach (var u in agent.RunStreamingAsync("hello"))
updates.Add(u);
Assert.NotEmpty(updates);
}Template 4 — Structured output
[Fact]
public async Task RunAsyncT_ReturnsTypedResult()
{
var agent = BuildAgentWithMockClient();
var resp = await agent.RunAsync<MyStructuredResult>("query");
Assert.NotNull(resp);
Assert.NotNull(resp.Result);
}Template 5 — Tool approval flow
[Fact]
public async Task ToolApproval_FlowsToApprovalContent()
{
var agent = BuildAgentWithMockClient(toolRequiresApproval: true);
var response = await agent.RunAsync("call the tool");
var approvalRequest = response.Messages
.SelectMany(m => m.Contents)
.OfType<FunctionApprovalRequestContent>()
.FirstOrDefault();
Assert.NotNull(approvalRequest);
}Wiring tips
- All templates assume an
IChatClientmock — no Azure credentials needed. Reuse theScriptedChatClientpattern emitted byMafNewAgent. - Mark the test class
[Trait("Category", "Smoke")]so CI can run smoke tests separately from end-to-end tests. - Smoke tests should complete in < 1 second each — they're structural, not behavioural.
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- cs0618-hunterSkill
- dotnet-inspectSkill
- maf-anti-pattern-scannerSkill
- maf-doctor-self-evolutionSkill
- maf-fan-out-validatorSkill
- maf-from-semantic-kernelSkill
- maf-issue-reporterSkill
- maf-migration-guideSkill
- maf-migration-plan-creatorSkill
- maf-migration-retrospectiveSkill
- maf-obsolete-api-registrySkill
- maf-release-watcherSkill
- maf-remediation-playbookSkill
- nuget-diff-analyzerSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

