feat(api): Gary header contract — read-only parsing of X-Gary-* headers#3
Merged
OriginalGary merged 2 commits intomainfrom May 5, 2026
Merged
feat(api): Gary header contract — read-only parsing of X-Gary-* headers#3OriginalGary merged 2 commits intomainfrom
OriginalGary merged 2 commits intomainfrom
Conversation
Parse X-Gary-Action-Id, X-Gary-Stage, X-Gary-Playbook, and X-Gary-Sensitivity on every /v1/chat/* request. Headers are optional; unknown enum values log a warning and are treated as absent (never 4xx). Parsed context is stored in a 20-entry in-memory ring buffer exposed via the health endpoint's new garyContextHistory field. Requests with at least one Gary header are also persisted to the audit_log table under action "gary.context". - src/lib/gary/context.ts: parser, enum sets, ring buffer, audit logging - src/sse/handlers/chat.ts: parse Gary context at handleChat() entry - open-sse/utils/cors.ts: allow four Gary headers in CORS preflight - src/lib/monitoring/observability.ts: add garyContextHistory to health payload - src/app/api/monitoring/health/route.ts: wire getRecentGaryContexts() - tests/unit/gary-context.test.ts: 14 tests covering all parse cases Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CI Coverage Report
Coverage artifact was not available for this run. |
1. sse-shim-contract.test.ts: revert assertions from @graze/open-sse back to @omniroute/open-sse — the TypeScript path alias rename was explicitly deferred; the test was incorrectly updated ahead of the rename. 2. executor-codex.test.ts: update expected x-codex-installation-id UUID from 7f06a8ee (derived from omniroute-codex-installation salt) to 5594a324 (derived from the renamed graze-codex-installation salt, which was changed in the brand sweep because no existing deployments use the old value). 3. electron/package.json: rename name/productName/appId/author/homepage from OmniRoute to Graze so electron-builder produces the graze-desktop executable that smoke-electron-packaged.mjs expects, and update publish target from diegosouzapw/OmniRoute to OpenGaryBot/graze. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
X-Gary-*request headers on every/v1/chat/*call:X-Gary-Action-Id,X-Gary-Stage,X-Gary-Playbook,X-Gary-Sensitivity/api/monitoring/healthasgaryContextHistoryaudit_logunderaction: "gary.context"Files changed
src/lib/gary/context.tssrc/sse/handlers/chat.tsparseGaryContext()athandleChat()entryopen-sse/utils/cors.tsx-gary-*headers in CORS preflightsrc/lib/monitoring/observability.tsgaryContextHistoryto health payloadsrc/app/api/monitoring/health/route.tsgetRecentGaryContexts()tests/unit/gary-context.test.tsTest plan
node --import tsx/esm --test tests/unit/gary-context.test.ts)typecheck:corescope)curl -H "X-Gary-Stage: plan" -H "X-Gary-Playbook: code-pr" -H "X-Gary-Action-Id: abc-123" -H "X-Gary-Sensitivity: tier-2" http://localhost:20128/v1/chat/completions ...Design decisions for later prompts
audit_log)parseGaryContextis called only fromhandleChat(), covering/v1/chat/completions,/v1/messages,/v1/completions,/v1/responses; embeddings/search/rerank do not fire (Gary pipeline only uses chat endpoints)@omniroute/open-ssealias not touched (deferred from brand sweep)🤖 Generated with Claude Code