ggen-engine 26.10.11

SPARQL-in-Tera code generation engine (vendored, renamed from praxis/crates/ggen)
//! Run the ggen code-generation pipeline: resolve, enrich, extract, render, write.
//
// GENERATED by `ggen sync` from `schema/praxis.ttl` (`praxis:CliCommand`
// instances). Do not edit by hand: routes are a pure projection of the
// ontology (mode = Overwrite); logic lives in `crate::verbs::handlers`.

use clap_noun_verb::Result;

/// Run the five-stage generation pipeline: resolve, enrich, extract, render, write. --watch re-runs the pipeline on filesystem changes.
///
/// # Arguments
/// * `dry_run` - Resolve and render but do not write any files to disk; report what would change.
/// * `watch` - Watch the filesystem and re-run the pipeline automatically whenever a watched file changes.
/// * `consumer_mode` - Suppress installer emission of outputs derived from `fixtureOnly`-marked specs (OS-13 consumer mode).
#[clap_noun_verb_macros::verb("run")]
fn sync_run(dry_run: bool, watch: bool, consumer_mode: bool) -> Result<serde_json::Value> {
    // HAND-EDITED (lane dryrun-written, 2026-10-10): dry-run reports renamed
    // the `written` key to `planned_writes` and gained `dry_run: true`. The
    // engine's `SyncReport` still serializes `written` (typed API surface,
    // many consumers); this verb-level transform is the CLI honesty fix — a
    // dry-run names what WOULD be written, never claims writes happened.
    // Consumers grepping `written` on dry-run stdout get nothing (fail-visible).
    // NOTE: this hand edit lives below the GENERATED routing annotation and
    // must be re-applied if `mode = Overwrite` regeneration ever rewrites
    // this file.
    let mut report = crate::verbs::handlers::handle_sync_run(dry_run, watch, consumer_mode)?;
    if dry_run {
        if let Some(obj) = report.as_object_mut() {
            if let Some(planned) = obj.remove("written") {
                obj.insert("planned_writes".to_string(), planned);
            }
            obj.insert("dry_run".to_string(), serde_json::Value::Bool(true));
        }
    }
    Ok(report)
}