Skip to content

feat(copilot): add evidence-based Copilot customizations#690

Open
YunchuWang wants to merge 15 commits intomainfrom
auto/copilot-customization-20260326
Open

feat(copilot): add evidence-based Copilot customizations#690
YunchuWang wants to merge 15 commits intomainfrom
auto/copilot-customization-20260326

Conversation

@YunchuWang
Copy link
Copy Markdown
Member

Summary

Evidence-based GitHub Copilot customization files generated by deep repository inspection of microsoft/durabletask-dotnet. Every rule is justified by direct repository evidence (code comments, CI workflows, commit patterns). No boilerplate. No fabricated paths or commands. All new rules conflict-checked against the existing copilot-instructions.md.

What Was Added / Modified

.github/copilot-instructions.md — IMPROVED

  • Added: Replay Determinism section — the single most critical invariant in this repo. Evidence: // IMPORTANT comments in TaskActivityContext.cs and TypeExtensions.cs; existing FuncTaskOrchestrator and TaskOrchestrationContext abstractions. Copilot previously had no awareness of the replay constraint and would suggest DateTime.Now or Guid.NewGuid() inside orchestrators.
  • Added: gRPC/Protobuf layer rules — proto field number permanence, build-time stub generation via Grpc.Tools, refresh-protos.ps1 workflow. Evidence: src/Grpc/orchestrator_service.proto, .github/workflows/*.yml.
  • Added: Path-change confirmation rule — before renaming any referenced file path, confirm with the user. Evidence: src/Grpc/refresh-protos.ps1 references specific paths; previous issue with assumed paths.
  • Removed: ## Build and Test section — build/test commands belong in CI config, not in always-active Copilot instructions.

.github/copilot/instructions/analyzers-generators.md — CREATED

  • Scope: src/Analyzers/**, src/Generators/**, test/Analyzers.Tests/**, test/Generators.Tests/**
  • Rules: Compile-time-only components must not introduce runtime NuGet dependencies; any interface change in src/Abstractions/ that source generators implement must be reflected in generator output.
  • Evidence: // IMPORTANT: implemented by source generators in TaskActivityContext.cs; src/Generators/ and src/Analyzers/ directory structure.

.github/copilot/instructions/grpc-worker.md — CREATED

  • Scope: src/Grpc/**, src/Worker/**, src/InProcessTestHost/**, test/Grpc.IntegrationTests/**
  • Rules: Proto field numbers are permanent (removing/renumbering breaks wire compatibility with in-flight orchestrations); C# stubs are generated at build time by Grpc.Tools — do not commit them; integration tests use GrpcSidecarFixture / IntegrationTestBase.
  • Evidence: src/Grpc/orchestrator_service.proto, src/Grpc/refresh-protos.ps1, test/Grpc.IntegrationTests/ test infrastructure.

.github/skills/breaking-change-check/SKILL.md — CREATED

  • 6-step conditional playbook: identify changed API surface, verify all callers, check orchestration replay safety, check serialization compatibility, classify breaking change type (binary/source/behavioral), document in PR.
  • Evidence: // WARNING comment in JsonDataConverter.cs; breaking change policy linked in existing copilot-instructions.md; src/<area>/<area>.csproj <PackageId> pattern for shipped NuGet packages.
  • Invoked only when public/protected API surface is changing — not always applicable (skill, not global instruction).

.github/copilot/agents/copilot-customizer.md — CREATED

  • Interactive Copilot Chat agent for future use: analyze any repo and propose Copilot customizations with user approval.
  • Two-phase model (analyze→plan→STOP, then execute only after confirmation). Evidence-gated. Cost-model aware. Conflict-arbitration priority table.

Evidence Highlights

Finding Source
Orchestrators replay from history — determinism is a hard invariant TaskOrchestrationContext abstractions; FuncTaskOrchestrator; // IMPORTANT in TaskActivityContext.cs
Proto field numbers are permanent src/Grpc/orchestrator_service.proto field numbering
C# stubs are build-time generated, not committed src/Grpc/*.csproj references Grpc.Tools; no .cs files in src/Grpc/ that are stubs
Source generators implement abstract interfaces // IMPORTANT: implemented by source generators in TaskActivityContext.cs
Breaking change policy is enforced Existing copilot-instructions.md links dotnet/runtime breaking-change-rules

Conflict Check

All new rules were checked against the existing .github/copilot-instructions.md. No duplicates or contradictions introduced. The Replay Determinism and gRPC sections in copilot-instructions.md extend (not replace) the existing C# guidelines. Path-specific instructions apply only to their scoped directories and do not override global rules.

Maintenance Notes

  • Re-run copilot-customizer quarterly or after major architectural changes
  • Update analyzers-generators.md if new source generator projects are added
  • Update grpc-worker.md if the protobuf transport is replaced or supplemented
  • The breaking-change-check skill should be reviewed when the NuGet release process changes

Limitations

  • Instructions are based on a static snapshot of the repo at generation time
  • Path-specific instructions (.github/copilot/instructions/) require Copilot for Business or Enterprise tier
  • The copilot-customizer agent requires Copilot Chat with agent support enabled

Future Follow-ups

  • Most likely to save time: Replay Determinism rules — Copilot consistently suggests DateTime.Now in orchestrator contexts without this guidance
  • Most likely to go stale: refresh-protos.ps1 path reference (if proto tooling changes); Grpc.Tools package name
  • Intentionally omitted: Path-specific instructions for src/Clients/ and src/Extensions/ — insufficient evidence of rules that must not apply globally; AGENTS.md — no autonomous coding agents actively used in this repo's documented workflow
  • Next run focus: Monitor whether Copilot respects the applyTo globs on the path-specific instruction files; adjust scope patterns if needed

🤖 Generated with Claude Code via copilot-customizer skill

YunchuWang and others added 4 commits March 26, 2026 11:46
Generated by copilot-customizer skill after deep repository inspection.
Each file is justified by direct evidence from the codebase.

Changes:
- .github/copilot-instructions.md: Added two critical missing sections:
  (1) Replay Determinism invariant — the most important architectural
      constraint in this repo, absent from existing instructions.
      Evidence: replay model described in issue-fixer.agent.md,
      WARNING/IMPORTANT comments throughout src/.
  (2) gRPC/Protobuf layer rules — proto field number permanence,
      refresh-protos.ps1 workflow.
      Evidence: WARNING comment in JsonDataConverter.cs, refresh-protos.ps1.
  (3) Build and test commands — dotnet build/test with exact flags.
      Evidence: validate-build.yml CI workflow.

- .github/copilot/instructions/analyzers-generators.md: Path-specific
  rules for Roslyn analyzer and source generator code. Different runtime
  model (compile-time only), different test infrastructure, interface
  consistency constraint with Abstractions.
  Evidence: src/Analyzers/Analyzers.csproj (no runtime deps),
  IMPORTANT comment in TaskActivityContext.cs.

- .github/copilot/instructions/grpc-worker.md: Path-specific rules for
  gRPC proto changes, Worker dispatch loop concurrency constraints, and
  the correct pattern for writing integration tests.
  Evidence: IMPORTANT comment in TaskOrchestrationDispatcher.cs,
  WorkItemDispatcher.cs concurrency note, GrpcSidecarFixture pattern
  in test/Grpc.IntegrationTests/.

- .github/copilot/skills/breaking-change-check.md: Skill for systematic
  backward-compatibility verification before changing public APIs.
  Evidence: copilot-instructions.md already references breaking change
  rules but provides no structured process. PR template has a breaking
  change checklist. Commit history shows several breaking-change-related
  fixes (c299597, e427bbc, 781bb6e).

- .github/copilot/agents/copilot-customizer.md: Interactive Copilot Chat
  agent for future customization runs via @copilot-customizer.

Conflict check: No rules duplicated. No contradiction with existing
copilot-instructions.md or the three existing agents.

Co-Authored-By: Claude <noreply@anthropic.com>
Addressing review feedback on the initial customization commit:

1. copilot-instructions.md:
   - Remove '## Build and Test' section (commands not appropriate here;
     already covered in validate-build.yml which contributors can read)
   - Fix '## gRPC / Protobuf Layer': remove false claim that generated
     code lives in src/Grpc/Grpc/ — stubs are build-time generated,
     not committed. Update to accurate description.
   - Add path-change confirmation rule: before referencing or moving
     any file path, verify it exists and confirm with user.

2. .github/copilot/agents/copilot-customizer.md:
   - Rewrite in correct chatagent fence format matching the existing
     agents in this repo (issue-fixer.agent.md pattern).
   - Remove @copilot-customizer invocation syntax (Copilot does not
     support @agent-name mentions).
   - Remove @workspace references (not a supported mechanism in agents).
   - Broaden scope: works in Copilot coding agent context, not just
     VS Code Copilot Chat.
   - Add explicit path-verification rule before any file path is cited.

3. .github/skills/ (moved from .github/copilot/skills/):
   - breaking-change-check: moved to .github/skills/breaking-change-check/SKILL.md
     to match the correct GitHub Copilot skill directory format
     (skills live in named directories as SKILL.md, not flat .md files).

Co-Authored-By: Claude <noreply@anthropic.com>
1. Two-phase model (Issue #2):
   Added hard stop between Phase 1 (analyze+plan) and Phase 2 (execute).
   Agent now presents a plan and explicitly waits for user approval with
   a visible STOP marker before writing any file.

2. Evidence standard hardened (Issue #3):
   Defined exactly what counts as valid evidence (file:line+snippet,
   CI command, explicit code comment, CONTRIBUTING.md section, commit
   pattern). Listed explicit NOT VALID examples (inference, common
   practice, "likely"). Rule: no evidence → no rule, no file.

3. Path verification with fallback (Issue #4):
   Added mandatory path verification gate before writing any instruction.
   If path cannot be verified: do NOT include it, mark as
   UNVERIFIED PATH, ask user before proceeding.

4. Assessment format loosened (Issue #5):
   Fields in the plan output are now: only include if supported by
   hard evidence; write INSUFFICIENT EVIDENCE — omitted otherwise.
   Prevents filling-the-template behavior.

5. Priority model added (Issue #6):
   Explicit ordered decision tree (1→5): repo-wide instructions first,
   AGENTS.md second, path instructions third, skills fourth, agents last.
   Default: do less.

6. Skill/agent decision rules made deterministic (Issue #7):
   Replaced descriptive text with ALL-must-be-true checklists for when
   to create a skill and when to create an agent.

7. Post-run reflection required (Issue #8):
   Added mandatory Phase 3 post-run reflection covering: mistakes made,
   over-engineering avoided, hallucinations caught, agent spec improvement
   suggestions, stale risk. Required on every run.

8. Untestable instruction gate (Issue #9):
   Added explicit testability gate — if an instruction cannot be violated
   in a detectable way, it must not be written.

9. Commit fallback for missing git (Issue #10):
   Phase 2.4 now outputs a commit plan (files, message, concerns) when
   git is unavailable or commit fails, instead of silently failing.

10. Prohibited language list:
    Extended and applied as a hard gate — if prohibited language appears
    in an instruction, the instruction is deleted, not softened.

Co-Authored-By: Claude <noreply@anthropic.com>
Issue #1 (shell cmd over-reliance):
  Every shell block now has an "Else (no terminal)" fallback that
  instructs the agent to infer from visible context only and to
  explicitly label each inference — preventing fake command output.

Issue #3 (evidence anti-leak):
  Added Evidence Integrity section: do not fabricate file paths,
  line numbers, or snippets. If exact line unknown → cite file only.
  If snippet unavailable → state "snippet not verified". If nothing
  concrete → do not write the rule.

Issue #4 (rigid structure kills reasoning):
  Plan template changed from "Output this exact structure" to
  "Use this structure if applicable. Do NOT fabricate content to
  fill fields." Fields with no evidence write INSUFFICIENT EVIDENCE.
  Added TERMINAL ACCESS field so confidence level is explicit.

Issue #5 (no cost model):
  Added Cost Model section: each file adds maintenance cost,
  cognitive load, and contradiction risk. Rule: only add when
  value > long-term cost. This is now also a required field in
  the plan (Cost justification per proposed change).

Issue #6 (staleness not a decision condition):
  Staleness Filter is now a pre-write gate, not just post-run output.
  If a rule is stale-prone within 3 months → move to skill or omit.
  Stale risk is also a required field in the plan per proposed change.

Issue #7 (conflict arbitration incomplete):
  Added Conflict Resolution Priority table (1=copilot-instructions.md
  highest, 5=agents lowest). Each proposed change now includes
  "Authority level: [1-5]" in the plan. Never duplicate across levels.

Issue #8 ("under 100 lines" is arbitrary):
  Changed to "Prefer under 100 lines. If longer, justify why each
  section earns its place." Applied same principle to path
  instructions (<60), skills (<150).

Issue #9 (commit fallback already OK, confirmed):
  No change needed — fallback was already added in prior round.

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 27, 2026 01:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds evidence-based GitHub Copilot customization artifacts to better align AI suggestions with DurableTask .NET SDK invariants (replay determinism, wire compatibility, generator/analyzer constraints) and to provide reusable playbooks/agents for future work.

Changes:

  • Expanded .github/copilot-instructions.md with replay determinism and gRPC/proto compatibility guidance.
  • Added scoped Copilot instruction files for analyzers/generators and gRPC worker/integration-test areas.
  • Added a breaking-change review skill and a “copilot-customizer” chat agent spec for future instruction generation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
.github/copilot-instructions.md Adds repo-wide guidance on orchestrator determinism and gRPC/proto compatibility.
.github/copilot/instructions/analyzers-generators.md Adds path-scoped rules for Roslyn analyzer/generator projects and their tests.
.github/copilot/instructions/grpc-worker.md Adds path-scoped rules for proto wire compatibility, worker dispatch loop, and integration tests.
.github/skills/breaking-change-check/SKILL.md Adds a conditional, multi-step breaking-change safety checklist/playbook.
.github/copilot/agents/copilot-customizer.md Adds a two-phase agent spec for proposing future Copilot customizations with evidence gating.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 27, 2026 01:30
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
YunchuWang and others added 4 commits March 26, 2026 18:31
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

The closing fence after the WaitForInstanceCompletionAsync example was
dropped during rebase conflict resolution.

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 27, 2026 02:39
- analyzers-generators.md: narrow applyTo to src/Analyzers/**,src/Generators/**
  only; test/Generators.Tests intentionally uses System.Reflection and
  Microsoft.Extensions.DependencyInjection (verified in TestHelpers.cs),
  so the compile-time-only rules must not scope into test projects
- grpc-worker.md: add src/Shared/Grpc/ProtoUtils.cs as a required update
  point when proto fields change; this file performs most history/action
  conversions and exists alongside the client-side ProtoUtils.cs (verified
  with find)
- copilot-instructions.md: remove proto3-inaccurate 'required fields'
  phrasing; orchestrator_service.proto uses proto3 (syntax = proto3) which
  has no required keyword; reworded to describe actual unsafe patterns
  (fields the SDK/sidecar treats as required, fields without safe defaults,
  changing field types)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 27, 2026 02:45
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment on lines +1 to +3
---
applyTo: "src/Analyzers/**,src/Generators/**"
---
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applyTo only scopes this instruction file to src/Analyzers/**,src/Generators/**, but the content includes explicit guidance for test/Analyzers.Tests/ and test/Generators.Tests/ (and the PR description lists those tests as in-scope). If the intent is to have these rules active while editing the test projects too, include the test globs in applyTo; otherwise consider removing/relocating the test-specific sections to avoid a misleading scope.

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +28
- Generator tests use `Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing` — use `GeneratorDriver` or the test helper wrappers in `test/Generators.Tests/`.
- Compare generated output with explicit expected source strings (inline in the tests or via shared helpers). When changing generator templates, update all affected expected outputs or helper expectations.
- Do not emit `#pragma warning disable` in generated output without explicit justification.
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file says generator tests should compare output with “stored expected snapshots”, but test/Generators.Tests currently asserts generated output via inline expected source strings in TestState.GeneratedSources (e.g., test/Generators.Tests/Utils/TestHelpers.cs). Updating this wording will avoid steering contributors toward a snapshot workflow that the repo doesn’t use today.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants