asimov_patterns/programs.rs
1// This is free and unencumbered software released into the public domain.
2
3//! Role-specific execution traits and command-line configuration values.
4//!
5//! Each trait is a marker extending [`Execute`](crate::Execute). It identifies
6//! the intended operation but adds no constructor, input parameter, or runtime
7//! validation. `T` is the result type; the implementation chooses the associated
8//! [`Error`](crate::Execute::Error) type. Bounds can constrain it with, for example,
9//! `Fetcher<T, Error = E>`. [`Indexer`] has no type parameters and uses `()` for
10//! its result; its error can likewise be constrained with `Indexer<Error = E>`.
11//!
12//! # Pattern catalog
13//!
14//! | Trait | Logical input | Logical output | Options |
15//! | --- | --- | --- | --- |
16//! | [`Adapter`] | SPARQL query | RDF query result | [`AdapterOptions`] |
17//! | [`Compiler`] | Natural-language text | SPARQL query | [`CompilerOptions`] |
18//! | [`Emitter`] | None | Generated RDF | [`EmitterOptions`] |
19//! | [`Fetcher`] | One URL | RDF describing the resource | [`FetcherOptions`] |
20//! | [`Indexer`] | RDF | None; updates a persistent index | [`IndexerOptions`] |
21//! | [`Lister`] | One collection URL | RDF describing zero or more entries | [`ListerOptions`] |
22//! | [`Matcher`] | RDF | RDF describing matches | [`MatcherOptions`] |
23//! | [`Prompter`] | Prompt text | Response text | [`PrompterOptions`] |
24//! | [`Reader`] | Document or byte stream | Imported RDF | [`ReaderOptions`] |
25//! | [`Reasoner`] | RDF | Entailed RDF | [`ReasonerOptions`] |
26//! | [`Resolver`] | One URI | Zero or more URLs | [`ResolverOptions`] |
27//! | [`Runner`] | Program text | Execution result as text | [`RunnerOptions`] |
28//! | [`Writer`] | RDF | Exported document or byte stream | [`WriterOptions`] |
29//!
30//! All thirteen patterns in the [specification][pps] have corresponding traits
31//! here and process wrappers in `asimov-runner`. RDF in this table denotes
32//! graphs or datasets, not individual statements, records, or buffers.
33//!
34//! # Results and streaming
35//!
36//! These traits prescribe semantic roles, not buffering, stream types, or
37//! process management. A streaming implementation must distinguish successful
38//! startup from eventual completion and expose later errors through its result.
39//! Receiving output alone does not establish success; see [`Execute`](crate::Execute).
40//!
41//! Concrete behavior is documented in [`asimov-runner`][runner]: consult its
42//! [execution and results][results] section for result types, input ownership,
43//! output routing, and cancellation; [completion outcomes][completion] for error
44//! precedence; and [JSONL transport][jsonl] for graph framing, batching, and composition.
45//! The runner's [linear pipelines][pipelines] connect compatible process-backed
46//! programs and coordinate their completion independently of these marker traits.
47//!
48//! # Native capabilities
49//!
50//! [`ListerCapabilities`] describes optional native sorting, numeric offset,
51//! URI cursor (`before`/`after`), and limit support separately from the requests
52//! in [`ListerOptions`]. Each capability uses
53//! [`OptionSupport`](crate::OptionSupport): unknown, supported, or unsupported.
54//! Callers can translate manifest metadata into these values without this crate
55//! depending on a manifest schema. Capabilities do not imply host emulation;
56//! forwarding and fallback policies are documented by the concrete executor.
57//!
58//! # Options and defaults
59//!
60//! Every options type supports `Default`, direct field access, and a
61//! `builder()`. Defaults leave optional fields unset and collections empty;
62//! builders accept values convertible to `String` for string fields. Values
63//! are stored without checking whether the selected program supports them.
64//!
65//! The companion [`asimov-runner`][runner] wrappers emit configured fields as
66//! individual `--name=value` arguments according to supplied capabilities. Hosts
67//! may enforce a limit instead of forwarding an unsupported flag, and may also
68//! enforce it independently to protect against program bugs. `None` omits an
69//! option rather than supplying an empty value. Programs apply these defaults:
70//!
71//! | Patterns | Input format | Output format | Other defaults |
72//! | --- | --- | --- | --- |
73//! | Adapter, emitter, fetcher | No input-format option | `jsonl` | — |
74//! | Compiler | No input-format option | No output-format option | No pattern-specific options |
75//! | Indexer | `jsonl` | No output-format option | Index destination required |
76//! | Lister | No input-format option | `jsonl` | No limit or cursor bounds; offset `0`; program-defined order |
77//! | Matcher, reasoner | `jsonl` | `jsonl` | — |
78//! | Prompter | `text` | `text` | Model `auto` |
79//! | Reader | `auto` | `jsonl` | — |
80//! | Resolver | No input-format option | No output-format option | No limit |
81//! | Runner | No input-format option | No output-format option | No definitions |
82//! | Writer | `jsonl` | `auto` | — |
83//!
84//! `text` means UTF-8 without a standardized chat envelope. `auto` delegates
85//! format detection or selection to the program. `jsonl` needs a documented
86//! [RDF mapping profile][rdf-mapping] shared by producer and consumer. Setting
87//! a format option does not encode, decode, or convert any bytes in this crate.
88//!
89//! # Additional arguments and files
90//!
91//! Each `other` vector is an ordered argument list, not a shell command. The
92//! runner appends its entries after generated options and before a dedicated
93//! URL or URI operand. Each entry is passed verbatim as one argument: use two
94//! entries for `--name value`, or one for `--name=value`. Do not add shell quotes
95//! or redirection syntax. Repeated builder `other(...)` calls append; the
96//! `maybe_other(...)` helpers append only `Some` values.
97//!
98//! Additional arguments can supply documented extensions or positional files.
99//! Keep options before operands; use `--` to end option parsing when a filename
100//! begins with `-`. Avoid repeating singleton options already set in fields:
101//! precedence is program-defined, so `other` is not an override mechanism.
102//!
103//! **Format selection and file selection are separate.** For patterns with
104//! optional input/output files, no operands select stdin/stdout, one operand
105//! selects the input file, and two select input then output. To read stdin and
106//! write a file, supply `-` followed by the output path. An indexer instead
107//! requires its final operand to name the persistent index. See each trait's
108//! synopsis for the applicable operand rules.
109//!
110//! A named input file replaces stdin as the payload source, and a named output
111//! file replaces stdout as the destination. Consult the concrete invocation API
112//! for file selection and stream-routing behavior; see the [runner's file operands][files].
113//!
114//! [pps]: https://asimov-specs.github.io/program-patterns/#patterns
115//! [runner]: https://docs.rs/asimov-runner/latest/asimov_runner/programs/
116//! [results]: https://docs.rs/asimov-runner/latest/asimov_runner/programs/#execution-and-results
117//! [completion]: https://docs.rs/asimov-runner/latest/asimov_runner/struct.ExecutionCompletion.html
118//! [jsonl]: https://docs.rs/asimov-runner/latest/asimov_runner/jsonl/
119//! [pipelines]: https://docs.rs/asimov-runner/latest/asimov_runner/pipeline/
120//! [files]: https://docs.rs/asimov-runner/latest/asimov_runner/programs/#file-operands
121//! [rdf-mapping]: https://asimov-specs.github.io/program-patterns/#rdf-mapping
122
123mod adapter;
124pub use adapter::*;
125
126mod compiler;
127pub use compiler::*;
128
129mod lister;
130pub use lister::*;
131
132mod emitter;
133pub use emitter::*;
134
135mod fetcher;
136pub use fetcher::*;
137
138mod indexer;
139pub use indexer::*;
140
141mod matcher;
142pub use matcher::*;
143
144mod prompter;
145pub use prompter::*;
146
147mod reader;
148pub use reader::*;
149
150mod reasoner;
151pub use reasoner::*;
152
153mod resolver;
154pub use resolver::*;
155
156mod runner;
157pub use runner::*;
158
159mod writer;
160pub use writer::*;