feat: add safe routing context - #60
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📝 WalkthroughWalkthroughAdds metadata-only routing context collection from bounded workspace signals, deterministic profile-hint precedence, capability-gated MCP root handling, sanitized route-preview/audit evidence, and extensive runtime, security, routing, and documentation tests. ChangesRouting context integration
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related issues
Possibly related PRs
Poem
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error, 1 warning)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/mcp/server/miftah-server.ts`:
- Around line 169-174: Cache the result produced by provideRoutingContext, keyed
to the current MCP roots/connection, so collectRoutingContext is executed only
once for each roots state. Reuse the cached RoutingContextSnapshot on subsequent
lookups, including before roots initialization where applicable, and invalidate
the cache whenever MCP roots are refreshed or the connection context changes.
In `@src/routing/context-collector.ts`:
- Line 154: Update the array sorting expression in the normalization flow to use
toSorted() instead of sort(), preserving the existing sorted return value while
satisfying the e18e/prefer-array-to-sorted lint rule.
- Around line 131-136: Move the URI-scheme and Windows-drive regex literals used
by redactProjectValue to module-level constants, then have the function reuse
those constants while preserving the existing matching behavior.
In `@src/routing/routing-engine.ts`:
- Around line 59-65: Update the markerProfiles construction to use the
non-mutating toSorted() method instead of sort(), preserving the existing
deduplication and ordering behavior while satisfying the
e18e/prefer-array-to-sorted lint rule.
In `@vitest.config.ts`:
- Around line 13-14: Replace the global fileParallelism setting in the Vitest
configuration with separate projects/workspaces: keep fixture-dependent specs in
a serialized project and leave unrelated tests on the default parallel
execution. Ensure each project’s test include patterns isolate the appropriate
files without changing their existing test behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 86515006-89af-46b4-a8a0-728f859c95fc
📒 Files selected for processing (19)
CHANGELOG.mdREADME.mddocs/architecture.mddocs/config.mddocs/security.mdsrc/audit/audit-trail.tssrc/audit/audit-types.tssrc/mcp/server/miftah-server.tssrc/mcp/server/operation-pipeline.tssrc/routing/context-collector.tssrc/routing/routing-engine.tssrc/routing/routing-types.tssrc/runtime/create-miftah-runtime.tstests/mcp-wrapper.test.tstests/operation-pipeline.test.tstests/routing-context-docs-contract.test.tstests/routing-context.test.tstests/routing-policy.test.tsvitest.config.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Validation
Relates to #20
Summary by CodeRabbit