Skip to content

Add path-scoped Copilot instructions for context/ and routing/#146

Merged
dgenio merged 8 commits intomainfrom
copilot/add-copilot-instructions-context-routing
Mar 10, 2026
Merged

Add path-scoped Copilot instructions for context/ and routing/#146
dgenio merged 8 commits intomainfrom
copilot/add-copilot-instructions-context-routing

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 9, 2026

Summary

The two largest subsystems — context engine (11 modules) and routing engine (9 modules) — lacked agent-facing guidance scoped to their directories. Agents editing manager.py or graph.py had no subsystem-specific invariants to follow, risking broken pipeline ordering, firewall bypasses, or invalid graph states.

Changes

  • .github/instructions/context.instructions.md (applyTo: src/contextweaver/context/**)

  • .github/instructions/routing.instructions.md (applyTo: src/contextweaver/routing/**)

    • All 4 ChoiceGraph._validate() invariants documented (root exists, children resolve, no cycles, all items reachable)
    • Eager cycle detection in add_edge() — must not be bypassed
    • TreeBuilder 3-strategy priority order (namespace → Jaccard clustering → alphabetical) with fallback conditions
    • Router determinism: (-score, id) sort key must not change; confidence_gap bounds
    • generate_sample_catalog seed=42 is a contract — demos and tests depend on it
    • ChoiceCard schema prohibition; sync-only routing; no cross-engine imports

Both files are ≤100 lines, documentation-only, and grounded in actual code.

Checklist

  • Tests added or updated for every new/changed public function
  • make ci passes locally (fmt + lint + type + test + example + demo)
  • CHANGELOG.md updated under ## [Unreleased]
  • Docstrings added for all new public APIs (Google-style)
  • Every modified module stays ≤ 300 lines (or a decomposition issue is linked above)
  • Related issue linked in the summary above
  • Agent-facing docs updated if pipeline, API, or conventions changed

Notes for reviewers

Instruction files are loaded automatically by VS Code Copilot when editing files under the targeted paths — no tooling changes required. Content is derived directly from manager.py docstring, graph.py._validate(), router.py.route(), tree.py.build(), and catalog.py.generate_sample_catalog() — reviewers should cross-check those sources if any rule seems off.

Original prompt

This section details on the original issue you should resolve

<issue_title>[agent] Add path-scoped Copilot instructions for context/ and routing/</issue_title>
<issue_description>## Problem

The two largest subsystems — context engine (9 modules, 1113 lines) and routing engine (9 modules, 1568 lines) — lack module-specific agent guidance. Root-level files (AGENTS.md, CLAUDE.md, .github/copilot-instructions.md) provide general conventions but don't cover subsystem-specific invariants.

Agents editing context/manager.py (629 lines, the largest module) or routing/graph.py (316 lines) need scoped rules to avoid breaking critical invariants like pipeline stage ordering, firewall guarantees, or ChoiceGraph validation constraints.

Evidence:

Proposal

Create 2 path-scoped Copilot instruction files that VS Code Copilot automatically loads when editing files in the corresponding directories.

.github/instructions/context.instructions.md

Apply to src/contextweaver/context/**. Should cover:

.github/instructions/routing.instructions.md

Apply to src/contextweaver/routing/**. Should cover:

  • ChoiceGraph validation rules: root must exist, all children must resolve, all items must be reachable, no cycles
  • TreeBuilder strategies: namespace grouping → Jaccard clustering → alphabetical fallback
  • Router beam-search constraints: deterministic tie-break by ID, confidence_gap threshold
  • Catalog invariants: generate_sample_catalog is seeded for reproducibility
  • ChoiceCard: never include full schemas (keeps prompt tokens minimal)
  • All routing is synchronous (pure computation, no async)

Acceptance criteria

File paths

  • .github/instructions/context.instructions.md (create)
  • .github/instructions/routing.instructions.md (create)

Dependencies

  • None (independent)

Estimated effort

S (1-2 days)</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Loading
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.

[agent] Add path-scoped Copilot instructions for context/ and routing/

3 participants