@@ -10,6 +10,10 @@ pub enum ContextProvenance {
1010 name : String ,
1111 } ,
1212 CustomContextNotes ,
13+ DocumentContext {
14+ source : String ,
15+ title : String ,
16+ } ,
1317 JiraIssueContext {
1418 issue_key : String ,
1519 } ,
@@ -65,6 +69,13 @@ impl ContextProvenance {
6569 }
6670 }
6771
72+ pub fn document_context ( source : impl Into < String > , title : impl Into < String > ) -> Self {
73+ Self :: DocumentContext {
74+ source : source. into ( ) ,
75+ title : title. into ( ) ,
76+ }
77+ }
78+
6879 pub fn linear_issue_context ( issue_id : impl Into < String > ) -> Self {
6980 Self :: LinearIssueContext {
7081 issue_id : issue_id. into ( ) ,
@@ -118,6 +129,7 @@ impl ContextProvenance {
118129 }
119130 Self :: Analyzer { .. }
120131 | Self :: CustomContextNotes
132+ | Self :: DocumentContext { .. }
121133 | Self :: JiraIssueContext { .. }
122134 | Self :: LinearIssueContext { .. }
123135 | Self :: DependencyGraphNeighborhood
@@ -141,6 +153,7 @@ impl ContextProvenance {
141153 let source = match self {
142154 Self :: ActiveReviewRules | Self :: Analyzer { .. } => return None ,
143155 Self :: CustomContextNotes => "custom-context" . to_string ( ) ,
156+ Self :: DocumentContext { source, .. } => source. trim ( ) . to_string ( ) ,
144157 Self :: JiraIssueContext { .. } => "jira-issue" . to_string ( ) ,
145158 Self :: LinearIssueContext { .. } => "linear-issue" . to_string ( ) ,
146159 Self :: DependencyGraphNeighborhood => "dependency-graph" . to_string ( ) ,
@@ -165,6 +178,9 @@ impl ContextProvenance {
165178 Self :: ActiveReviewRules => "active review rules" . to_string ( ) ,
166179 Self :: Analyzer { name } => format ! ( "{name} analyzer" ) ,
167180 Self :: CustomContextNotes => "custom context notes" . to_string ( ) ,
181+ Self :: DocumentContext { source, title } => {
182+ format ! ( "document context ({source}): {title}" )
183+ }
168184 Self :: JiraIssueContext { issue_key } => format ! ( "jira issue context: {issue_key}" ) ,
169185 Self :: LinearIssueContext { issue_id } => {
170186 format ! ( "linear issue context: {issue_id}" )
@@ -260,6 +276,10 @@ mod tests {
260276 ContextProvenance :: RepositoryGraphMetadata . to_string( ) ,
261277 "repository graph metadata"
262278 ) ;
279+ assert_eq ! (
280+ ContextProvenance :: document_context( "design-doc" , "Checkout architecture" ) . to_string( ) ,
281+ "document context (design-doc): Checkout architecture"
282+ ) ;
263283 assert_eq ! (
264284 ContextProvenance :: jira_issue_context( "ENG-123" ) . to_string( ) ,
265285 "jira issue context: ENG-123"
@@ -290,6 +310,12 @@ mod tests {
290310 . as_deref( ) ,
291311 Some ( "context-source:symbol-graph" )
292312 ) ;
313+ assert_eq ! (
314+ ContextProvenance :: document_context( "runbook" , "Pager escalation" )
315+ . artifact_tag( )
316+ . as_deref( ) ,
317+ Some ( "context-source:runbook" )
318+ ) ;
293319 assert_eq ! (
294320 ContextProvenance :: jira_issue_context( "ENG-123" )
295321 . artifact_tag( )
0 commit comments