Skip to content

feat(trace): GitHub Copilot support (spec, plan, and M1) - #3801

Merged
migmartri merged 17 commits into
chainloop-dev:mainfrom
migmartri:issue-3800-spec-copilot-trace-provider
Nov 11, 2026
Merged

migmartri merged 17 commits into
chainloop-dev:mainfrom
migmartri:issue-3800-spec-copilot-trace-provider

Conversation

@migmartri

@migmartri migmartri commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

This PR adds GitHub Copilot support to Chainloop Trace. It holds the spec, the implementation plan, and the first milestone of the plan..

  • Spec: docs/specs/issue-3800-copilot-trace-provider.md
  • Plan: docs/plans/issue-3800-copilot-trace-provider.md
  • Implementation: M1 of the plan (R-001 to R-007, R-010)

One copilot provider covers Copilot CLI and the Copilot agent in VS Code. Both read the hook files in .github/hooks/, and Trace owns its own file there, .github/hooks/chainloop-trace.json. chainloop trace init --copilot and chainloop trace run --copilot install it. Trace records the Copilot session event log as AI coding-session evidence: conversation, tools, models, tokens from the session summary, an API-price cost estimate, and code attribution for the file and shell tools.

The Copilot agent also runs the hooks in .claude/settings.json. The Claude Code provider now ignores Copilot payloads (R-003), so a repository with both providers records a Copilot session once, under Copilot.

Skills tracking, spec source pointers, and pasted image pointers are M2 of the plan, in a later PR.

The trace init summary now ends with the docs link, with no per-agent notes. This goes against two earlier specs:

  • Codex spec issue-3657 R-006 ("Initialization MUST tell Codex users to review and trust the installed hooks"). The spec is frozen, so it is not changed here.
  • Pi spec issue-3520 R-009. This PR supersedes it with R-010, which keeps every rule except the init note.

The Trace README keeps the trust steps of Pi, Codex, and Copilot.

Open question for reviewers:

  • Does the Copilot agent in VS Code write the same session event log as Copilot CLI? Proposed: yes. A manual VS Code session before merge checks it, with the fallback in the spec.

We would like two reviewers to approve this spec before it merges.

Provider checklist

Provider package (app/cli/internal/trace/copilot/)

  • Name constant and var _ trace.Provider = (*Provider)(nil).
  • InstallHooks: a second call changes nothing. The hooks of the user stay.
  • InstallHooksForTraceRun: all hooks except session end.
  • SettingsFile: the file that install writes.
  • UninstallHooks: removes only the Chainloop hooks.
  • HooksInstalled: true only for the Chainloop hooks.
  • Hook events: session start and session end. No user prompt hook: Copilot drops its output.
  • Hook events: before and after each file tool and shell tool. (No skill tool: M2.)
  • ReadHookInput: typed struct, size limit, absolute FilePath, Cwd and TranscriptPath, Command. Copilot sends no tool call ID or agent ID.
  • IsFileWritingTool and IsCommandTool: one Go slice is the source of each list.
  • Attribution strategy selected: snapshot.
  • Shell tool sends pre and post hooks with the same ToolUseID (none on both sides, TRC-006).
  • CopySessionData: safe to repeat, checks paths from the payload, does not fail the hook when the agent or the transcript is missing.
  • ParseSession: reads only the copy in opts.SessionDir.
  • CopySessionData and ParseSession: no control plane and no network, so that local mode works.
  • Trace state only through the *state.Store.
  • Evidence: agent name and version, session ID and times, primary model, models used, model provider.
  • Evidence: token usage (input, output, total, cache read, cache write).
  • Evidence: cost from an embedded price table.
  • Evidence: tools used, conversation counts. (No subagents: spec Non-Goal.)
  • Evidence: RawSession["main"] is never nil. Each line is a JSON object.
  • Evidence: a warning for each data item that cannot be read.
  • Session-start and post-tool responses: one JSON document each, and nothing for an empty message.
  • Supports* methods tell the truth about each channel.
  • AnnounceToUser writes the post-tool additionalContext.
  • Optional: SkillTracker, SpecCopyReplacer, PastedImageFinder (M2).
  • Unit tests: hooks, parse with testdata/, announce responses, copy.

CLI wiring

  • Registered in providers/registry.go.
  • traceProviderFlags field, any(), names().
  • --copilot flag in trace init (with help text) and in trace run.
  • chainloop trace hook copilot … subcommands in cmd/trace_hook.go, with skipActionOptsInit.
  • Pre-tool response written first, if the agent blocks tools without one (not needed: Copilot does not block on an empty response).
  • providers/capabilities_test.go updated.
  • cmd/trace_init_providers_test.go and cmd/trace_init_test.go updated.
  • make generate run for the CLI reference.

End-to-end tests and documentation

  • e2e/copilot.go implements e2e.Harness.
  • Harness in the harnesses map of e2e/e2e_test.go.
  • Version and models in e2e/config.yaml.
  • Suite run for the new column, with the results checked: Copilot CLI 1.0.109 with gpt-6.1-sol passed all 26 checked features.
  • README.md: new column in each feature table, with values from the suite.
  • README.md: a "Why not Yes" line for each cell that is not Yes.
  • README.md: row in "How each agent is hooked in", and provider list at the top updated.
  • Spec in docs/specs/, with requirement IDs cited in this PR.
  • License header year updated in each changed file.
  • make -C app/cli lint (new issues) and make -C app/cli test pass.

Refs #3800

AI disclosure: Claude Code helped to research, plan, and implement this change.

🤖 Generated with Claude Code

Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93
@migmartri migmartri added the spec Design spec label Nov 10, 2026
@chainloop-platform

chainloop-platform Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

PR validation — ✅ 3 passing

Status Policy Material Messages
✅ Passed pr-min-approvals pr-info -
✅ Passed pr-description-required pr-info -
✅ Passed pr-user-story-linked pr-info -

View attestation ↗

AI Session Checks — 🟡 87% · ⚠️ 1 failing

Avg score Sessions Failing policies Attribution Files Lines Total Duration
🟡 87% 2 ⚠️ 1 99% AI / 1% Human 32 +3301 / -93 3h38m2.787s

🟡 80% — 99% AI — ✅ All policies passing

Nov 10, 2026 21:50 UTC · 3h37m15s · $89.76 · 1.7k in / 764.9k out · claude-code 2.1.322 (claude-opus-5-5)

View session details ↗

Change Summary

Adds the Copilot core provider, CLI flags and hooks, private transcript capture, parsing, attribution wiring and a cross-provider payload guard. Adds regression tests, a real CLI harness and compatibility documentation, and removes per-agent init notes after user approval.

AI Session Overall Score

🟡 80% — Core implementation is well planned and CLI-tested; VS Code validation and minor scope cleanup remain.

AI Session Analysis Breakdown

🟢 93% · context-and-planning

🟢 M1 specified delivery outcomes, ownership, security boundaries, unit tests and CLI/manual acceptance exercises before coding. · High Impact

🟢 90% · solution-quality

🟢 Identity, containment and atomic-copy defenses have concrete regression coverage, including a FIFO failure reproduced before the fix. · High Impact

🟡 77% · scope-discipline

🟡 The PR adds an unrelated random-date line to the CLI README; neither M1 nor user follow-ups authorize it. · Low Severity

🟡 76% · user-trust-signal

🟠 The user rejected extra init information, then clarified that existing notes after the learn-more line should also go. · Medium Severity

💡 State the intended output boundary explicitly when simplifying both new and existing text.

🟡 75% · alignment

🟠 The agent initially omitted the required banner, acknowledged that choice when asked, and added progress output after user follow-up. · Medium Severity

💡 Resolve hook-channel uncertainty experimentally before dropping a required user-visible outcome.

🟡 73% · verification

🟢 Real CLI failures exposed hook trust and patch-attribution gaps; fixes were followed by an explicitly passing feature matrix. · High Impact

🟠 The required manual VS Code check and verified-cell mapping are not captured; the real-agent suite covers only CLI sessions. · Medium Severity

💡 Complete and record a real VS Code session before treating the shared-host milestone as verified.

🟠 The user was active throughout but never explicitly confirmed that the new provider behavior worked. · Medium Severity

🟡 Full-suite success lines were filtered and pipeline status was not preserved, weakening the broad pass claim despite explicit focused-package successes. · Low Severity


File Attribution

███████████████████░ 99% AI / 1% Human

Status Attribution File Lines
created ai app/cli/internal/trace/copilot/parse.go +493 / -0
created ai app/cli/internal/trace/copilot/hooks.go +431 / -0
created ai app/cli/internal/trace/copilot/hooks_test.go +271 / -0
created ai app/cli/internal/trace/copilot/parse_test.go +259 / -0
created ai app/cli/internal/trace/copilot/provider_test.go +247 / -0
created ai app/cli/internal/trace/copilot/pricing.json +229 / -0
created ai app/cli/internal/trace/copilot/copy.go +201 / -0
created ai app/cli/internal/trace/e2e/copilot.go +193 / -0
created ai docs/plans/issue-3800-copilot-trace-provider.md +169 / -0
created ai app/cli/internal/trace/copilot/provider.go +163 / -0
created ai docs/specs/issue-3800-copilot-trace-provider.md +152 / -0
modified ai app/cli/internal/trace/README.md +70 / -51
modified ai app/cli/internal/trace/claude/hooks_test.go +90 / -0
created ai app/cli/internal/trace/e2e/copilot_test.go +83 / -0
created ai app/cli/internal/trace/copilot/pricing.go +77 / -0
modified ai app/cli/internal/trace/claude/hooks.go +57 / -8
modified ai app/cli/cmd/trace_hook.go +21 / -0
modified ai app/cli/cmd/trace_init.go +4 / -17
modified ai app/cli/cmd/trace_init_providers_test.go +13 / -2
modified ai app/cli/cmd/trace_init_test.go +7 / -6
created ai app/cli/internal/trace/copilot/testdata/session.jsonl +13 / -0
modified ai app/cli/cmd/trace_hook_test.go +12 / -0
modified ai app/cli/internal/trace/e2e/config.yaml +12 / -0
modified ai docs/specs/issue-3520-pi-trace-provider.md +10 / -2
modified ai app/cli/cmd/trace_init_providers.go +7 / -3

…and 7 more file(s).


Policies (4)

Status Policy Material Messages
✅ Passed ai-config-ai-agents-allowed ai-coding-session-1091d5 -
✅ Passed ai-config-no-dangerous-commands ai-coding-session-1091d5 -
✅ Passed ai-config-no-secrets ai-coding-session-1091d5 -
✅ Passed ai-config-mcp-servers-allowed ai-coding-session-1091d5 -

🟢 95% — 0% AI — ⚠️ 1 policies failing

Nov 11, 2026 01:12 UTC · 16m5s · $0.11 · 33 in / 805 out · copilot 1.0.109 (gpt-6.1-sol)

View session details ↗

Change Summary

Adds a trace provider, session parsing and copying, hook integration, pricing data, and related tests and documentation. The available coding transcript covers a separate README date experiment and its reversal, not those implementation changes.

AI Session Overall Score

🟢 95% — Captured README experiment was well-handled; broader provider implementation and runtime validation remain unassessed.

AI Session Analysis Breakdown

🟢 97% · scope-discipline

🟢 Path-specific staging committed only the README while unrelated worktree modifications remained unstaged. · High Impact

🟢 96% · alignment

🟢 Commit and push output confirms the reported two-line README addition and successful publication. · High Impact

🟢 94% · context-and-planning

No notes.

🟢 93% · user-trust-signal

🟢 After the local reversal report, the user authorized publication with a neutral follow-up rather than abandoning assistance. · High Impact

abstained · solution-quality

🟡 solution-quality not assessed — reviewer should confirm coverage · Low Severity

abstained · verification

🟡 verification not assessed — reviewer should confirm coverage · Low Severity


Policies (4, 1 failing)

Status Policy Material Messages
⚠️ Failed ai-config-ai-agents-allowed ai-coding-session-386938 AI agent 'copilot' is not in the allowed list
✅ Passed ai-config-no-dangerous-commands ai-coding-session-386938 -
✅ Passed ai-config-no-secrets ai-coding-session-386938 -
✅ Passed ai-config-mcp-servers-allowed ai-coding-session-386938 -

Security Checks — ✅ 6 passing

✅ Nothing this change touches has a recorded security-fix history.

View in Chainloop ↗ · How this works ↗

✅ secret-scan

Status Policy Messages
✅ Passed secrets-detection -

✅ sast-scan

Status Policy Messages
✅ Passed owasp-top10-2025 -
✅ Passed sast -
✅ Passed cwe-top25 -
✅ Passed cwe-top26-40-cusp -

✅ iac-scan

Status Policy Messages
✅ Passed iac-misconfiguration -
Scans not applied (2)
Scan Reason
vulnerability-scan no manifest/lockfile changed
github-actions-scan no workflow files changed

View attestation ↗


Powered by Chainloop and Chainloop Trace

Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Add a copilot Trace provider that covers Copilot CLI and the Copilot agent in VS Code through a hook file that Trace owns in .github/hooks. It records the Copilot session event log as evidence, with attribution and an API-price cost estimate. The Claude Code provider now ignores Copilot payloads, so a Copilot session is recorded once.

Implements M1 of docs/plans/issue-3800-copilot-trace-provider.md (R-001 to R-007, R-010).

Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93
@migmartri migmartri changed the title spec: issue-3800 GitHub Copilot support in Chainloop Trace feat(trace): GitHub Copilot support (spec, plan, and M1) Nov 11, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 27 files (changes from recent commits).

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

View guided diff | Re-trigger cubic

Comment thread app/cli/cmd/trace_hook.go Resolved
Comment thread app/cli/internal/trace/copilot/copy.go Resolved
Comment thread app/cli/internal/trace/copilot/hooks.go Resolved
Comment thread app/cli/internal/trace/copilot/copy.go Resolved
Copilot uses apply_patch for file edits with GPT models. The provider now records each file of the patch. It also reads the model of each message and of session start, and wraps non-object tool arguments for the session viewer.

The e2e harness trusts the workspace folder, because Copilot CLI loads the repository hooks only in a trusted folder. trace init and the README tell users to trust the repository. The README Copilot column holds the results of Copilot CLI 1.0.109 with gpt-6.1-sol.

Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93
@migmartri
migmartri requested a review from a team November 11, 2026 00:31

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 8 files (changes from recent commits).

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

View guided diff | Re-trigger cubic

Comment thread app/cli/internal/trace/copilot/parse.go Resolved
Reject a non-regular Copilot log before opening it, so a FIFO cannot block the hook, and report a read error of the first line. Add a command-tree test for the copilot hook subcommands. Document the mixed pre-tool batch limit (chainloop-dev#3803).

Spec: describe the payload forms by event name, narrow R-007 to the model channel, list every requirement that the VS Code fallback affects, and add Windows as a Non-Goal (chainloop-dev#3802).

Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93
Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93
Copilot shows the progress messages of a hook to the user. The Copilot provider now writes the session-start banner and the session link after a push as progress lines, before the additionalContext for the model. Checked by hand with Copilot CLI 1.0.109.

Spec: R-007 now requires the banner and the session link for the user.

Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93
Add the payloads that Copilot CLI 1.0.109 sends to the hooks of .claude/settings.json, so the guard of R-003 is tested against real shapes.

Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93
The README covers the Copilot setup, so trace init prints no extra note for Copilot.

Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93
The trace init summary now ends with the docs link. The Pi and Codex trust notes are removed, and the Trace README keeps those setup steps.

This goes against Codex spec issue-3657 R-006, which is frozen, and supersedes Pi spec issue-3520 R-009 with R-010.

Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93
Assisted-by: GitHub Copilot
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 386938e5-0467-469a-81ef-4aae40023df7
…ut an error

Copilot sends the patch text of its edit tool as a string tool_input to the hooks of .claude/settings.json. The Claude Code reader failed to decode it before the Copilot check ran, which logged a bad-input error. It now decodes tool_input after the checks for other agents.

Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93
The progress line already shows the session link to the user. The provider no longer gives the link to the model too, so the model does not repeat it.

Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 11 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread app/cli/cmd/trace_init.go Resolved
Comment thread app/cli/internal/trace/claude/hooks.go Resolved
Comment thread app/cli/README.md Resolved
…e Code hook

A tool_input object with a field of the wrong type is bad input again. Only a tool_input that is not an object, such as a Copilot patch string, gives no file path.

Refs chainloop-dev#3800

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 1091d5bb-f3cb-4795-997a-fabee098ff93
Assisted-by: GitHub Copilot
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

Chainloop-Trace-Sessions: 386938e5-0467-469a-81ef-4aae40023df7
Resolve the README conflict: keep the Pi skills tracking changes of chainloop-dev#3759 and the Copilot column.

Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>

@danlishka danlishka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@migmartri
migmartri merged commit 3b8ac75 into chainloop-dev:main Nov 11, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants