Skip to main content

pharos_native/runtime/
ops_bridge.rs

1//! Native operational helpers migrated from the runtime ops and helper surfaces.
2//!
3//! The functions are deliberately data- and filesystem-only. They do not spawn
4//! shell commands, interpolate untrusted SQL, or write outside caller-selected roots.
5
6use serde_json::Value;
7use std::path::{Path, PathBuf};
8
9use crate::config::ServeConfig;
10
11/// Appends the shared app flags to an owned argv vector in stable order.
12///
13/// # Parameters
14///
15/// - `config`: Input consumed by [`crate::runtime::ops_bridge::append_app_common_flags`].
16/// - `argv`: Input consumed by [`crate::runtime::ops_bridge::append_app_common_flags`].
17///
18/// # Returns
19///
20/// Returns after [`crate::runtime::ops_bridge::append_app_common_flags`] applies its in-place effect.
21///
22/// # Performance
23///
24/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::ops_bridge::append_app_common_flags`].
25///
26/// # Examples
27///
28/// ```rust,ignore
29/// let _result = pharos_native::runtime::ops_bridge::append_app_common_flags(todo!(), todo!());
30/// ```
31///
32/// # Related
33///
34/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
35pub fn append_app_common_flags(config: &ServeConfig, argv: &mut Vec<String>) {
36    let flags = [
37        ("--conf", config.conf_path.as_deref()),
38        ("--app-dir", config.app_dir.as_deref()),
39        ("--build-dir", config.build_dir.as_deref()),
40        ("--state-dir", config.state_dir.as_deref()),
41        ("--state-path", config.state_path.as_deref()),
42        ("--base-path", config.base_path.as_deref()),
43    ];
44    for (flag, value) in flags {
45        if let Some(value) = value.filter(|value| !value.is_empty()) {
46            argv.push(flag.to_owned());
47            argv.push(value.to_owned());
48        }
49    }
50}
51
52/// Fails closed for the retired shell runtime bridge; Rust dispatch owns behavior directly.
53///
54/// # Parameters
55///
56/// - `_repo_root`: Input consumed by [`crate::runtime::ops_bridge::runtime_script_path`].
57///
58/// # Returns
59///
60/// Returns [`Some`] when [`crate::runtime::ops_bridge::runtime_script_path`] can produce a value and [`None`] otherwise.
61///
62/// # Examples
63///
64/// ```rust,ignore
65/// let _result = pharos_native::runtime::ops_bridge::runtime_script_path(todo!());
66/// ```
67///
68/// # Related
69///
70/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
71pub fn runtime_script_path(_repo_root: &Path) -> Option<PathBuf> {
72    None
73}
74
75/// Fails closed for the retired shell runtime bridge; Rust dispatch owns behavior directly.
76///
77/// # Parameters
78///
79/// - `_repo_root`: Input consumed by [`crate::runtime::ops_bridge::shell_runtime_command_capture`].
80/// - `_args`: Input consumed by [`crate::runtime::ops_bridge::shell_runtime_command_capture`].
81///
82/// # Returns
83///
84/// Returns the successful value produced by [`crate::runtime::ops_bridge::shell_runtime_command_capture`] or an error when the operation fails.
85///
86/// # Errors
87///
88/// Returns an error value when [`crate::runtime::ops_bridge::shell_runtime_command_capture`] cannot complete successfully.
89///
90/// # Examples
91///
92/// ```rust,ignore
93/// let _result = pharos_native::runtime::ops_bridge::shell_runtime_command_capture(todo!(), todo!());
94/// ```
95///
96/// # Related
97///
98/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
99pub fn shell_runtime_command_capture(_repo_root: &Path, _args: &[String]) -> Result<String, i32> {
100    Err(78)
101}
102
103/// Appends one owned argument while enforcing a fixed command-vector bound.
104///
105/// # Parameters
106///
107/// - `argv`: Input consumed by [`crate::runtime::ops_bridge::push_argv_value`].
108/// - `value`: Input consumed by [`crate::runtime::ops_bridge::push_argv_value`].
109/// - `capacity`: Input consumed by [`crate::runtime::ops_bridge::push_argv_value`].
110///
111/// # Returns
112///
113/// Returns the computed value produced by [`crate::runtime::ops_bridge::push_argv_value`].
114///
115/// # Examples
116///
117/// ```rust,ignore
118/// let _result = pharos_native::runtime::ops_bridge::push_argv_value(todo!(), "value", todo!());
119/// ```
120///
121/// # Related
122///
123/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
124pub fn push_argv_value(argv: &mut Vec<String>, value: Option<&str>, capacity: usize) -> i32 {
125    pharos_runtime_ops::push_argv_value(argv, value, capacity)
126}
127
128/// Removes a temporary request body and clears its ownership slot.
129///
130/// # Parameters
131///
132/// - `path`: Input consumed by [`crate::runtime::ops_bridge::cleanup_temp_body_file`].
133///
134/// # Returns
135///
136/// Returns after [`crate::runtime::ops_bridge::cleanup_temp_body_file`] applies its in-place effect.
137///
138/// # Examples
139///
140/// ```rust,ignore
141/// let _result = pharos_native::runtime::ops_bridge::cleanup_temp_body_file(std::path::Path::new("fixture.json"));
142/// ```
143///
144/// # Related
145///
146/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
147pub fn cleanup_temp_body_file(path: &mut Option<PathBuf>) {
148    pharos_runtime_ops::cleanup_temp_body_file(path)
149}
150
151/// Writes a bounded request body to a uniquely-created temporary file.
152///
153/// # Parameters
154///
155/// - `body`: Input consumed by [`crate::runtime::ops_bridge::write_temp_body_file`].
156///
157/// # Returns
158///
159/// Returns the successful value produced by [`crate::runtime::ops_bridge::write_temp_body_file`] or an error when the operation fails.
160///
161/// # Errors
162///
163/// Returns an error value when [`crate::runtime::ops_bridge::write_temp_body_file`] cannot complete successfully.
164///
165/// # Examples
166///
167/// ```rust,ignore
168/// let _result = pharos_native::runtime::ops_bridge::write_temp_body_file(b"");
169/// ```
170///
171/// # Related
172///
173/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
174pub fn write_temp_body_file(body: Option<&[u8]>) -> Result<PathBuf, i32> {
175    pharos_runtime_ops::write_temp_body_file(body)
176}
177
178/// Returns whether text is safe for an identifier position.
179///
180/// # Parameters
181///
182/// - `text`: Input consumed by [`crate::runtime::ops_bridge::identifier_safe`].
183///
184/// # Returns
185///
186/// Returns `true` when the condition checked by [`crate::runtime::ops_bridge::identifier_safe`] holds and `false` otherwise.
187///
188/// # Performance
189///
190/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::ops_bridge::identifier_safe`].
191///
192/// # Examples
193///
194/// ```rust,ignore
195/// let _result = pharos_native::runtime::ops_bridge::identifier_safe("{}");
196/// ```
197///
198/// # Related
199///
200/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
201pub fn identifier_safe(text: &str) -> bool {
202    pharos_runtime_ops::identifier_safe(text)
203}
204
205/// Escapes a value for a SQL string literal without constructing a query.
206///
207/// # Parameters
208///
209/// - `text`: Input consumed by [`crate::runtime::ops_bridge::sql_literal_escape`].
210///
211/// # Returns
212///
213/// Returns the computed value produced by [`crate::runtime::ops_bridge::sql_literal_escape`].
214///
215/// # Examples
216///
217/// ```rust,ignore
218/// let _result = pharos_native::runtime::ops_bridge::sql_literal_escape("{}");
219/// ```
220///
221/// # Related
222///
223/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
224pub fn sql_literal_escape(text: &str) -> String {
225    pharos_runtime_ops::sql_literal_escape(text)
226}
227
228/// Trims a captured command-like value while rejecting control characters.
229///
230/// # Parameters
231///
232/// - `text`: Input consumed by [`crate::runtime::ops_bridge::capture_trimmed`].
233///
234/// # Returns
235///
236/// Returns [`Some`] when [`crate::runtime::ops_bridge::capture_trimmed`] can produce a value and [`None`] otherwise.
237///
238/// # Performance
239///
240/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::ops_bridge::capture_trimmed`].
241///
242/// # Examples
243///
244/// ```rust,ignore
245/// let _result = pharos_native::runtime::ops_bridge::capture_trimmed("{}");
246/// ```
247///
248/// # Related
249///
250/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
251pub fn capture_trimmed(text: &str) -> Option<String> {
252    pharos_runtime_ops::capture_trimmed(text)
253}
254
255/// Returns whether a deployment packaging directory is present and usable.
256///
257/// # Parameters
258///
259/// - `root`: Input consumed by [`crate::runtime::ops_bridge::cross_deb_packaging_available`].
260///
261/// # Returns
262///
263/// Returns `true` when the condition checked by [`crate::runtime::ops_bridge::cross_deb_packaging_available`] holds and `false` otherwise.
264///
265/// # Examples
266///
267/// ```rust,ignore
268/// let _result = pharos_native::runtime::ops_bridge::cross_deb_packaging_available(std::path::Path::new("."));
269/// ```
270///
271/// # Related
272///
273/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
274pub fn cross_deb_packaging_available(root: &Path) -> bool {
275    pharos_runtime_ops::cross_deb_packaging_available(root)
276}
277
278/// Checks whether an executable is available on PATH without invoking it.
279///
280/// # Parameters
281///
282/// - `command`: Input consumed by [`crate::runtime::ops_bridge::command_exists`].
283///
284/// # Returns
285///
286/// Returns `true` when the condition checked by [`crate::runtime::ops_bridge::command_exists`] holds and `false` otherwise.
287///
288/// # Examples
289///
290/// ```rust,ignore
291/// let _result = pharos_native::runtime::ops_bridge::command_exists(todo!());
292/// ```
293///
294/// # Related
295///
296/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
297pub fn command_exists(command: &str) -> bool {
298    pharos_runtime_ops::command_exists(command)
299}
300
301/// Appends one bounded access-log line to a runtime-owned log file.
302///
303/// # Parameters
304///
305/// - `path`: Input consumed by [`crate::runtime::ops_bridge::write_error_log`].
306/// - `app_id`: Input consumed by [`crate::runtime::ops_bridge::write_error_log`].
307/// - `method`: Input consumed by [`crate::runtime::ops_bridge::write_error_log`].
308/// - `request_path`: Input consumed by [`crate::runtime::ops_bridge::write_error_log`].
309/// - `status_text`: Input consumed by [`crate::runtime::ops_bridge::write_error_log`].
310/// - `reason`: Input consumed by [`crate::runtime::ops_bridge::write_error_log`].
311///
312/// # Returns
313///
314/// Returns the computed value produced by [`crate::runtime::ops_bridge::write_error_log`].
315///
316/// # Performance
317///
318/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::ops_bridge::write_error_log`].
319///
320/// # Examples
321///
322/// ```rust,ignore
323/// let _result = pharos_native::runtime::ops_bridge::write_error_log(std::path::Path::new("fixture.json"), todo!(), todo!(), "/", "400 Bad Request", todo!());
324/// ```
325///
326/// # Related
327///
328/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
329pub fn write_error_log(
330    path: &Path,
331    app_id: Option<&str>,
332    method: Option<&str>,
333    request_path: Option<&str>,
334    status_text: Option<&str>,
335    reason: Option<&str>,
336) -> i32 {
337    pharos_runtime_ops::write_error_log(path, app_id, method, request_path, status_text, reason)
338}
339
340/// Writes access log.
341///
342/// # Parameters
343///
344/// - `path`: Input consumed by [`crate::runtime::ops_bridge::write_access_log`].
345/// - `line`: Input consumed by [`crate::runtime::ops_bridge::write_access_log`].
346///
347/// # Returns
348///
349/// Returns the computed value produced by [`crate::runtime::ops_bridge::write_access_log`].
350///
351/// # Performance
352///
353/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::ops_bridge::write_access_log`].
354///
355/// # Examples
356///
357/// ```rust,ignore
358/// let _result = pharos_native::runtime::ops_bridge::write_access_log(std::path::Path::new("fixture.json"), todo!());
359/// ```
360///
361/// # Related
362///
363/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
364pub fn write_access_log(path: &Path, line: &str) -> i32 {
365    pharos_runtime_ops::write_access_log(path, line)
366}
367
368/// Resolves the configured HTTP body limit with a bounded default.
369///
370/// # Parameters
371///
372/// - `value`: Input consumed by [`crate::runtime::ops_bridge::http_body_limit`].
373///
374/// # Returns
375///
376/// Returns the computed value produced by [`crate::runtime::ops_bridge::http_body_limit`].
377///
378/// # Examples
379///
380/// ```rust,ignore
381/// let _result = pharos_native::runtime::ops_bridge::http_body_limit("value");
382/// ```
383///
384/// # Related
385///
386/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
387pub fn http_body_limit(value: Option<i64>) -> usize {
388    pharos_runtime_ops::http_body_limit(value)
389}
390
391/// Spools a bounded request body to a caller-selected temporary path.
392///
393/// # Parameters
394///
395/// - `path`: Input consumed by [`crate::runtime::ops_bridge::spool_request_body_to_temp_file`].
396/// - `body`: Input consumed by [`crate::runtime::ops_bridge::spool_request_body_to_temp_file`].
397///
398/// # Returns
399///
400/// Returns the computed value produced by [`crate::runtime::ops_bridge::spool_request_body_to_temp_file`].
401///
402/// # Examples
403///
404/// ```rust,ignore
405/// let _result = pharos_native::runtime::ops_bridge::spool_request_body_to_temp_file(std::path::Path::new("fixture.json"), b"");
406/// ```
407///
408/// # Related
409///
410/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
411pub fn spool_request_body_to_temp_file(path: &Path, body: &[u8]) -> i32 {
412    pharos_runtime_ops::spool_request_body_to_temp_file(path, body)
413}
414
415/// Appends an escaped key/value pair to PostgreSQL conninfo text.
416///
417/// # Parameters
418///
419/// - `output`: Input consumed by [`crate::runtime::ops_bridge::conninfo_append_kv`].
420/// - `key`: Input consumed by [`crate::runtime::ops_bridge::conninfo_append_kv`].
421/// - `value`: Input consumed by [`crate::runtime::ops_bridge::conninfo_append_kv`].
422///
423/// # Returns
424///
425/// Returns `true` when the condition checked by [`crate::runtime::ops_bridge::conninfo_append_kv`] holds and `false` otherwise.
426///
427/// # Examples
428///
429/// ```rust,ignore
430/// let _result = pharos_native::runtime::ops_bridge::conninfo_append_kv(todo!(), "key", "value");
431/// ```
432///
433/// # Related
434///
435/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
436pub fn conninfo_append_kv(output: &mut String, key: &str, value: &str) -> bool {
437    pharos_runtime_ops::conninfo_append(output, key, value)
438}
439
440/// Returns whether a configured PostgreSQL adapter handle candidate is usable.
441///
442/// # Parameters
443///
444/// - `candidate`: Input consumed by [`crate::runtime::ops_bridge::open_libpq_handle_candidate`].
445///
446/// # Returns
447///
448/// Returns `true` when the condition checked by [`crate::runtime::ops_bridge::open_libpq_handle_candidate`] holds and `false` otherwise.
449///
450/// # Examples
451///
452/// ```rust,ignore
453/// let _result = pharos_native::runtime::ops_bridge::open_libpq_handle_candidate(todo!());
454/// ```
455///
456/// # Related
457///
458/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
459pub fn open_libpq_handle_candidate(candidate: Option<&Path>) -> bool {
460    pharos_runtime_ops::open_libpq_handle_candidate(candidate)
461}
462
463/// Converts a JSON scalar into a bounded signed integer.
464///
465/// # Parameters
466///
467/// - `value`: Input consumed by [`crate::runtime::ops_bridge::long_from_value`].
468///
469/// # Returns
470///
471/// Returns the computed value produced by [`crate::runtime::ops_bridge::long_from_value`].
472///
473/// # Examples
474///
475/// ```rust,ignore
476/// let _result = pharos_native::runtime::ops_bridge::long_from_value("value");
477/// ```
478///
479/// # Related
480///
481/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
482pub fn long_from_value(value: &Value) -> i64 {
483    pharos_runtime_ops::long_from_value(value)
484}
485
486/// Reports whether a SQLite database path is readable and regular.
487///
488/// # Parameters
489///
490/// - `path`: Input consumed by [`crate::runtime::ops_bridge::db_check_json`].
491///
492/// # Returns
493///
494/// Returns the successful value produced by [`crate::runtime::ops_bridge::db_check_json`] or an error when the operation fails.
495///
496/// # Errors
497///
498/// Returns an error value when [`crate::runtime::ops_bridge::db_check_json`] cannot complete successfully.
499///
500/// # Examples
501///
502/// ```rust,ignore
503/// let _result = pharos_native::runtime::ops_bridge::db_check_json(std::path::Path::new("fixture.json"));
504/// ```
505///
506/// # Related
507///
508/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
509pub fn db_check_json(path: &Path) -> Result<String, &'static str> {
510    pharos_runtime_ops::db_check_json(path)
511}
512
513/// Resolves an explicitly configured database backend.
514///
515/// # Parameters
516///
517/// - `app_root`: Input consumed by [`crate::runtime::ops_bridge::default_backend`].
518/// - `runtime_conf_path`: Input consumed by [`crate::runtime::ops_bridge::default_backend`].
519///
520/// # Returns
521///
522/// Returns [`Some`] when [`crate::runtime::ops_bridge::default_backend`] can produce a value and [`None`] otherwise.
523///
524/// # Examples
525///
526/// ```rust,ignore
527/// let _result = pharos_native::runtime::ops_bridge::default_backend(std::path::Path::new("apps/dev_docs"), todo!());
528/// ```
529///
530/// # Related
531///
532/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
533pub fn default_backend(app_root: &Path, runtime_conf_path: Option<&Path>) -> Option<String> {
534    super::database::dynamic_relational_backend(app_root, runtime_conf_path)
535}
536
537/// Returns a bounded JSON description of one output path.
538///
539/// # Parameters
540///
541/// - `path`: Input consumed by [`crate::runtime::ops_bridge::output_path_status`].
542///
543/// # Returns
544///
545/// Returns the successful value produced by [`crate::runtime::ops_bridge::output_path_status`] or an error when the operation fails.
546///
547/// # Errors
548///
549/// Returns an error value when [`crate::runtime::ops_bridge::output_path_status`] cannot complete successfully.
550///
551/// # Examples
552///
553/// ```rust,ignore
554/// let _result = pharos_native::runtime::ops_bridge::output_path_status(std::path::Path::new("fixture.json"));
555/// ```
556///
557/// # Related
558///
559/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
560pub fn output_path_status(path: &Path) -> Result<String, i32> {
561    pharos_runtime_ops::output_path_status(path)
562}
563
564/// Returns the default native execution environment.
565///
566/// # Returns
567///
568/// Returns the computed value produced by [`crate::runtime::ops_bridge::default_environment`].
569///
570/// # Examples
571///
572/// ```rust,ignore
573/// let _result = pharos_native::runtime::ops_bridge::default_environment();
574/// ```
575///
576/// # Related
577///
578/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
579pub fn default_environment() -> &'static str {
580    pharos_runtime_ops::default_environment()
581}
582
583/// Validates a supported runtime environment name.
584///
585/// # Parameters
586///
587/// - `environment`: Input consumed by [`crate::runtime::ops_bridge::environment_valid`].
588///
589/// # Returns
590///
591/// Returns `true` when the condition checked by [`crate::runtime::ops_bridge::environment_valid`] holds and `false` otherwise.
592///
593/// # Examples
594///
595/// ```rust,ignore
596/// let _result = pharos_native::runtime::ops_bridge::environment_valid(todo!());
597/// ```
598///
599/// # Related
600///
601/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
602pub fn environment_valid(environment: &str) -> bool {
603    pharos_runtime_ops::environment_valid(environment)
604}
605
606/// Checks one output path and returns its bounded JSON disposition.
607///
608/// # Parameters
609///
610/// - `path`: Input consumed by [`crate::runtime::ops_bridge::output_path_check_json`].
611///
612/// # Returns
613///
614/// Returns the successful value produced by [`crate::runtime::ops_bridge::output_path_check_json`] or an error when the operation fails.
615///
616/// # Errors
617///
618/// Returns an error value when [`crate::runtime::ops_bridge::output_path_check_json`] cannot complete successfully.
619///
620/// # Examples
621///
622/// ```rust,ignore
623/// let _result = pharos_native::runtime::ops_bridge::output_path_check_json(std::path::Path::new("fixture.json"));
624/// ```
625///
626/// # Related
627///
628/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
629pub fn output_path_check_json(path: &Path) -> Result<String, &'static str> {
630    pharos_runtime_ops::output_path_check_json(path)
631}
632
633/// Appends one SQL-literal character with the escaping required by SQLite and PostgreSQL.
634///
635/// # Parameters
636///
637/// - `output`: Input consumed by [`crate::runtime::ops_bridge::append_escaped_sql_char`].
638/// - `character`: Input consumed by [`crate::runtime::ops_bridge::append_escaped_sql_char`].
639///
640/// # Returns
641///
642/// Returns `true` when the condition checked by [`crate::runtime::ops_bridge::append_escaped_sql_char`] holds and `false` otherwise.
643///
644/// # Examples
645///
646/// ```rust,ignore
647/// let _result = pharos_native::runtime::ops_bridge::append_escaped_sql_char(todo!(), todo!());
648/// ```
649///
650/// # Related
651///
652/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
653pub fn append_escaped_sql_char(output: &mut String, character: char) -> bool {
654    pharos_runtime_ops::append_escaped_sql_char(output, character)
655}
656
657/// Writes macOS-compatible no-index markers to a directory tree.
658///
659/// # Parameters
660///
661/// - `root`: Input consumed by [`crate::runtime::ops_bridge::write_noindex_markers_recursive`].
662///
663/// # Returns
664///
665/// Returns the successful value produced by [`crate::runtime::ops_bridge::write_noindex_markers_recursive`] or an error when the operation fails.
666///
667/// # Errors
668///
669/// Returns an error value when [`crate::runtime::ops_bridge::write_noindex_markers_recursive`] cannot complete successfully.
670///
671/// # Examples
672///
673/// ```rust,ignore
674/// let _result = pharos_native::runtime::ops_bridge::write_noindex_markers_recursive(std::path::Path::new("."));
675/// ```
676///
677/// # Related
678///
679/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
680pub fn write_noindex_markers_recursive(root: &Path) -> Result<usize, &'static str> {
681    pharos_runtime_ops::write_noindex_markers_recursive(root)
682}
683
684/// Matches the native operational command tuple exactly enough for dispatch.
685///
686/// # Parameters
687///
688/// - `args`: Input consumed by [`crate::runtime::ops_bridge::match_ops_command`].
689/// - `first`: Input consumed by [`crate::runtime::ops_bridge::match_ops_command`].
690/// - `second`: Input consumed by [`crate::runtime::ops_bridge::match_ops_command`].
691/// - `third`: Input consumed by [`crate::runtime::ops_bridge::match_ops_command`].
692///
693/// # Returns
694///
695/// Returns `true` when the condition checked by [`crate::runtime::ops_bridge::match_ops_command`] holds and `false` otherwise.
696///
697/// # Examples
698///
699/// ```rust,ignore
700/// let _result = pharos_native::runtime::ops_bridge::match_ops_command(todo!(), todo!(), todo!(), todo!());
701/// ```
702///
703/// # Related
704///
705/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
706pub fn match_ops_command(args: &[String], first: &str, second: &str, third: Option<&str>) -> bool {
707    pharos_runtime_ops::match_ops_command(args, first, second, third)
708}
709
710/// Normalizes an app-relative base path without allowing traversal.
711///
712/// # Parameters
713///
714/// - `value`: Input consumed by [`crate::runtime::ops_bridge::normalize_base_path`].
715///
716/// # Returns
717///
718/// Returns [`Some`] when [`crate::runtime::ops_bridge::normalize_base_path`] can produce a value and [`None`] otherwise.
719///
720/// # Performance
721///
722/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::ops_bridge::normalize_base_path`].
723///
724/// # Examples
725///
726/// ```rust,ignore
727/// let _result = pharos_native::runtime::ops_bridge::normalize_base_path("value");
728/// ```
729///
730/// # Related
731///
732/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
733pub fn normalize_base_path(value: &str) -> Option<String> {
734    pharos_runtime_ops::normalize_base_path(value)
735}
736
737/// Returns a path under a trusted root for a validated relative helper value.
738///
739/// # Parameters
740///
741/// - `root`: Input consumed by [`crate::runtime::ops_bridge::resolve_runtime_path`].
742/// - `relative`: Input consumed by [`crate::runtime::ops_bridge::resolve_runtime_path`].
743///
744/// # Returns
745///
746/// Returns [`Some`] when [`crate::runtime::ops_bridge::resolve_runtime_path`] can produce a value and [`None`] otherwise.
747///
748/// # Performance
749///
750/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::ops_bridge::resolve_runtime_path`].
751///
752/// # Examples
753///
754/// ```rust,ignore
755/// let _result = pharos_native::runtime::ops_bridge::resolve_runtime_path(std::path::Path::new("."), todo!());
756/// ```
757///
758/// # Related
759///
760/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
761pub fn resolve_runtime_path(root: &Path, relative: &str) -> Option<PathBuf> {
762    pharos_runtime_ops::resolve_runtime_path(root, relative)
763}
764
765/// Builds a bounded deployment-check report from declarative metadata.
766///
767/// # Parameters
768///
769/// - `app_root`: Input consumed by [`crate::runtime::ops_bridge::build_app_deploy_check_report_local_json`].
770/// - `target_id`: Input consumed by [`crate::runtime::ops_bridge::build_app_deploy_check_report_local_json`].
771///
772/// # Returns
773///
774/// Returns the successful value produced by [`crate::runtime::ops_bridge::build_app_deploy_check_report_local_json`] or an error when the operation fails.
775///
776/// # Errors
777///
778/// Returns an error value when [`crate::runtime::ops_bridge::build_app_deploy_check_report_local_json`] cannot complete successfully.
779///
780/// # Examples
781///
782/// ```rust,ignore
783/// let _result = pharos_native::runtime::ops_bridge::build_app_deploy_check_report_local_json(std::path::Path::new("apps/dev_docs"), "dev_docs");
784/// ```
785///
786/// # Related
787///
788/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
789pub fn build_app_deploy_check_report_local_json(
790    app_root: &Path,
791    target_id: &str,
792) -> Result<String, &'static str> {
793    pharos_runtime_ops::build_app_deploy_check_report_local_json(app_root, target_id)
794}
795
796/// Builds a bounded drift report from two JSON documents.
797///
798/// # Parameters
799///
800/// - `app_root`: Input consumed by [`crate::runtime::ops_bridge::build_app_doctor_report_local_json`].
801/// - `target_id`: Input consumed by [`crate::runtime::ops_bridge::build_app_doctor_report_local_json`].
802///
803/// # Returns
804///
805/// Returns the successful value produced by [`crate::runtime::ops_bridge::build_app_doctor_report_local_json`] or an error when the operation fails.
806///
807/// # Errors
808///
809/// Returns an error value when [`crate::runtime::ops_bridge::build_app_doctor_report_local_json`] cannot complete successfully.
810///
811/// # Examples
812///
813/// ```rust,ignore
814/// let _result = pharos_native::runtime::ops_bridge::build_app_doctor_report_local_json(std::path::Path::new("apps/dev_docs"), "dev_docs");
815/// ```
816///
817/// # Related
818///
819/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
820pub fn build_app_doctor_report_local_json(
821    app_root: &Path,
822    target_id: &str,
823) -> Result<String, &'static str> {
824    pharos_runtime_ops::build_app_doctor_report_local_json(app_root, target_id)
825}
826
827/// Builds app drift report local JSON.
828///
829/// # Parameters
830///
831/// - `expected_path`: Input consumed by [`crate::runtime::ops_bridge::build_app_drift_report_local_json`].
832/// - `actual_path`: Input consumed by [`crate::runtime::ops_bridge::build_app_drift_report_local_json`].
833///
834/// # Returns
835///
836/// Returns the successful value produced by [`crate::runtime::ops_bridge::build_app_drift_report_local_json`] or an error when the operation fails.
837///
838/// # Errors
839///
840/// Returns an error value when [`crate::runtime::ops_bridge::build_app_drift_report_local_json`] cannot complete successfully.
841///
842/// # Performance
843///
844/// Performance is proportional to the size of the supplied inputs and any parsed or loaded data consumed by [`crate::runtime::ops_bridge::build_app_drift_report_local_json`].
845///
846/// # Examples
847///
848/// ```rust,ignore
849/// let _result = pharos_native::runtime::ops_bridge::build_app_drift_report_local_json(todo!(), todo!());
850/// ```
851///
852/// # Related
853///
854/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
855pub fn build_app_drift_report_local_json(
856    expected_path: &Path,
857    actual_path: &Path,
858) -> Result<String, &'static str> {
859    pharos_runtime_ops::build_app_drift_report_local_json(expected_path, actual_path)
860}
861
862/// Appends one validated key/value pair to PostgreSQL connection information.
863///
864/// # Parameters
865///
866/// - `output`: Input consumed by [`crate::runtime::ops_bridge::conninfo_append`].
867/// - `key`: Input consumed by [`crate::runtime::ops_bridge::conninfo_append`].
868/// - `value`: Input consumed by [`crate::runtime::ops_bridge::conninfo_append`].
869///
870/// # Returns
871///
872/// Returns `true` when the condition checked by [`crate::runtime::ops_bridge::conninfo_append`] holds and `false` otherwise.
873///
874/// # Examples
875///
876/// ```rust,ignore
877/// let _result = pharos_native::runtime::ops_bridge::conninfo_append(todo!(), "key", "value");
878/// ```
879///
880/// # Related
881///
882/// - [`crate::runtime::ops_bridge`] for adjacent helpers that share the same runtime surface.
883pub fn conninfo_append(output: &mut String, key: &str, value: &str) -> bool {
884    conninfo_append_kv(output, key, value)
885}