Skip to content

feat: Copilot governance engine, VS Code extension, and recall parser#45

Open
bilersan wants to merge 4 commits intoActiveMemory:mainfrom
bilersan:feat/copilot-governance
Open

feat: Copilot governance engine, VS Code extension, and recall parser#45
bilersan wants to merge 4 commits intoActiveMemory:mainfrom
bilersan:feat/copilot-governance

Conversation

@bilersan
Copy link
Contributor

Summary

Three-layer governance architecture for VS Code Copilot that closes the governance gap with Claude Code hooks, plus Copilot Chat session parser and Windows compatibility fixes.

Resolves #44
Closes #28
Closes #30
Supersedes #29, #31, #36

Architecture

Layer 1: Behavioral Rules (copilot-instructions.md)

Preventive/advisory rules in the system prompt — session lifecycle, when to call tools, governance response handling.

Layer 2: MCP Governance-in-Response

CheckGovernance() appends contextual warnings to every MCP tool response:

  • Session not started → nudge ctx_session_event(start)
  • Context not loaded → nudge ctx_status()
  • Drift stale (>15min or >5 calls) → nudge ctx_drift()
  • Persist nudge (>=10 calls since last write) → nudge ctx_add()
  • Violations from detection ring → CRITICAL escalation

Layer 3: VS Code Detection Ring

Extension monitors terminal commands and file edits:

  • Terminal watcher: dangerous commands (rm -rf /, git push --force, etc.)
  • File edit watcher: sensitive files (.env, .pem, credentials)
  • Records violations → MCP escalates with CRITICAL warnings

Commits

  1. fix: Windows cross-platform compatibility — Case-insensitive path comparison on Windows for boundary validation
  2. feat: Copilot Chat session parser — CopilotParser for ctx recall with platform-aware JSONL parsing
  3. feat: VS Code extension with MCP integration@ctx chat participant, mcp.json generation, detection ring, session lifecycle
  4. feat: MCP governance engine — CheckGovernance with 5 checks, 24 tests, wired into route/tool dispatch

Testing

  • 24 governance tests (all checks, edge cases, violations)
  • 39 MCP server tests (all pass including session priming)
  • Init/hook integration tests for mcp.json generation
  • Compliance tests pass (goconst, gosec, literal newline)

- Case-insensitive path comparison on Windows for boundary validation
- Extract osWindows constant for goconst compliance

Closes ActiveMemory#30
Supersedes ActiveMemory#31

Signed-off-by: ersan bilik <ersanbilik@gmail.com>
- CopilotParser implementing SessionParser interface with Matches() and ParseFile()
- Platform-aware directory discovery for Code and Code Insiders
- Typed Go structs for Copilot Chat JSONL format (snapshot+patch model)
- Registration in parser.go and query scanning in query.go
- ToolCopilot constant in config/session

Closes ActiveMemory#28
Supersedes ActiveMemory#29

Signed-off-by: ersan bilik <ersanbilik@gmail.com>
- VS Code extension with @ctx chat participant and slash commands
- .vscode/mcp.json generation in init and hook paths
- VS Code-specific context overrides (CONSTITUTION, CONVENTIONS, etc.)
- Session event CLI command for VS Code lifecycle integration
- Detection ring: terminal watcher for dangerous commands
- Detection ring: file edit watcher for sensitive file patterns
- Violation recording to .context/state/violations.json
- Extension tests and init/hook integration tests

Supersedes ActiveMemory#36

Signed-off-by: ersan bilik <ersanbilik@gmail.com>
- Governance checker (CheckGovernance) appends contextual warnings to
  every MCP tool response: session-not-started, context-not-loaded,
  drift-stale, persist-nudge, and violation escalation
- Per-tool state recording: RecordSessionStart, RecordContextLoaded,
  RecordDriftCheck, RecordContextWrite, IncrementCallsSinceWrite
- Violation reading from .context/state/violations.json with automatic
  cleanup after escalation (read-and-clear pattern)
- Governance wired into route/tool dispatch with appendGovernance
- RecordSessionStart called on session event handler
- copilot-instructions.md template with governance rules and
  detection ring documentation
- 24 governance tests covering all check paths and edge cases

Signed-off-by: ersan bilik <ersanbilik@gmail.com>
@bilersan bilersan force-pushed the feat/copilot-governance branch from 9fa7a32 to 300d3a6 Compare March 17, 2026 17:09
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.

feat: Copilot governance engine and VS Code extension Windows cross-platform compatibility fixes feat: Add Copilot Chat session parser for recall

1 participant