{
  "schema_version": "1.0.0",
  "id": "emit-intent-file-writer",
  "nodes": {
    "bytes_written": {
      "id": "bytes_written",
      "op": {
        "op_type": "DataDecl",
        "data": {
          "name": "bytes_written",
          "ty": {
            "kind": "Primitive",
            "value": "Usize"
          },
          "mutable": false,
          "init": "std::fs::metadata(output_file).map(|meta| meta.len() as usize).unwrap_or(0usize)"
        }
      },
      "span": null,
      "crystal_origin": null,
      "label": null
    },
    "file_exists": {
      "id": "file_exists",
      "op": {
        "op_type": "DataDecl",
        "data": {
          "name": "file_exists",
          "ty": {
            "kind": "Primitive",
            "value": "Bool"
          },
          "mutable": false,
          "init": "std::path::Path::new(output_file).exists()"
        }
      },
      "span": null,
      "crystal_origin": null,
      "label": null
    },
    "write_notice": {
      "id": "write_notice",
      "op": {
        "op_type": "StdIO",
        "data": {
          "kind": "Println",
          "format_str": "Wrote {} bytes to {}",
          "args": [
            "bytes_written",
            "output_file"
          ]
        }
      },
      "span": null,
      "crystal_origin": null,
      "label": null
    },
    "content": {
      "id": "content",
      "op": {
        "op_type": "DataDecl",
        "data": {
          "name": "content",
          "ty": {
            "kind": "Ref",
            "value": {
              "lifetime": null,
              "mutable": false,
              "inner": {
                "kind": "Primitive",
                "value": "Str"
              }
            }
          },
          "mutable": false,
          "init": "\"Written by Crystal Factory!\""
        }
      },
      "span": null,
      "crystal_origin": null,
      "label": null
    },
    "crystal_count": {
      "id": "crystal_count",
      "op": {
        "op_type": "DataDecl",
        "data": {
          "name": "crystal_count",
          "ty": {
            "kind": "Primitive",
            "value": "Usize"
          },
          "mutable": false,
          "init": "1"
        }
      },
      "span": null,
      "crystal_origin": null,
      "label": null
    },
    "exists_notice": {
      "id": "exists_notice",
      "op": {
        "op_type": "StdIO",
        "data": {
          "kind": "Println",
          "format_str": "File exists after write: {}",
          "args": [
            "file_exists"
          ]
        }
      },
      "span": null,
      "crystal_origin": null,
      "label": null
    },
    "banner": {
      "id": "banner",
      "op": {
        "op_type": "StdIO",
        "data": {
          "kind": "Println",
          "format_str": "\\n  Crystal Factory — Program assembled from {} crystals\\n",
          "args": [
            "crystal_count"
          ]
        }
      },
      "span": null,
      "crystal_origin": null,
      "label": null
    },
    "cleanup": {
      "id": "cleanup",
      "op": {
        "op_type": "Expression",
        "data": {
          "expr": "std::fs::remove_file(output_file).ok()",
          "ty": {
            "kind": "Unit"
          }
        }
      },
      "span": null,
      "crystal_origin": null,
      "label": null
    },
    "done_notice": {
      "id": "done_notice",
      "op": {
        "op_type": "StdIO",
        "data": {
          "kind": "Println",
          "format_str": "\\n  All crystals executed successfully.",
          "args": []
        }
      },
      "span": null,
      "crystal_origin": null,
      "label": null
    },
    "write_file": {
      "id": "write_file",
      "op": {
        "op_type": "FileWrite",
        "data": {
          "path_expr": "output_file",
          "content_expr": "content",
          "mode": "Create"
        }
      },
      "span": null,
      "crystal_origin": null,
      "label": null
    },
    "output_file": {
      "id": "output_file",
      "op": {
        "op_type": "DataDecl",
        "data": {
          "name": "output_file",
          "ty": {
            "kind": "Ref",
            "value": {
              "lifetime": null,
              "mutable": false,
              "inner": {
                "kind": "Primitive",
                "value": "Str"
              }
            }
          },
          "mutable": false,
          "init": "\"/tmp/crystal_output.txt\""
        }
      },
      "span": null,
      "crystal_origin": null,
      "label": null
    },
    "preview_notice": {
      "id": "preview_notice",
      "op": {
        "op_type": "StdIO",
        "data": {
          "kind": "Println",
          "format_str": "Saved content preview: {}",
          "args": [
            "content"
          ]
        }
      },
      "span": null,
      "crystal_origin": null,
      "label": null
    },
    "main": {
      "id": "main",
      "op": {
        "op_type": "EntryPoint",
        "data": {
          "body": [
            "crystal_count",
            "banner",
            "output_file",
            "content",
            "write_file",
            "bytes_written",
            "file_exists",
            "write_notice",
            "exists_notice",
            "preview_notice",
            "cleanup",
            "done_notice"
          ],
          "is_async": false
        }
      },
      "span": null,
      "crystal_origin": null,
      "label": null
    }
  },
  "edges": [],
  "crate_deps": {},
  "features": [],
  "edition": "2021",
  "cfg": null,
  "metadata": {
    "intent": "save a status report to an output file and confirm bytes written",
    "entrypoint_mode": "ir_intent_scaffold"
  }
}