sync

Function sync 

Source
pub fn sync(
    manifest: Option<String>,
    output_dir: Option<String>,
    dry_run: Option<bool>,
    force: Option<bool>,
    audit: Option<bool>,
    rule: Option<String>,
    verbose: Option<bool>,
    watch: Option<bool>,
    validate_only: Option<bool>,
    format: Option<String>,
    timeout: Option<u64>,
) -> Result<SyncOutput>
Expand description

Execute the complete code synchronization pipeline from a ggen.toml manifest.

This is THE ONLY command in ggen v5. It replaces all previous commands (ggen generate, ggen validate, ggen template, etc.) with a single unified pipeline.

§Pipeline Flow

ggen.toml → ontology → CONSTRUCT inference → SELECT → Template → Code

§Flags

–manifest PATH Path to ggen.toml (default: ./ggen.toml) –output-dir PATH Override output directory from manifest –dry-run Preview changes without writing files –force Overwrite existing files (DESTRUCTIVE - use with –audit) –audit Create detailed audit trail in .ggen/audit/ –rule NAME Execute only specific generation rule –verbose Show detailed execution logs –watch Continuous file monitoring and auto-regeneration –validate-only Run SHACL/SPARQL validation without generation –format FORMAT Output format: text, json, yaml (default: text) –timeout MS Maximum execution time in milliseconds (default: 30000)

§Flag Combinations

Safe workflows: ggen sync –dry-run –audit Preview with audit ggen sync –force –audit Destructive overwrite with tracking ggen sync –watch –validate-only Continuous validation

CI/CD workflows: ggen sync –format json Machine-readable output ggen sync –validate-only Pre-flight checks

Development workflows: ggen sync –watch –verbose Live feedback ggen sync –rule structs Focused iteration

§Flag Precedence

–validate-only overrides –force –dry-run prevents file writes (–force has no effect) –watch triggers continuous execution

§Safety Notes

⚠️ ALWAYS use –audit with –force to enable rollback ⚠️ ALWAYS use –dry-run before –force to preview changes ⚠️ Review docs/features/force-flag.md before using –force

§Examples

# Basic sync (the primary workflow)
ggen sync

# Sync from specific manifest
ggen sync --manifest project/ggen.toml

# Dry-run to preview changes
ggen sync --dry-run

# Sync specific rule only
ggen sync --rule structs

# Force overwrite with audit trail (RECOMMENDED)
ggen sync --force --audit

# Watch mode for development
ggen sync --watch --verbose

# Validate without generating
ggen sync --validate-only

# JSON output for CI/CD
ggen sync --format json

# Complex: Watch, audit, verbose
ggen sync --watch --audit --verbose --rule api_endpoints

§Documentation

Full feature documentation:

  • docs/features/audit-trail.md Audit trail format and usage
  • docs/features/force-flag.md Safe destructive workflows
  • docs/features/merge-mode.md Hybrid manual/generated code
  • docs/features/watch-mode.md Continuous regeneration
  • docs/features/conditional-execution.md SPARQL ASK conditions
  • docs/features/validation.md SHACL/SPARQL constraints