onetaskgraph_plugin_api/source.rs
1//! The two traits a plugin implements, and the secret lookup it is handed.
2
3use schemars::{JsonSchema, Schema};
4use secrecy::SecretString;
5use serde::{Deserialize, Serialize};
6use serde_json::Value;
7
8use crate::{
9 Capabilities, Comment, CommentBody, DependencyEdge, Direction, Document, DocumentQuery,
10 ItemWrite, Label, MetadataKey, MetadataRecord, Metering, NativeId, NewComment, Page,
11 PageRequest, Priority, Project, ProjectQuery, SourceError, SourceName, Status, StatusCategory,
12 Task, TaskQuery, TaskRef, WriteSupport, commentless, documentless, unwritable,
13 unwritable_field, unwritable_metadata,
14};
15
16/// Whether a source is answering right now.
17///
18/// # Placement is an open contract question
19///
20/// This type lives here because [`TaskSource::health`] returns it and the trait
21/// lives here: placing it in `onetaskgraph-core` would make this crate depend on
22/// the engine and invert the one direction the crate split exists to establish.
23/// The approved contract enumerates this crate's contents exhaustively and does
24/// not name `Health`, so the enumeration and the trait as written cannot both
25/// stand. Compiling forces the placement below; the resolution — add it to the
26/// enumeration, or redesign `health` so no such type crosses the boundary —
27/// belongs to the contract's owner, not to this crate. See `AGENTS.md`.
28#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
29// llmlint: ignore[invalid_states_unrepresentable] SECOND PERMITTED REASON — this restates at a new site the justification already recorded at `Capabilities.max_page_size` (capability.rs) and `PageRequest.limit` (query.rs), and a third time in this type's own doc comment above and in AGENTS.md's "Open contract question — `Health`": `Health`'s shape is approved contract text that `TaskSource::health` returns, so an enum here would change the serialized form and the trait six undispatched nodes implement. That is the contract owner's call, not this crate's.
30pub struct Health {
31 /// Whether the source answered.
32 ///
33 /// A bare `bool` beside an untyped `detail` cannot say that an unreachable source
34 /// must explain itself, or keep "reachable with a warning" apart from "reachable";
35 /// an enum carrying the detail in its unreachable variant would.
36 // llmlint: ignore[invalid_states_unrepresentable] SECOND PERMITTED REASON — this
37 // restates at this field the justification already recorded at
38 // `Capabilities.max_page_size` (capability.rs), `PageRequest.limit` (query.rs), this
39 // type's own doc comment above, and AGENTS.md's "Open contract question — `Health`":
40 // `Health`'s shape is approved contract text that `TaskSource::health` returns, so an
41 // enum here would change the serialized form and the trait six undispatched nodes
42 // implement. That is the contract owner's call, not this crate's.
43 // llmlint: ignore[boundary_inputs_validated] making "unreachable with no reason given" unrepresentable means an enum here, which changes the serialized form and the trait six undispatched nodes implement. Deferred to the contract's owner — AGENTS.md, "Open contract question — `Health`".
44 pub reachable: bool,
45 /// What the source said, when it said anything useful.
46 pub detail: Option<String>,
47}
48
49/// One configured source, as the engine drives it.
50///
51/// Dyn-compatible through `async_trait` because the engine holds
52/// `Vec<Box<dyn TaskSource>>` over heterogeneous plugins.
53///
54/// Three rules bind every implementation, and the engine's compensation is only
55/// correct while all three hold:
56///
57/// 1. **Apply** every predicate you declare [`Support::Native`](crate::Support::Native).
58/// 2. **Ignore** every [`Support`](crate::Support)-typed predicate you declare
59/// `Unsupported` — return the *wider* result set, never a narrower one.
60/// Silently dropping rows for a predicate you did not declare is the one
61/// failure no test above the plugin can catch.
62/// 3. Never return a silently empty dependency read. Rule 2 reaches the
63/// `Support`-typed *predicates* alone; a dependency read is always real, and so is a
64/// document read — [`Capabilities::documents`] says whether this source has documents
65/// at all, and a source that says it has none is never asked for one rather than
66/// answering an empty page.
67#[async_trait::async_trait]
68pub trait TaskSource: Send + Sync {
69 /// The plugin kind that built this source, for display and for plan output.
70 fn kind(&self) -> &'static str;
71
72 /// What this source applies itself. Read once per query by the engine.
73 fn capabilities(&self) -> Capabilities;
74
75 /// Whether the source is answering right now.
76 ///
77 /// # Errors
78 ///
79 /// Returns a [`SourceError`] when the check itself could not be made.
80 async fn health(&self) -> Result<Health, SourceError>;
81
82 /// Fetch one task by its native id, or `None` when there is no such task.
83 ///
84 /// # Errors
85 ///
86 /// Returns a [`SourceError`] when the source could not answer.
87 async fn get_task(&self, id: &NativeId) -> Result<Option<Task>, SourceError>;
88
89 /// Fetch one project by its native id, or `None` when there is no such project.
90 ///
91 /// # Errors
92 ///
93 /// Returns a [`SourceError`] when the source could not answer.
94 async fn get_project(&self, id: &NativeId) -> Result<Option<Project>, SourceError>;
95
96 /// One page of the tasks matching `query`.
97 ///
98 /// # Errors
99 ///
100 /// Returns a [`SourceError`] when the source could not answer.
101 async fn query_tasks(
102 &self,
103 query: &TaskQuery,
104 page: &PageRequest,
105 ) -> Result<Page<Task>, SourceError>;
106
107 /// One page of the projects matching `query`.
108 ///
109 /// # Errors
110 ///
111 /// Returns a [`SourceError`] when the source could not answer.
112 async fn query_projects(
113 &self,
114 query: &ProjectQuery,
115 page: &PageRequest,
116 ) -> Result<Page<Project>, SourceError>;
117
118 /// One page of every label this source knows.
119 ///
120 /// # Errors
121 ///
122 /// Returns a [`SourceError`] when the source could not answer.
123 async fn labels(&self, page: &PageRequest) -> Result<Page<Label>, SourceError>;
124
125 /// One page of the task dependency edges at `id`, in `direction`.
126 ///
127 /// # Errors
128 ///
129 /// Returns a [`SourceError`] when the source could not answer.
130 async fn task_dependencies(
131 &self,
132 id: &NativeId,
133 direction: Direction,
134 page: &PageRequest,
135 ) -> Result<Page<DependencyEdge>, SourceError>;
136
137 /// One page of the project dependency edges at `id`, in `direction`.
138 ///
139 /// # Errors
140 ///
141 /// Returns a [`SourceError`] when the source could not answer.
142 async fn project_dependencies(
143 &self,
144 id: &NativeId,
145 direction: Direction,
146 page: &PageRequest,
147 ) -> Result<Page<DependencyEdge>, SourceError>;
148
149 /// Whether this source can be written through at all.
150 ///
151 /// Defaulted to [`WriteSupport::Unsupported`], which is what keeps this a read
152 /// interface for every source that has nothing to write into: one that cannot be
153 /// written needs no edit and keeps working. Read before a write is attempted, so a
154 /// copy naming such a source as its destination is refused before anything is read.
155 fn writes(&self) -> WriteSupport {
156 WriteSupport::Unsupported
157 }
158
159 /// Create or update one task, answering with the native id the destination holds it
160 /// under.
161 ///
162 /// A source declaring [`WriteSupport::Supported`] owes three things here. It refuses,
163 /// naming the field, anything it cannot represent rather than dropping it — including
164 /// a metadata key it cannot carry, which it names. It writes every other field it was
165 /// given. And it never creates when [`ItemWrite::target`] names an item it does not
166 /// hold.
167 ///
168 /// # Errors
169 ///
170 /// Returns [`SourceError::Refused`] when this source has no write side, when a field
171 /// or a metadata key cannot be represented, or when `target` names nothing here; and
172 /// whatever else the source could not do the write for.
173 async fn write_task(&self, write: &ItemWrite<Task>) -> Result<NativeId, SourceError> {
174 let _ = write;
175 Err(unwritable(self.kind()))
176 }
177
178 /// Create or update one project, on exactly the terms of
179 /// [`write_task`](Self::write_task).
180 ///
181 /// # Errors
182 ///
183 /// As [`write_task`](Self::write_task).
184 async fn write_project(&self, write: &ItemWrite<Project>) -> Result<NativeId, SourceError> {
185 let _ = write;
186 Err(unwritable(self.kind()))
187 }
188
189 /// Set the status of one task this source holds, and change nothing else about it,
190 /// answering with the status as this source now reads it — or `None` when this source
191 /// holds no such task.
192 ///
193 /// The category lands where this source's own mapping sends it, exactly as a
194 /// [`write_task`](Self::write_task) of a task in that category would: a category this
195 /// source has disabled is refused in the words a write of it is refused with. Title,
196 /// content, labels, metadata, dependencies, [`Task::delivers`], [`Task::delivered_by`],
197 /// project and comments are left exactly as they are.
198 ///
199 /// Defaulted to [`unwritable_field`], which is what keeps this an addition rather than a
200 /// break: a source that cannot write a status on its own needs no edit and refuses by
201 /// saying so. A source declaring [`WriteSupport::Unsupported`] is never asked.
202 ///
203 /// [`Task::delivers`]: crate::Task::delivers
204 /// [`Task::delivered_by`]: crate::Task::delivered_by
205 ///
206 /// # Errors
207 ///
208 /// Returns [`SourceError::Refused`] when this source cannot write a status, or cannot
209 /// write this one; and whatever else the source could not do the write for.
210 async fn set_task_status(
211 &self,
212 id: &NativeId,
213 category: StatusCategory,
214 ) -> Result<Option<Status>, SourceError> {
215 let _ = (id, category);
216 Err(unwritable_field(self.kind(), "status"))
217 }
218
219 /// Set the priority of one task this source holds, and change nothing else about it,
220 /// answering with the priority as this source now reads it — or `None` when this source
221 /// holds no such task.
222 ///
223 /// [`Priority::None`] clears the priority. Title, content, status, labels, metadata,
224 /// repositories, dependencies and comments are left exactly as they are. Nothing about
225 /// the task's status moves, so the engine re-evaluates no delivered task after it.
226 ///
227 /// Defaulted to [`unwritable_field`], which is what keeps this an addition rather than a
228 /// break. A source declaring [`WriteSupport::Unsupported`], or declaring
229 /// [`Capabilities::priority`] unsupported, is never asked.
230 ///
231 /// # Errors
232 ///
233 /// Returns [`SourceError::Refused`] when this source cannot write a priority, or cannot
234 /// write this one — a board with no option for it, naming the option; and whatever else
235 /// the source could not do the write for.
236 async fn set_task_priority(
237 &self,
238 id: &NativeId,
239 priority: Priority,
240 ) -> Result<Option<Priority>, SourceError> {
241 let _ = (id, priority);
242 Err(unwritable_field(self.kind(), "priority"))
243 }
244
245 /// Replace the content of one task this source holds with `content`, byte for byte, and
246 /// change nothing else about it — or answer `None` when this source holds no such task.
247 ///
248 /// The content is [`Task::content`] exactly as this source reports it: what a later read
249 /// answers there is `content`. Where the source keeps something else inside the same
250 /// backend field — a metadata block in an issue body — that is kept as it was, and so is
251 /// every other member: title, status, priority, labels, metadata, repositories,
252 /// dependencies, project and comments. Nothing about the task's status moves, so the
253 /// engine re-evaluates no delivered task after it.
254 ///
255 /// Defaulted to [`unwritable_field`] on exactly the terms of
256 /// [`set_task_status`](Self::set_task_status). A source declaring
257 /// [`WriteSupport::Unsupported`] is never asked.
258 ///
259 /// # Errors
260 ///
261 /// Returns [`SourceError::Refused`] when this source cannot write a task's content on its
262 /// own, or cannot represent this one; and whatever else the source could not do the write
263 /// for.
264 async fn set_task_content(
265 &self,
266 id: &NativeId,
267 content: &str,
268 ) -> Result<Option<()>, SourceError> {
269 let _ = (id, content);
270 Err(unwritable_field(self.kind(), "content"))
271 }
272
273 /// Replace the [`Task::delivered_by`] of one task this source holds, and change nothing
274 /// else about it — or answer `None` when this source holds no such task.
275 ///
276 /// Every entry is a qualified id, and the list is the whole of it: what the task held
277 /// there before is replaced, not merged. It is the store's to keep in step — the engine
278 /// calls this whenever it writes a task's [`Task::delivers`] — and nothing a person types
279 /// reaches it directly.
280 ///
281 /// Defaulted to [`unwritable_field`] on exactly the terms of
282 /// [`set_task_status`](Self::set_task_status).
283 ///
284 /// [`Task::delivers`]: crate::Task::delivers
285 /// [`Task::delivered_by`]: crate::Task::delivered_by
286 ///
287 /// # Errors
288 ///
289 /// Returns [`SourceError::Refused`] when this source cannot hold the list, and whatever
290 /// else it could not do the write for.
291 async fn set_delivered_by(
292 &self,
293 id: &NativeId,
294 delivered_by: &[TaskRef],
295 ) -> Result<Option<()>, SourceError> {
296 let _ = (id, delivered_by);
297 Err(unwritable_field(self.kind(), "delivered_by"))
298 }
299
300 /// Set one key of the metadata of one task this source holds, and change nothing else
301 /// about it, answering with the task as this source reads it back after the write — or
302 /// `None` when this source holds no such task.
303 ///
304 /// The key is added when the task does not hold it and replaced when it does; every other
305 /// metadata key, and every other field of the task, is left exactly as it was. A `value`
306 /// the task already holds under `key` is a write that changes nothing, and a source owes
307 /// it no write at all. The answer is a read, not an echo: what the engine reports as the
308 /// value is what the returned task holds under `key`.
309 ///
310 /// Nothing about the task's status or its [`Task::delivers`] moves, so the engine
311 /// re-evaluates no delivered task after this write.
312 ///
313 /// Defaulted to [`unwritable_metadata`] on exactly the terms of
314 /// [`set_task_status`](Self::set_task_status): a source that cannot write one key on its
315 /// own needs no edit and refuses by saying so. A source declaring
316 /// [`WriteSupport::Unsupported`] is never asked.
317 ///
318 /// [`Task::delivers`]: crate::Task::delivers
319 ///
320 /// # Errors
321 ///
322 /// Returns [`SourceError::Refused`] when this source cannot write one key of a task's
323 /// metadata on its own, or cannot write this one without changing something else; and
324 /// whatever else the source could not do the write for.
325 async fn set_task_metadata(
326 &self,
327 id: &NativeId,
328 key: &MetadataKey,
329 value: &Value,
330 ) -> Result<Option<Task>, SourceError> {
331 let _ = (id, key, value);
332 Err(unwritable_metadata(self.kind(), MetadataRecord::Task))
333 }
334
335 /// Set one key of the metadata of one project this source holds, on exactly the terms of
336 /// [`set_task_metadata`](Self::set_task_metadata).
337 ///
338 /// # Errors
339 ///
340 /// As [`set_task_metadata`](Self::set_task_metadata).
341 async fn set_project_metadata(
342 &self,
343 id: &NativeId,
344 key: &MetadataKey,
345 value: &Value,
346 ) -> Result<Option<Project>, SourceError> {
347 let _ = (id, key, value);
348 Err(unwritable_metadata(self.kind(), MetadataRecord::Project))
349 }
350
351 /// Set one key of the metadata of one document this source holds, on exactly the terms of
352 /// [`set_task_metadata`](Self::set_task_metadata).
353 ///
354 /// A source declaring [`Capabilities::documents`] unsupported is never asked, exactly as
355 /// it is never asked for a document read.
356 ///
357 /// # Errors
358 ///
359 /// As [`set_task_metadata`](Self::set_task_metadata).
360 async fn set_document_metadata(
361 &self,
362 id: &NativeId,
363 key: &MetadataKey,
364 value: &Value,
365 ) -> Result<Option<Document>, SourceError> {
366 let _ = (id, key, value);
367 Err(unwritable_metadata(self.kind(), MetadataRecord::Document))
368 }
369
370 /// Remove one task this destination holds, so a copy that could not finish can put
371 /// the destination back the way it found it.
372 ///
373 /// This is not a verb of the product: nothing a user types deletes anything, and a
374 /// copy never deletes an item it did not itself create in the run that is failing.
375 /// It exists because a copy is either complete or it never happened — a half-written
376 /// project has to be run again, and the re-run is the mutation burst that trips a
377 /// hosted destination's rate limiter. Undoing this run's own creates is what removes
378 /// that retry at source.
379 ///
380 /// A source declaring [`WriteSupport::Supported`] owes a real implementation, for the
381 /// reason it owes [`write_task`](Self::write_task) one: the engine will create items
382 /// there, so it has to be able to remove the ones it created. An `id` naming nothing
383 /// is **not** an error — the item is already gone, which is the state this asks for.
384 ///
385 /// # Errors
386 ///
387 /// Returns [`SourceError::Refused`] when this source has no write side, and whatever
388 /// else the source could not remove the item for.
389 async fn delete_task(&self, id: &NativeId) -> Result<(), SourceError> {
390 let _ = id;
391 Err(unwritable(self.kind()))
392 }
393
394 /// Remove one project this destination holds, on exactly the terms of
395 /// [`delete_task`](Self::delete_task).
396 ///
397 /// # Errors
398 ///
399 /// As [`delete_task`](Self::delete_task).
400 async fn delete_project(&self, id: &NativeId) -> Result<(), SourceError> {
401 let _ = id;
402 Err(unwritable(self.kind()))
403 }
404
405 /// Fetch one document by its native id, or `None` when there is no such document.
406 ///
407 /// Defaulted to [`documentless`], which is what keeps documents an addition rather
408 /// than a break: a source with none needs no edit, keeps working, and says so in the
409 /// same words every other document-free source does. A source that has documents
410 /// declares [`Support::Native`](crate::Support::Native) for
411 /// [`Capabilities::documents`] and owes a real implementation here, because that
412 /// declaration is what makes the engine ask.
413 ///
414 /// # Errors
415 ///
416 /// Returns [`SourceError::Refused`] when this source has no documents, and whatever
417 /// else the source could not answer for.
418 async fn get_document(&self, id: &NativeId) -> Result<Option<Document>, SourceError> {
419 let _ = id;
420 Err(documentless(self.kind()))
421 }
422
423 /// One page of the documents matching `query`.
424 ///
425 /// Defaulted on exactly the terms of [`get_document`](Self::get_document). A source
426 /// with no documents refuses rather than answering an empty page: an empty page reads
427 /// as a source that has documents and holds none matching, which is the one wrong
428 /// answer this method can give.
429 ///
430 /// # Errors
431 ///
432 /// As [`get_document`](Self::get_document).
433 async fn query_documents(
434 &self,
435 query: &DocumentQuery,
436 page: &PageRequest,
437 ) -> Result<Page<Document>, SourceError> {
438 let _ = (query, page);
439 Err(documentless(self.kind()))
440 }
441
442 /// Create or update one document, on exactly the terms of
443 /// [`write_task`](Self::write_task).
444 ///
445 /// # Errors
446 ///
447 /// As [`write_task`](Self::write_task).
448 async fn write_document(&self, write: &ItemWrite<Document>) -> Result<NativeId, SourceError> {
449 let _ = write;
450 Err(unwritable(self.kind()))
451 }
452
453 /// Remove one document this destination holds, on exactly the terms of
454 /// [`delete_task`](Self::delete_task).
455 ///
456 /// # Errors
457 ///
458 /// As [`delete_task`](Self::delete_task).
459 async fn delete_document(&self, id: &NativeId) -> Result<(), SourceError> {
460 let _ = id;
461 Err(unwritable(self.kind()))
462 }
463
464 /// One page of the comments on `task`, oldest first, or `None` when this source holds
465 /// no such task.
466 ///
467 /// Defaulted to [`commentless`], which is what keeps comments an addition rather than a
468 /// break: a source with none needs no edit and keeps working. A source whose tasks have
469 /// comments declares [`Support::Native`](crate::Support::Native) for
470 /// [`Capabilities::comments`] and owes a real implementation of all four comment methods,
471 /// because that declaration is what makes the engine ask.
472 ///
473 /// "No such task" is `None` rather than an error, exactly as it is for
474 /// [`get_task`](Self::get_task); a task that exists and has no comments is an empty page.
475 ///
476 /// # Errors
477 ///
478 /// Returns [`SourceError::Refused`] when this source has no comments, and whatever else
479 /// the source could not answer for.
480 async fn task_comments(
481 &self,
482 task: &NativeId,
483 page: &PageRequest,
484 ) -> Result<Option<Page<Comment>>, SourceError> {
485 let _ = (task, page);
486 Err(commentless(self.kind()))
487 }
488
489 /// Add one comment to `task`, answering with the comment as the source now holds it, or
490 /// `None` when this source holds no such task.
491 ///
492 /// The body is stored byte for byte. A source that records the author itself refuses a
493 /// [`NewComment::author`] rather than dropping it, naming why; a source that cannot
494 /// represent the body refuses it, naming why, rather than escaping it into something
495 /// else.
496 ///
497 /// # Errors
498 ///
499 /// Returns [`SourceError::Refused`] when this source has no comments or cannot be
500 /// written, when it cannot record what it was given, and whatever else it could not do
501 /// the write for.
502 async fn add_comment(
503 &self,
504 task: &NativeId,
505 comment: &NewComment,
506 ) -> Result<Option<Comment>, SourceError> {
507 let _ = (task, comment);
508 Err(commentless(self.kind()))
509 }
510
511 /// Replace the body of the comment `comment` on `task`, answering with the comment as the
512 /// source now holds it, or `None` when this source holds no such task or that task has no
513 /// such comment.
514 ///
515 /// Only the body and the time it last changed move: the id, the author and the time it
516 /// was written are the comment's own.
517 ///
518 /// # Errors
519 ///
520 /// As [`add_comment`](Self::add_comment).
521 async fn edit_comment(
522 &self,
523 task: &NativeId,
524 comment: &NativeId,
525 body: &CommentBody,
526 ) -> Result<Option<Comment>, SourceError> {
527 let _ = (task, comment, body);
528 Err(commentless(self.kind()))
529 }
530
531 /// Remove the comment `comment` from `task`, answering with the id it removed, or `None`
532 /// when this source holds no such task or that task has no such comment.
533 ///
534 /// Unlike [`delete_task`](Self::delete_task), this *is* a verb of the product — a person
535 /// removes a comment they posted — so a comment that is not there is reported as `None`
536 /// for the engine to refuse by name, rather than treated as already gone.
537 ///
538 /// # Errors
539 ///
540 /// As [`add_comment`](Self::add_comment).
541 async fn delete_comment(
542 &self,
543 task: &NativeId,
544 comment: &NativeId,
545 ) -> Result<Option<NativeId>, SourceError> {
546 let _ = (task, comment);
547 Err(commentless(self.kind()))
548 }
549
550 /// What this source has sent to its backend since it was built and what that spent, or
551 /// `None` when it does not meter its own requests.
552 ///
553 /// Defaulted to `None`, which is what keeps metering an addition rather than a break: a
554 /// source that does not count its requests needs no edit, and is reported as not
555 /// metering rather than as having spent nothing. A source that answers owes a running
556 /// total — see [`Metering`] — because what one command spent is read as the difference
557 /// between two readings.
558 ///
559 /// # Errors
560 ///
561 /// Returns a [`SourceError`] when the reading itself could not be taken. A caller
562 /// reports such a source as not metering; what a command cost is never a reason for the
563 /// command to fail.
564 async fn metering(&self) -> Result<Option<Metering>, SourceError> {
565 Ok(None)
566 }
567}
568
569/// The factory that turns one configuration block into a live [`TaskSource`].
570///
571/// Having the compile-time registry and the subprocess seam be the same shape is
572/// the whole reason this is a trait rather than a free function.
573pub trait SourcePlugin: Send + Sync + 'static {
574 /// The name a configuration document's `plugin:` field names.
575 fn kind(&self) -> &'static str;
576
577 /// The JSON Schema for this plugin's own `config:` block.
578 fn config_schema(&self) -> Schema;
579
580 /// Build a live source from one configuration block.
581 ///
582 /// `name` is the configured source's name, for error messages only — a
583 /// plugin never learns it for any other purpose.
584 ///
585 /// # Errors
586 ///
587 /// Returns [`SourceError::Config`] when `config` is not valid for this
588 /// plugin, or [`SourceError::Auth`] when a named credential is absent.
589 fn build(
590 &self,
591 name: &SourceName,
592 config: &serde_json::Value,
593 secrets: &dyn SecretResolver,
594 ) -> Result<Box<dyn TaskSource>, SourceError>;
595
596 /// The fields of this plugin's `config:` block that name a filesystem path, as dotted
597 /// paths into that block.
598 ///
599 /// A relative value at one of these, **supplied by a configuration document**, is
600 /// resolved against the directory holding that document before [`Self::build`] sees it;
601 /// supplied through the environment or a flag it keeps resolving against the process
602 /// working directory, because there is no document to rebase it on. A plugin is handed
603 /// values and no origins, so this declaration is the only way it can say which of its
604 /// own fields that rule reaches.
605 ///
606 /// Defaulted to none, which is what keeps this an addition rather than a break: a
607 /// plugin whose block holds no path needs no edit, and a caller asks every plugin
608 /// rather than keeping a table of which ones answer.
609 // llmlint: ignore[invalid_states_unrepresentable] The identity of a configuration field
610 // is a name, and no type can make a wrong one unrepresentable here: every string is a
611 // syntactically valid dotted path, so a newtype would validate nothing and would only
612 // move where a name that is not a field of *this* plugin is accepted. What decides that
613 // is whether the name is a property of the schema `config_schema` publishes — a
614 // per-plugin fact no shared type can hold — so the gate is per plugin and executable:
615 // `document_relative_fields_are_fields_this_plugin_declares` in
616 // `onetaskgraph-local-md/tests/plugin.rs`, which a plugin adding a declaration owes its
617 // own copy of.
618 fn document_relative_paths(&self) -> &'static [&'static str] {
619 &[]
620 }
621}
622
623/// How a plugin reads the credential its configuration names.
624///
625/// A configuration document never carries a credential value, only the name of
626/// the environment variable holding it.
627pub trait SecretResolver: Send + Sync {
628 /// The value of `var`, or `None` when nothing defines it.
629 ///
630 /// The returned value is never logged and never appears in `Debug` output.
631 fn get(&self, var: &str) -> Option<SecretString>;
632}