fabro/run.json
Fabro 502bb318f7 checkpoint
⚒️ Generated with [Fabro](https://fabro.sh)
2026-05-23 16:23:53 -04:00

1451 lines
No EOL
334 KiB
JSON

{
"title": "Legacy Sandbox Config Auto-Migration Implementation Plan",
"spec": {
"run_id": "01KSB6HFNMJ802AXGBAV5JP7ZS",
"settings": {
"project": {
"name": null,
"description": null,
"metadata": {}
},
"workflow": {
"name": null,
"description": null,
"graph": "workflow.fabro",
"metadata": {}
},
"run": {
"goal": {
"type": "inline",
"value": "# Legacy Sandbox Config Auto-Migration Implementation Plan\n\n> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.\n\n**Goal:** Automatically rewrite confidently migratable legacy `[run.sandbox]` config files to the named-environments syntax during startup.\n\n**Architecture:** Keep legacy behavior isolated in a removable `fabro-config` module. The normal settings schema stays strict; only file-based loads get a temporary parse-failure recovery path that rewrites the file, writes a backup, warns, and then resumes normal parsing.\n\n**Tech Stack:** Rust, `toml_edit`, existing `fabro-config` settings builders, `tracing`, `tempfile` tests, public docs under `docs/public`.\n\n---\n\n## File Structure\n\n- Create `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n - Owns detection, TOML rewriting, backup naming/writing, unsupported-key diagnostics, and tests for legacy mappings.\n- Modify `lib/crates/fabro-config/src/lib.rs`\n - Register the module privately.\n- Modify `lib/crates/fabro-config/Cargo.toml`\n - Add the existing workspace `toml_edit` dependency; current main does not depend on it from `fabro-config`.\n- Modify `lib/crates/fabro-config/src/load.rs`\n - Add a small parse-failure hook that delegates to the migration module, then returns to normal parsing.\n- Modify docs:\n - `docs/public/execution/environments.mdx`\n - Create `docs/public/changelog/2026-05-23.mdx` because current main's latest public changelog is `2026-05-22.mdx`.\n\n## Migration Contract\n\nOnly migrate when all of these are true:\n\n- The file is valid TOML as a document.\n- `[run.sandbox]` exists.\n- `[run.environment]` does not exist.\n- `[environments.default]` does not exist.\n- Every legacy sandbox key is in the supported mapping below.\n- The migrated content parses successfully as `SettingsLayer`.\n\nThis is intentionally a file-load migration only. Current in-memory parsing behavior, including `legacy_run_sandbox_is_rejected` in `lib/crates/fabro-config/src/tests/resolve_run.rs`, should remain strict and unchanged.\n\nSupported mappings:\n\n| Legacy key | New key |\n|---|---|\n| `run.sandbox.provider` | `run.environment.id = \"default\"` and `environments.default.provider` |\n| `run.sandbox.preserve` | `environments.default.lifecycle.preserve` |\n| `run.sandbox.env` | `environments.default.env` |\n| `run.sandbox.daytona.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.docker.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.daytona.auto_stop_interval = N` | `environments.default.lifecycle.auto_stop = \"{N}m\"` |\n| `run.sandbox.daytona.labels` | `environments.default.labels` |\n| `run.sandbox.daytona.snapshot.name` | `environments.default.image.ref` |\n| `run.sandbox.daytona.snapshot.cpu` | `environments.default.resources.cpu` |\n| `run.sandbox.daytona.snapshot.memory` | `environments.default.resources.memory` |\n| `run.sandbox.daytona.snapshot.disk` | `environments.default.resources.disk` |\n| `run.sandbox.daytona.snapshot.dockerfile` | `environments.default.image.dockerfile` |\n| `run.sandbox.daytona.volumes[].volume_id` | `environments.default.volumes[].id` |\n| `run.sandbox.daytona.volumes[].mount_path` | `environments.default.volumes[].mount_path` |\n| `run.sandbox.daytona.volumes[].subpath` | `environments.default.volumes[].subpath` |\n| `run.sandbox.docker.image` | `environments.default.image.ref` |\n| `run.sandbox.docker.memory_limit` | `environments.default.resources.memory` |\n| `run.sandbox.docker.cpu_quota` | `environments.default.resources.cpu` when divisible by `100000` |\n\nUnsupported or ambiguous cases fail with a message shaped like:\n\n```text\nLegacy [run.sandbox] settings in <path> could not be auto-migrated.\n\nUnsupported keys:\n - run.sandbox.daytona.foo\n - run.sandbox.docker.cpu_quota\n\nRename legacy sandbox configuration to [run.environment] and [environments.<slug>].\nSee docs/public/execution/environments.mdx.\n```\n\nSuccessful migration writes a backup next to the original file:\n\n```text\nsettings.toml.legacy-sandbox-migration.bak\nsettings.toml.legacy-sandbox-migration.1.bak\nsettings.toml.legacy-sandbox-migration.2.bak\n```\n\nSuccessful migration emits:\n\n```text\nMigrated legacy [run.sandbox] settings in <path> to [run.environment] and [environments.default]. Backup written to <backup>. This temporary compatibility migration will be removed before v1.0.\n```\n\n## Task 1: Add the Migration Module Skeleton\n\n**Files:**\n- Create: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n- Modify: `lib/crates/fabro-config/src/lib.rs`\n- Modify: `lib/crates/fabro-config/Cargo.toml`\n\n- [ ] **Step 1: Add the `toml_edit` dependency**\n\nAdd this to `[dependencies]` in `lib/crates/fabro-config/Cargo.toml`:\n\n```toml\ntoml_edit.workspace = true\n```\n\n- [ ] **Step 2: Register the module privately**\n\nAdd this beside the other private modules in `lib/crates/fabro-config/src/lib.rs`:\n\n```rust\nmod legacy_sandbox_migration;\n```\n\n- [ ] **Step 3: Create the module API**\n\nCreate `lib/crates/fabro-config/src/legacy_sandbox_migration.rs` with this starting shape:\n\n```rust\n#![expect(\n clippy::disallowed_methods,\n reason = \"temporary startup config migration uses synchronous file I/O before config is loaded\"\n)]\n\nuse std::fmt;\nuse std::path::{Path, PathBuf};\n\nuse toml_edit::{DocumentMut, Item, Table, Value};\n\nuse crate::{Error, Result, SettingsLayer};\n\npub(crate) const REMOVAL_NOTE: &str =\n \"This temporary compatibility migration will be removed before v1.0.\";\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub(crate) struct LegacySandboxMigrationReport {\n pub(crate) contents: String,\n pub(crate) backup_path: PathBuf,\n pub(crate) warning: String,\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\nstruct MigrationFailure {\n unsupported_keys: Vec<String>,\n}\n\nimpl fmt::Display for MigrationFailure {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n writeln!(f, \"Legacy [run.sandbox] settings could not be auto-migrated.\")?;\n writeln!(f)?;\n writeln!(f, \"Unsupported keys:\")?;\n for key in &self.unsupported_keys {\n writeln!(f, \" - {key}\")?;\n }\n writeln!(f)?;\n write!(\n f,\n \"Rename legacy sandbox configuration to [run.environment] and [environments.<slug>]. See docs/public/execution/environments.mdx.\"\n )\n }\n}\n\npub(crate) fn migrate_settings_path(\n path: &Path,\n original_contents: &str,\n) -> Result<Option<LegacySandboxMigrationReport>> {\n let Some(next_contents) = migrate_contents(original_contents, path)? else {\n return Ok(None);\n };\n\n next_contents\n .parse::<SettingsLayer>()\n .map_err(|err| Error::parse_file(\"Migrated settings file is invalid\", path, err))?;\n\n let backup_path = next_backup_path(path);\n std::fs::write(&backup_path, original_contents).map_err(|source| {\n Error::other(format!(\n \"writing legacy sandbox migration backup {}: {source}\",\n backup_path.display()\n ))\n })?;\n std::fs::write(path, &next_contents).map_err(|source| {\n Error::other(format!(\n \"writing migrated settings file {}: {source}\",\n path.display()\n ))\n })?;\n\n let warning = format!(\n \"Migrated legacy [run.sandbox] settings in {} to [run.environment] and [environments.default]. Backup written to {}. {REMOVAL_NOTE}\",\n path.display(),\n backup_path.display()\n );\n\n Ok(Some(LegacySandboxMigrationReport {\n contents: next_contents,\n backup_path,\n warning,\n }))\n}\n\nfn migrate_contents(original_contents: &str, path: &Path) -> Result<Option<String>> {\n let mut doc = match original_contents.parse::<DocumentMut>() {\n Ok(doc) => doc,\n Err(_) => return Ok(None),\n };\n\n if !has_legacy_run_sandbox(&doc) {\n return Ok(None);\n }\n if has_new_environment_config(&doc) {\n return Err(Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated because the file already contains [run.environment] or [environments.default]. Remove one config style and retry.\",\n path.display()\n )));\n }\n\n migrate_document(&mut doc).map_err(|failure| {\n Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated.\\n\\n{}\",\n path.display(),\n failure\n ))\n })?;\n\n Ok(Some(doc.to_string()))\n}\n\nfn has_legacy_run_sandbox(doc: &DocumentMut) -> bool {\n doc.get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n .is_some()\n}\n\nfn has_new_environment_config(doc: &DocumentMut) -> bool {\n let has_run_environment = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"environment\"))\n .is_some();\n let has_default_environment = doc\n .get(\"environments\")\n .and_then(Item::as_table)\n .and_then(|envs| envs.get(\"default\"))\n .is_some();\n has_run_environment || has_default_environment\n}\n\nfn next_backup_path(path: &Path) -> PathBuf {\n let base = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !base.exists() {\n return base;\n }\n\n for index in 1.. {\n let candidate = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.{index}.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !candidate.exists() {\n return candidate;\n }\n }\n unreachable!(\"unbounded backup suffix search should return\")\n}\n```\n\n- [ ] **Step 4: Add placeholder-free private stubs that compile**\n\nAdd private helpers with `unimplemented!()` only inside tests disabled by `#[cfg(test)]` is not allowed. Instead, make `migrate_document` return the one known unsupported failure until Task 2 fills it:\n\n```rust\nfn migrate_document(_doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n })\n}\n```\n\n- [ ] **Step 5: Run the focused compile check**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: compiles; there may be zero tests in this module at this point.\n\n## Task 2: Implement Provider-Only Migration\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for provider-only migration**\n\nAdd these tests inside `legacy_sandbox_migration.rs`:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n fn migrate(source: &str) -> String {\n migrate_contents(source, Path::new(\"settings.toml\"))\n .expect(\"migration should not error\")\n .expect(\"legacy sandbox should migrate\")\n }\n\n #[test]\n fn provider_only_daytona_config_migrates_to_default_environment() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n );\n\n let settings = migrated\n .parse::<SettingsLayer>()\n .expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.id, \"default\");\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(migrated.contains(\"[run.environment]\"));\n assert!(migrated.contains(\"[environments.default]\"));\n assert!(!migrated.contains(\"[run.sandbox]\"));\n }\n\n #[test]\n fn non_legacy_config_is_not_migrated() {\n let migrated = migrate_contents(\"_version = 1\\n\", Path::new(\"settings.toml\"))\n .expect(\"non-legacy TOML should not error\");\n\n assert!(migrated.is_none());\n }\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config provider_only_daytona_config_migrates_to_default_environment --quiet\n```\n\nExpected: FAIL because `migrate_document` still returns unsupported `run.sandbox`.\n\n- [ ] **Step 3: Replace `migrate_document` with provider migration**\n\nImplement the initial migration:\n\n```rust\nfn migrate_document(doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n let Some(sandbox_item) = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n else {\n return Ok(());\n };\n let Some(sandbox) = sandbox_item.as_table().cloned() else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n });\n };\n\n let mut unsupported = Vec::new();\n for (key, _) in sandbox.iter() {\n if key != \"provider\" {\n unsupported.push(format!(\"run.sandbox.{key}\"));\n }\n }\n if !unsupported.is_empty() {\n return Err(MigrationFailure {\n unsupported_keys: unsupported,\n });\n }\n\n let Some(provider) = sandbox.get(\"provider\").and_then(Item::as_str) else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox.provider\".to_string()],\n });\n };\n\n set_value(path_table(doc, &[\"run\", \"environment\"]), \"id\", Value::from(\"default\"));\n set_value(\n path_table(doc, &[\"environments\", \"default\"]),\n \"provider\",\n Value::from(provider),\n );\n\n remove_run_sandbox(doc);\n Ok(())\n}\n\nfn path_table<'a>(doc: &'a mut DocumentMut, path: &[&str]) -> &'a mut Table {\n let mut item = doc.as_item_mut();\n for segment in path {\n item = &mut item[segment];\n if !item.is_table() {\n *item = Item::Table(Table::new());\n }\n }\n item.as_table_mut().expect(\"path item should be a table\")\n}\n\nfn set_value(table: &mut Table, key: &str, value: Value) {\n table[key] = Item::Value(value);\n}\n\nfn remove_run_sandbox(doc: &mut DocumentMut) {\n if let Some(run) = doc.get_mut(\"run\").and_then(Item::as_table_mut) {\n run.remove(\"sandbox\");\n }\n}\n```\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 3: Add Daytona and Docker Field Mappings\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for direct legacy field mappings**\n\nAdd tests that assert resolved behavior, not only string contents:\n\n```rust\n#[test]\nfn daytona_snapshot_labels_lifecycle_and_volumes_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\npreserve = true\n\n[run.sandbox.env]\nNODE_ENV = \"development\"\n\n[run.sandbox.daytona]\nauto_stop_interval = 30\n\n[run.sandbox.daytona.labels]\nrepo = \"fabro-sh/fabro\"\n\n[run.sandbox.daytona.snapshot]\nname = \"fabro-v11\"\ncpu = 8\nmemory = \"16GB\"\ndisk = \"20GB\"\ndockerfile = { path = \"Dockerfile\" }\n\n[[run.sandbox.daytona.volumes]]\nvolume_id = \"vol_auth\"\nmount_path = \"/home/daytona/.config\"\nsubpath = \"agents\"\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.image.reference.as_deref(), Some(\"fabro-v11\"));\n assert_eq!(resolved.resources.cpu, Some(8));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(16_000_000_000));\n assert_eq!(resolved.resources.disk.map(|size| size.as_bytes()), Some(20_000_000_000));\n assert!(resolved.lifecycle.preserve);\n assert_eq!(resolved.lifecycle.auto_stop.map(|duration| duration.as_std().as_secs()), Some(1800));\n assert_eq!(resolved.labels.get(\"repo\").map(String::as_str), Some(\"fabro-sh/fabro\"));\n assert_eq!(resolved.env.get(\"NODE_ENV\").map(|value| value.as_source()).as_deref(), Some(\"development\"));\n assert_eq!(resolved.volumes.len(), 1);\n assert_eq!(resolved.volumes[0].id, \"vol_auth\");\n assert_eq!(resolved.volumes[0].mount_path, \"/home/daytona/.config\");\n assert_eq!(resolved.volumes[0].subpath.as_deref(), Some(\"agents\"));\n}\n\n#[test]\nfn docker_image_memory_and_cpu_quota_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\nimage = \"buildpack-deps:noble\"\nmemory_limit = \"4GB\"\ncpu_quota = 200000\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.provider, EnvironmentProvider::Docker);\n assert_eq!(resolved.image.reference.as_deref(), Some(\"buildpack-deps:noble\"));\n assert_eq!(resolved.resources.cpu, Some(2));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(4_000_000_000));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: FAIL because the two new nested-mapping tests are not implemented yet.\n\n- [ ] **Step 3: Implement table copying and value transforms**\n\nExtend `migrate_document` so it:\n\n- Allows top-level legacy keys `provider`, `preserve`, `env`, `daytona`, and `docker`.\n- Copies `run.sandbox.env` into `environments.default.env`.\n- Sets `environments.default.lifecycle.preserve` from `run.sandbox.preserve`.\n- Handles provider-specific nested mappings only for the selected provider.\n- Removes `run.sandbox` after successful migration.\n\nUse helper functions with these signatures:\n\n```rust\nfn migrate_daytona(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn migrate_docker(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn copy_table(source: &Item, target: &mut Table);\nfn copy_array_of_tables_with_volume_id(source: &Item, target: &mut Table, unsupported: &mut Vec<String>);\nfn item_path_keys(prefix: &str, item: &Item, out: &mut Vec<String>);\n```\n\nImplementation rules:\n\n- `auto_stop_interval` must be an integer. Store `format!(\"{minutes}m\")`.\n- `docker.cpu_quota` must be an integer divisible by `100000`; otherwise add `run.sandbox.docker.cpu_quota` to unsupported keys.\n- For Daytona volumes, each array entry may contain only `volume_id`, `mount_path`, and `subpath`; rename `volume_id` to `id`.\n- `daytona.snapshot.dockerfile` must be copied as the existing TOML value, preserving inline string or `{ path = \"...\" }`.\n- When collecting unsupported nested keys, report full paths such as `run.sandbox.daytona.snapshot.foo`.\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 4: Add File Rewrite and Loader Hook\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/load.rs`\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add file rewrite tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn migrate_settings_path_writes_backup_and_rewrites_original() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n let original = r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#;\n std::fs::write(&path, original).expect(\"write fixture\");\n\n let report = migrate_settings_path(&path, original)\n .expect(\"migration should succeed\")\n .expect(\"legacy config should migrate\");\n\n let rewritten = std::fs::read_to_string(&path).expect(\"read rewritten settings\");\n let backup = std::fs::read_to_string(&report.backup_path).expect(\"read backup\");\n\n assert_eq!(backup, original);\n assert!(rewritten.contains(\"[run.environment]\"));\n assert!(rewritten.contains(\"[environments.default]\"));\n assert!(report.warning.contains(\"temporary compatibility migration\"));\n}\n\n#[test]\nfn existing_backup_uses_numbered_suffix() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(path.with_file_name(\"settings.toml.legacy-sandbox-migration.bak\"), \"old\")\n .expect(\"write existing backup\");\n\n let next = next_backup_path(&path);\n\n assert!(next.ends_with(\"settings.toml.legacy-sandbox-migration.1.bak\"));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm current state**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS if Task 1 file-writing code compiled; otherwise fix only the migration module.\n\n- [ ] **Step 3: Hook migration into file loading**\n\nChange `load_settings_path` in `lib/crates/fabro-config/src/load.rs` to this shape:\n\n```rust\npub(crate) fn load_settings_path(path: &Path) -> Result<SettingsLayer> {\n let content = std::fs::read_to_string(path).map_err(|source| Error::read_file(path, source))?;\n let mut layer = match content.parse::<SettingsLayer>() {\n Ok(layer) => layer,\n Err(err) => match crate::legacy_sandbox_migration::migrate_settings_path(path, &content)? {\n Some(report) => {\n tracing::warn!(\"{}\", report.warning);\n eprintln!(\"{}\", report.warning);\n report.contents.parse::<SettingsLayer>().map_err(|err| {\n Error::parse_file(\"Migrated settings file is invalid\", path, err)\n })?\n }\n None => return Err(Error::parse_file(\"Failed to parse settings file\", path, err)),\n },\n };\n let base_dir = path.parent().unwrap_or_else(|| Path::new(\".\"));\n resolve_goal_file_paths(&mut layer, base_dir);\n Ok(layer)\n}\n```\n\n- [ ] **Step 4: Run loader-level verification**\n\nAdd a test in `load.rs` under `#[cfg(test)]` if the file does not already have a test module:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n #[test]\n fn load_settings_path_auto_migrates_legacy_sandbox_file() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(\n &path,\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n )\n .expect(\"write legacy settings\");\n\n let layer = load_settings_path(&path).expect(\"legacy settings should auto-migrate\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&layer)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(std::fs::read_to_string(&path)\n .expect(\"read rewritten settings\")\n .contains(\"[run.environment]\"));\n }\n}\n```\n\nRun:\n\n```bash\ncargo test -p fabro-config load_settings_path_auto_migrates_legacy_sandbox_file --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 5: Verify in-memory TOML parsing remains strict**\n\nRun the existing current-main rejection test:\n\n```bash\ncargo test -p fabro-config legacy_run_sandbox_is_rejected --quiet\n```\n\nExpected: PASS. Do not weaken `SettingsLayer` deserialization to accept `run.sandbox`; only `load_settings_path` should rewrite files from disk.\n\n## Task 5: Unsupported and Ambiguous Cases\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add failure tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn existing_new_environment_config_is_ambiguous() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.environment]\nid = \"default\"\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"mixed old and new config should fail\");\n\n assert!(err.to_string().contains(\"already contains [run.environment]\"));\n}\n\n#[test]\nfn unsupported_keys_are_reported_with_full_paths() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\n[run.sandbox.daytona]\nunknown = true\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"unsupported keys should fail migration\");\n\n let rendered = err.to_string();\n assert!(rendered.contains(\"run.sandbox.daytona.unknown\"));\n assert!(rendered.contains(\"docs/public/execution/environments.mdx\"));\n}\n\n#[test]\nfn unsupported_docker_cpu_quota_is_reported() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\ncpu_quota = 250000\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"non-divisible cpu quota should fail migration\");\n\n assert!(err.to_string().contains(\"run.sandbox.docker.cpu_quota\"));\n}\n```\n\n- [ ] **Step 2: Run failure tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 6: Documentation\n\n**Files:**\n- Modify: `docs/public/execution/environments.mdx`\n- Create: `docs/public/changelog/2026-05-23.mdx`\n\n- [ ] **Step 1: Document temporary auto-migration**\n\nAdd this note near the top of `docs/public/execution/environments.mdx`, after the initial environment/sandbox distinction:\n\n```mdx\n<Warning>\nOlder pre-v1.0 config files that still use `[run.sandbox]` are temporarily auto-migrated when Fabro loads them from disk. Fabro writes a sibling `*.legacy-sandbox-migration.bak` file, rewrites the config to `[run.environment]` plus `[environments.default]`, and then continues startup.\n\nThis compatibility rewrite only handles direct field mappings. Unsupported legacy fields fail with a migration message that lists the keys to edit manually. The rewrite path will be removed before v1.0.\n</Warning>\n```\n\n- [ ] **Step 2: Add a changelog note**\n\nCreate `docs/public/changelog/2026-05-23.mdx`:\n\n```mdx\n---\ntitle: \"Legacy sandbox config migration\"\ndate: \"2026-05-23\"\n---\n\n## Legacy sandbox config auto-migration\n\nFabro now temporarily rewrites confidently migratable pre-v1.0 `[run.sandbox]` config files to the named environment syntax. A backup is written next to the original file before rewriting. Ambiguous or unsupported legacy keys fail with a targeted migration message instead of the generic TOML unknown-field error.\n```\n\n- [ ] **Step 3: Check docs references**\n\nRun:\n\n```bash\nrg -n \"\\\\[run\\\\.sandbox\\\\]|legacy-sandbox-migration|run\\\\.environment\" docs/public/execution docs/public/changelog\n```\n\nExpected: remaining `[run.sandbox]` references are either historical changelog entries or explicit migration warnings.\n\n## Task 7: Full Verification\n\n**Files:**\n- All files touched above.\n\n- [ ] **Step 1: Run config crate tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 2: Run formatting check**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 fmt --check --all\n```\n\nExpected: PASS.\n\n- [ ] **Step 3: Optional workspace lint if formatting and tests pass**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings\n```\n\nExpected: PASS. If this is slow, record that it was not run and include the reason in the handoff.\n\n## Acceptance Criteria\n\n- Boot-time config loading rewrites simple legacy `[run.sandbox]` files without user action.\n- The rewritten file uses `[run.environment] id = \"default\"` and `[environments.default]`.\n- The original file is preserved in a sibling backup before rewrite.\n- Unsupported legacy keys fail with a targeted migration message listing exact keys.\n- Normal strict schema behavior remains unchanged for in-memory `from_toml` calls.\n- All legacy migration code is isolated in `legacy_sandbox_migration.rs` and removable before v1.0.\n"
},
"working_dir": null,
"metadata": {},
"inputs": {},
"model": {
"provider": "anthropic",
"name": "claude-sonnet-4-6",
"fallbacks": [],
"controls": {
"reasoning_effort": null,
"speed": null
}
},
"git": {
"author": null
},
"prepare": {
"commands": [],
"timeout_ms": 300000
},
"execution": {
"mode": "normal",
"approval": "prompt"
},
"checkpoint": {
"exclude_globs": [],
"skip_git_hooks": false
},
"clone": {
"enabled": true
},
"run_branch": {
"enabled": true,
"push": true
},
"meta_branch": {
"enabled": true,
"push": true
},
"environment": {
"id": "fabro-dev",
"provider": "daytona",
"image": {
"ref": "fabro-v11",
"dockerfile": {
"type": "inline",
"value": "FROM ubuntu:24.04\n\nRUN apt-get update && apt-get install -y --no-install-recommends \\\n curl git ca-certificates build-essential pkg-config libssl-dev unzip python3 \\\n xvfb xfce4 xfce4-terminal x11vnc novnc dbus-x11 \\\n libx11-6 libxrandr2 libxext6 libxrender1 libxfixes3 libxss1 libxtst6 libxi6 \\\n && rm -rf /var/lib/apt/lists/*\n\n# Install real Chromium (not the snap stub) via xtradeb PPA\nRUN apt-get update && apt-get install -y --no-install-recommends \\\n software-properties-common curl gnupg \\\n && add-apt-repository -y ppa:xtradeb/apps \\\n && apt-get update \\\n && apt-get install -y --no-install-recommends chromium \\\n && rm -rf /var/lib/apt/lists/*\n\n# Wrapper: Chromium needs --no-sandbox when running as root in a container,\n# and --disable-dev-shm-usage avoids crashes from small /dev/shm\nRUN printf '#!/bin/bash\\nexec /usr/bin/chromium --no-sandbox --disable-dev-shm-usage \"$@\"\\n' \\\n > /usr/local/bin/chromium-wrapper \\\n && chmod +x /usr/local/bin/chromium-wrapper\n\n# Make the wrapper the default in the system .desktop file and via alternatives\nRUN sed -i 's|^Exec=.*|Exec=/usr/local/bin/chromium-wrapper %U|' \\\n /usr/share/applications/chromium.desktop \\\n && update-alternatives --install /usr/bin/x-www-browser x-www-browser \\\n /usr/local/bin/chromium-wrapper 100\n\n# Tell XFCE's exo-open that Chromium is the WebBrowser helper (system-wide)\nRUN mkdir -p /etc/xdg/xfce4 /usr/share/xfce4/helpers \\\n && printf 'WebBrowser=custom-WebBrowser\\n' > /etc/xdg/xfce4/helpers.rc \\\n && printf '[Desktop Entry]\\n\\\nVersion=1.0\\n\\\nType=X-XFCE-Helper\\n\\\nName=Chromium\\n\\\nIcon=chromium\\n\\\nX-XFCE-Category=WebBrowser\\n\\\nX-XFCE-CommandsWithParameter=/usr/local/bin/chromium-wrapper \"%%s\"\\n\\\nX-XFCE-Commands=/usr/local/bin/chromium-wrapper\\n' \\\n > /usr/share/xfce4/helpers/custom-WebBrowser.desktop\n\n# GitHub CLI\nRUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \\\n | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \\\n && echo \"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main\" \\\n | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \\\n && apt-get update && apt-get install -y --no-install-recommends gh \\\n && rm -rf /var/lib/apt/lists/*\n\n# Rust\nRUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y\nENV PATH=\"/root/.cargo/bin:${PATH}\"\nRUN rustup toolchain install nightly-2026-04-14 --profile minimal --component clippy,rustfmt\nRUN cargo install cargo-nextest --locked\nENV CARGO_INCREMENTAL=0\n\n# Bun\nRUN curl -fsSL https://bun.sh/install | bash\nENV PATH=\"/root/.bun/bin:${PATH}\"\n\nWORKDIR /root\n"
}
},
"resources": {
"cpu": 8,
"memory": "16GB",
"disk": "20GB"
},
"network": {
"mode": "allow_all",
"allow": []
},
"lifecycle": {
"preserve": false,
"stop_on_terminal": true,
"auto_stop": "30m"
},
"labels": {
"repo": "fabro-sh/fabro"
},
"volumes": [],
"env": {}
},
"notifications": {},
"interviews": {
"provider": null,
"slack": null
},
"agent": {
"fabro_tools": false,
"permissions": null,
"mcps": {}
},
"hooks": [],
"scm": {
"provider": null,
"owner": null,
"repository": null,
"github": null
},
"pull_request": {
"enabled": true,
"draft": false,
"auto_merge": false,
"merge_strategy": "squash"
},
"artifacts": {
"include": []
},
"integrations": {
"github": {
"permissions": {}
}
}
}
},
"graph": {
"name": "ImplementPlan",
"nodes": {
"preflight_compile": {
"id": "preflight_compile",
"attrs": {
"model": {
"String": "claude-opus-4-7"
},
"script": {
"String": "cargo check -q --workspace 2>&1"
},
"provider": {
"String": "anthropic"
},
"label": {
"String": "Preflight Compile"
},
"shape": {
"String": "parallelogram"
},
"max_retries": {
"Integer": 0
}
}
},
"fix_lints": {
"id": "fix_lints",
"attrs": {
"model": {
"String": "claude-opus-4-7"
},
"label": {
"String": "Fix Lints"
},
"prompt": {
"String": "The preflight lint step failed. Read the build output from context and fix all clippy lint warnings."
},
"provider": {
"String": "anthropic"
},
"max_visits": {
"Integer": 3
}
}
},
"implement": {
"id": "implement",
"attrs": {
"provider": {
"String": "openai"
},
"label": {
"String": "Implement"
},
"reasoning_effort": {
"String": "xhigh"
},
"prompt": {
"String": "Read the plan file referenced in the goal and implement every step. Make all the code changes described in the plan. Use red/green TDD."
},
"model": {
"String": "gpt-5.5"
}
}
},
"verify": {
"id": "verify",
"attrs": {
"model": {
"String": "claude-opus-4-7"
},
"provider": {
"String": "anthropic"
},
"shape": {
"String": "parallelogram"
},
"retry_target": {
"String": "fixup"
},
"goal_gate": {
"Boolean": true
},
"label": {
"String": "Verify"
},
"script": {
"String": "git fetch origin main 2>&1 && git merge --no-edit --no-stat origin/main 2>&1 && cargo +nightly-2026-04-14 fmt --all 2>&1 && cargo dev docs refresh 2>&1 && cargo +nightly-2026-04-14 fmt --check --all 2>&1 && ! rg -n 'AuthMode::Disabled|RunAuthMethod|RunSubjectProvenance|\\bActorRef\\b|\\bActorKind\\b|AuthenticatedSubject|AuthenticatedService|AuthorizeRunScoped|AuthorizeRunBlob|AuthorizeStageArtifact|AuthorizeCommandLog|auth_method\\s*==\\s*\"disabled\"' lib/crates apps lib/packages docs/public/api-reference/fabro-api.yaml 2>&1 && cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings 2>&1 && cargo nextest run --workspace --status-level slow --profile ci 2>&1 && cargo dev docs check 2>&1 && bun install --frozen-lockfile 2>&1 && (cd apps/fabro-web && bun run typecheck) 2>&1 && (cd apps/fabro-web && bun run test) 2>&1 && (cd lib/packages/fabro-api-client && bun run typecheck) 2>&1 && cargo dev build -- -p fabro-cli --release 2>&1"
}
}
},
"simplify_gpt": {
"id": "simplify_gpt",
"attrs": {
"provider": {
"String": "openai"
},
"prompt": {
"String": "# Simplify: Code Review and Cleanup\n\nReview changes vs. origin for reuse, quality, and efficiency. Fix any issues found.\n\n## Phase 1: Identify Changes\n\nRun git diff (or git diff HEAD if there are staged changes) to see what changed. If there are no git changes, review the most recently modified files that the user mentioned or that you edited earlier in this conversation.\n\n## Phase 2: Launch Three Review Agents in Parallel\n\nUse the Agent tool to launch all three agents concurrently in a single message. Pass each agent the full diff so it has the complete context.\n\n### Agent 1: Code Reuse Review\n\nFor each change:\n\n1. Search for existing utilities and helpers that could replace newly written code. Use Grep to find similar patterns elsewhere in the codebase — common locations are utility directories, shared modules, and files adjacent to the changed ones.\n2. Flag any new function that duplicates existing functionality. Suggest the existing function to use instead.\n3. Flag any inline logic that could use an existing utility — hand-rolled string manipulation, manual path handling, custom environment checks, ad-hoc type guards, and similar patterns are common candidates.\n\nNote: This is a greenfield app, so focus on maximizing simplicity and don't worry about changing things to achieve it.\n\n### Agent 2: Code Quality Review\n\nReview the same changes for hacky patterns:\n\n1. Redundant state: state that duplicates existing state, cached values that could be derived, observers/effects that could be direct calls\n2. Parameter sprawl: adding new parameters to a function instead of generalizing or restructuring existing ones\n3. Copy-paste with slight variation: near-duplicate code blocks that should be unified with a shared abstraction\n4. Leaky abstractions: exposing internal details that should be encapsulated, or breaking existing abstraction boundaries\n5. Stringly-typed code: using raw strings where constants, enums (string unions), or branded types already exist in the codebase\n\nNote: This is a greenfield app, so be aggressive in optimizing quality.\n\n### Agent 3: Efficiency Review\n\nReview the same changes for efficiency:\n\n1. Unnecessary work: redundant computations, repeated file reads, duplicate network/API calls, N+1 patterns\n2. Missed concurrency: independent operations run sequentially when they could run in parallel\n3. Hot-path bloat: new blocking work added to startup or per-request/per-render hot paths\n4. Unnecessary existence checks: pre-checking file/resource existence before operating (TOCTOU anti-pattern) — operate directly and handle the error\n5. Memory: unbounded data structures, missing cleanup, event listener leaks\n6. Overly broad operations: reading entire files when only a portion is needed, loading all items when filtering for one\n\n## Phase 3: Fix Issues\n\nWait for all three agents to complete. Aggregate their findings and fix each issue directly. If a finding is a false positive or not worth addressing, note it and move on — do not argue with the finding, just skip it.\n\nWhen done, briefly summarize what was fixed (or confirm the code was already clean)."
},
"model": {
"String": "gpt-5.5"
},
"label": {
"String": "Simplify (GPT-55)"
}
}
},
"fixup": {
"id": "fixup",
"attrs": {
"model": {
"String": "claude-opus-4-7"
},
"max_visits": {
"Integer": 3
},
"label": {
"String": "Fixup"
},
"provider": {
"String": "anthropic"
},
"prompt": {
"String": "The verify step failed. Read the build output from context and fix all format, clippy, Rust test, docs, TypeScript typecheck/test, and build failures."
}
}
},
"simplify_opus": {
"id": "simplify_opus",
"attrs": {
"label": {
"String": "Simplify (Opus)"
},
"prompt": {
"String": "# Simplify: Code Review and Cleanup\n\nReview changes vs. origin for reuse, quality, and efficiency. Fix any issues found.\n\n## Phase 1: Identify Changes\n\nRun git diff (or git diff HEAD if there are staged changes) to see what changed. If there are no git changes, review the most recently modified files that the user mentioned or that you edited earlier in this conversation.\n\n## Phase 2: Launch Three Review Agents in Parallel\n\nUse the Agent tool to launch all three agents concurrently in a single message. Pass each agent the full diff so it has the complete context.\n\n### Agent 1: Code Reuse Review\n\nFor each change:\n\n1. Search for existing utilities and helpers that could replace newly written code. Use Grep to find similar patterns elsewhere in the codebase — common locations are utility directories, shared modules, and files adjacent to the changed ones.\n2. Flag any new function that duplicates existing functionality. Suggest the existing function to use instead.\n3. Flag any inline logic that could use an existing utility — hand-rolled string manipulation, manual path handling, custom environment checks, ad-hoc type guards, and similar patterns are common candidates.\n\nNote: This is a greenfield app, so focus on maximizing simplicity and don't worry about changing things to achieve it.\n\n### Agent 2: Code Quality Review\n\nReview the same changes for hacky patterns:\n\n1. Redundant state: state that duplicates existing state, cached values that could be derived, observers/effects that could be direct calls\n2. Parameter sprawl: adding new parameters to a function instead of generalizing or restructuring existing ones\n3. Copy-paste with slight variation: near-duplicate code blocks that should be unified with a shared abstraction\n4. Leaky abstractions: exposing internal details that should be encapsulated, or breaking existing abstraction boundaries\n5. Stringly-typed code: using raw strings where constants, enums (string unions), or branded types already exist in the codebase\n\nNote: This is a greenfield app, so be aggressive in optimizing quality.\n\n### Agent 3: Efficiency Review\n\nReview the same changes for efficiency:\n\n1. Unnecessary work: redundant computations, repeated file reads, duplicate network/API calls, N+1 patterns\n2. Missed concurrency: independent operations run sequentially when they could run in parallel\n3. Hot-path bloat: new blocking work added to startup or per-request/per-render hot paths\n4. Unnecessary existence checks: pre-checking file/resource existence before operating (TOCTOU anti-pattern) — operate directly and handle the error\n5. Memory: unbounded data structures, missing cleanup, event listener leaks\n6. Overly broad operations: reading entire files when only a portion is needed, loading all items when filtering for one\n\n## Phase 3: Fix Issues\n\nWait for all three agents to complete. Aggregate their findings and fix each issue directly. If a finding is a false positive or not worth addressing, note it and move on — do not argue with the finding, just skip it.\n\nWhen done, briefly summarize what was fixed (or confirm the code was already clean)."
},
"model": {
"String": "claude-opus-4-7"
},
"provider": {
"String": "anthropic"
}
}
},
"exit": {
"id": "exit",
"attrs": {
"shape": {
"String": "Msquare"
},
"label": {
"String": "Exit"
},
"provider": {
"String": "anthropic"
},
"model": {
"String": "claude-opus-4-7"
}
}
},
"preflight_lint": {
"id": "preflight_lint",
"attrs": {
"script": {
"String": "cargo +nightly-2026-04-14 clippy -q --workspace --all-targets -- -D warnings 2>&1"
},
"model": {
"String": "claude-opus-4-7"
},
"provider": {
"String": "anthropic"
},
"shape": {
"String": "parallelogram"
},
"max_retries": {
"Integer": 0
},
"label": {
"String": "Preflight Lint"
}
}
},
"start": {
"id": "start",
"attrs": {
"label": {
"String": "Start"
},
"model": {
"String": "claude-opus-4-7"
},
"provider": {
"String": "anthropic"
},
"shape": {
"String": "Mdiamond"
}
}
},
"toolchain": {
"id": "toolchain",
"attrs": {
"provider": {
"String": "anthropic"
},
"shape": {
"String": "parallelogram"
},
"label": {
"String": "Toolchain"
},
"model": {
"String": "claude-opus-4-7"
},
"script": {
"String": "command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1"
},
"max_retries": {
"Integer": 0
}
}
}
},
"edges": [
{
"from": "start",
"to": "toolchain",
"attrs": {}
},
{
"from": "toolchain",
"to": "preflight_compile",
"attrs": {
"condition": {
"String": "outcome=succeeded"
}
}
},
{
"from": "toolchain",
"to": "exit",
"attrs": {}
},
{
"from": "preflight_compile",
"to": "preflight_lint",
"attrs": {
"condition": {
"String": "outcome=succeeded"
}
}
},
{
"from": "preflight_compile",
"to": "exit",
"attrs": {}
},
{
"from": "preflight_lint",
"to": "implement",
"attrs": {
"condition": {
"String": "outcome=succeeded"
}
}
},
{
"from": "preflight_lint",
"to": "fix_lints",
"attrs": {}
},
{
"from": "fix_lints",
"to": "preflight_lint",
"attrs": {}
},
{
"from": "implement",
"to": "simplify_opus",
"attrs": {}
},
{
"from": "simplify_opus",
"to": "simplify_gpt",
"attrs": {}
},
{
"from": "simplify_gpt",
"to": "verify",
"attrs": {}
},
{
"from": "verify",
"to": "exit",
"attrs": {
"condition": {
"String": "outcome=succeeded"
}
}
},
{
"from": "verify",
"to": "fixup",
"attrs": {}
},
{
"from": "fixup",
"to": "verify",
"attrs": {}
}
],
"attrs": {
"goal": {
"String": "# Legacy Sandbox Config Auto-Migration Implementation Plan\n\n> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.\n\n**Goal:** Automatically rewrite confidently migratable legacy `[run.sandbox]` config files to the named-environments syntax during startup.\n\n**Architecture:** Keep legacy behavior isolated in a removable `fabro-config` module. The normal settings schema stays strict; only file-based loads get a temporary parse-failure recovery path that rewrites the file, writes a backup, warns, and then resumes normal parsing.\n\n**Tech Stack:** Rust, `toml_edit`, existing `fabro-config` settings builders, `tracing`, `tempfile` tests, public docs under `docs/public`.\n\n---\n\n## File Structure\n\n- Create `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n - Owns detection, TOML rewriting, backup naming/writing, unsupported-key diagnostics, and tests for legacy mappings.\n- Modify `lib/crates/fabro-config/src/lib.rs`\n - Register the module privately.\n- Modify `lib/crates/fabro-config/Cargo.toml`\n - Add the existing workspace `toml_edit` dependency; current main does not depend on it from `fabro-config`.\n- Modify `lib/crates/fabro-config/src/load.rs`\n - Add a small parse-failure hook that delegates to the migration module, then returns to normal parsing.\n- Modify docs:\n - `docs/public/execution/environments.mdx`\n - Create `docs/public/changelog/2026-05-23.mdx` because current main's latest public changelog is `2026-05-22.mdx`.\n\n## Migration Contract\n\nOnly migrate when all of these are true:\n\n- The file is valid TOML as a document.\n- `[run.sandbox]` exists.\n- `[run.environment]` does not exist.\n- `[environments.default]` does not exist.\n- Every legacy sandbox key is in the supported mapping below.\n- The migrated content parses successfully as `SettingsLayer`.\n\nThis is intentionally a file-load migration only. Current in-memory parsing behavior, including `legacy_run_sandbox_is_rejected` in `lib/crates/fabro-config/src/tests/resolve_run.rs`, should remain strict and unchanged.\n\nSupported mappings:\n\n| Legacy key | New key |\n|---|---|\n| `run.sandbox.provider` | `run.environment.id = \"default\"` and `environments.default.provider` |\n| `run.sandbox.preserve` | `environments.default.lifecycle.preserve` |\n| `run.sandbox.env` | `environments.default.env` |\n| `run.sandbox.daytona.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.docker.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.daytona.auto_stop_interval = N` | `environments.default.lifecycle.auto_stop = \"{N}m\"` |\n| `run.sandbox.daytona.labels` | `environments.default.labels` |\n| `run.sandbox.daytona.snapshot.name` | `environments.default.image.ref` |\n| `run.sandbox.daytona.snapshot.cpu` | `environments.default.resources.cpu` |\n| `run.sandbox.daytona.snapshot.memory` | `environments.default.resources.memory` |\n| `run.sandbox.daytona.snapshot.disk` | `environments.default.resources.disk` |\n| `run.sandbox.daytona.snapshot.dockerfile` | `environments.default.image.dockerfile` |\n| `run.sandbox.daytona.volumes[].volume_id` | `environments.default.volumes[].id` |\n| `run.sandbox.daytona.volumes[].mount_path` | `environments.default.volumes[].mount_path` |\n| `run.sandbox.daytona.volumes[].subpath` | `environments.default.volumes[].subpath` |\n| `run.sandbox.docker.image` | `environments.default.image.ref` |\n| `run.sandbox.docker.memory_limit` | `environments.default.resources.memory` |\n| `run.sandbox.docker.cpu_quota` | `environments.default.resources.cpu` when divisible by `100000` |\n\nUnsupported or ambiguous cases fail with a message shaped like:\n\n```text\nLegacy [run.sandbox] settings in <path> could not be auto-migrated.\n\nUnsupported keys:\n - run.sandbox.daytona.foo\n - run.sandbox.docker.cpu_quota\n\nRename legacy sandbox configuration to [run.environment] and [environments.<slug>].\nSee docs/public/execution/environments.mdx.\n```\n\nSuccessful migration writes a backup next to the original file:\n\n```text\nsettings.toml.legacy-sandbox-migration.bak\nsettings.toml.legacy-sandbox-migration.1.bak\nsettings.toml.legacy-sandbox-migration.2.bak\n```\n\nSuccessful migration emits:\n\n```text\nMigrated legacy [run.sandbox] settings in <path> to [run.environment] and [environments.default]. Backup written to <backup>. This temporary compatibility migration will be removed before v1.0.\n```\n\n## Task 1: Add the Migration Module Skeleton\n\n**Files:**\n- Create: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n- Modify: `lib/crates/fabro-config/src/lib.rs`\n- Modify: `lib/crates/fabro-config/Cargo.toml`\n\n- [ ] **Step 1: Add the `toml_edit` dependency**\n\nAdd this to `[dependencies]` in `lib/crates/fabro-config/Cargo.toml`:\n\n```toml\ntoml_edit.workspace = true\n```\n\n- [ ] **Step 2: Register the module privately**\n\nAdd this beside the other private modules in `lib/crates/fabro-config/src/lib.rs`:\n\n```rust\nmod legacy_sandbox_migration;\n```\n\n- [ ] **Step 3: Create the module API**\n\nCreate `lib/crates/fabro-config/src/legacy_sandbox_migration.rs` with this starting shape:\n\n```rust\n#![expect(\n clippy::disallowed_methods,\n reason = \"temporary startup config migration uses synchronous file I/O before config is loaded\"\n)]\n\nuse std::fmt;\nuse std::path::{Path, PathBuf};\n\nuse toml_edit::{DocumentMut, Item, Table, Value};\n\nuse crate::{Error, Result, SettingsLayer};\n\npub(crate) const REMOVAL_NOTE: &str =\n \"This temporary compatibility migration will be removed before v1.0.\";\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub(crate) struct LegacySandboxMigrationReport {\n pub(crate) contents: String,\n pub(crate) backup_path: PathBuf,\n pub(crate) warning: String,\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\nstruct MigrationFailure {\n unsupported_keys: Vec<String>,\n}\n\nimpl fmt::Display for MigrationFailure {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n writeln!(f, \"Legacy [run.sandbox] settings could not be auto-migrated.\")?;\n writeln!(f)?;\n writeln!(f, \"Unsupported keys:\")?;\n for key in &self.unsupported_keys {\n writeln!(f, \" - {key}\")?;\n }\n writeln!(f)?;\n write!(\n f,\n \"Rename legacy sandbox configuration to [run.environment] and [environments.<slug>]. See docs/public/execution/environments.mdx.\"\n )\n }\n}\n\npub(crate) fn migrate_settings_path(\n path: &Path,\n original_contents: &str,\n) -> Result<Option<LegacySandboxMigrationReport>> {\n let Some(next_contents) = migrate_contents(original_contents, path)? else {\n return Ok(None);\n };\n\n next_contents\n .parse::<SettingsLayer>()\n .map_err(|err| Error::parse_file(\"Migrated settings file is invalid\", path, err))?;\n\n let backup_path = next_backup_path(path);\n std::fs::write(&backup_path, original_contents).map_err(|source| {\n Error::other(format!(\n \"writing legacy sandbox migration backup {}: {source}\",\n backup_path.display()\n ))\n })?;\n std::fs::write(path, &next_contents).map_err(|source| {\n Error::other(format!(\n \"writing migrated settings file {}: {source}\",\n path.display()\n ))\n })?;\n\n let warning = format!(\n \"Migrated legacy [run.sandbox] settings in {} to [run.environment] and [environments.default]. Backup written to {}. {REMOVAL_NOTE}\",\n path.display(),\n backup_path.display()\n );\n\n Ok(Some(LegacySandboxMigrationReport {\n contents: next_contents,\n backup_path,\n warning,\n }))\n}\n\nfn migrate_contents(original_contents: &str, path: &Path) -> Result<Option<String>> {\n let mut doc = match original_contents.parse::<DocumentMut>() {\n Ok(doc) => doc,\n Err(_) => return Ok(None),\n };\n\n if !has_legacy_run_sandbox(&doc) {\n return Ok(None);\n }\n if has_new_environment_config(&doc) {\n return Err(Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated because the file already contains [run.environment] or [environments.default]. Remove one config style and retry.\",\n path.display()\n )));\n }\n\n migrate_document(&mut doc).map_err(|failure| {\n Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated.\\n\\n{}\",\n path.display(),\n failure\n ))\n })?;\n\n Ok(Some(doc.to_string()))\n}\n\nfn has_legacy_run_sandbox(doc: &DocumentMut) -> bool {\n doc.get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n .is_some()\n}\n\nfn has_new_environment_config(doc: &DocumentMut) -> bool {\n let has_run_environment = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"environment\"))\n .is_some();\n let has_default_environment = doc\n .get(\"environments\")\n .and_then(Item::as_table)\n .and_then(|envs| envs.get(\"default\"))\n .is_some();\n has_run_environment || has_default_environment\n}\n\nfn next_backup_path(path: &Path) -> PathBuf {\n let base = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !base.exists() {\n return base;\n }\n\n for index in 1.. {\n let candidate = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.{index}.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !candidate.exists() {\n return candidate;\n }\n }\n unreachable!(\"unbounded backup suffix search should return\")\n}\n```\n\n- [ ] **Step 4: Add placeholder-free private stubs that compile**\n\nAdd private helpers with `unimplemented!()` only inside tests disabled by `#[cfg(test)]` is not allowed. Instead, make `migrate_document` return the one known unsupported failure until Task 2 fills it:\n\n```rust\nfn migrate_document(_doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n })\n}\n```\n\n- [ ] **Step 5: Run the focused compile check**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: compiles; there may be zero tests in this module at this point.\n\n## Task 2: Implement Provider-Only Migration\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for provider-only migration**\n\nAdd these tests inside `legacy_sandbox_migration.rs`:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n fn migrate(source: &str) -> String {\n migrate_contents(source, Path::new(\"settings.toml\"))\n .expect(\"migration should not error\")\n .expect(\"legacy sandbox should migrate\")\n }\n\n #[test]\n fn provider_only_daytona_config_migrates_to_default_environment() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n );\n\n let settings = migrated\n .parse::<SettingsLayer>()\n .expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.id, \"default\");\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(migrated.contains(\"[run.environment]\"));\n assert!(migrated.contains(\"[environments.default]\"));\n assert!(!migrated.contains(\"[run.sandbox]\"));\n }\n\n #[test]\n fn non_legacy_config_is_not_migrated() {\n let migrated = migrate_contents(\"_version = 1\\n\", Path::new(\"settings.toml\"))\n .expect(\"non-legacy TOML should not error\");\n\n assert!(migrated.is_none());\n }\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config provider_only_daytona_config_migrates_to_default_environment --quiet\n```\n\nExpected: FAIL because `migrate_document` still returns unsupported `run.sandbox`.\n\n- [ ] **Step 3: Replace `migrate_document` with provider migration**\n\nImplement the initial migration:\n\n```rust\nfn migrate_document(doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n let Some(sandbox_item) = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n else {\n return Ok(());\n };\n let Some(sandbox) = sandbox_item.as_table().cloned() else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n });\n };\n\n let mut unsupported = Vec::new();\n for (key, _) in sandbox.iter() {\n if key != \"provider\" {\n unsupported.push(format!(\"run.sandbox.{key}\"));\n }\n }\n if !unsupported.is_empty() {\n return Err(MigrationFailure {\n unsupported_keys: unsupported,\n });\n }\n\n let Some(provider) = sandbox.get(\"provider\").and_then(Item::as_str) else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox.provider\".to_string()],\n });\n };\n\n set_value(path_table(doc, &[\"run\", \"environment\"]), \"id\", Value::from(\"default\"));\n set_value(\n path_table(doc, &[\"environments\", \"default\"]),\n \"provider\",\n Value::from(provider),\n );\n\n remove_run_sandbox(doc);\n Ok(())\n}\n\nfn path_table<'a>(doc: &'a mut DocumentMut, path: &[&str]) -> &'a mut Table {\n let mut item = doc.as_item_mut();\n for segment in path {\n item = &mut item[segment];\n if !item.is_table() {\n *item = Item::Table(Table::new());\n }\n }\n item.as_table_mut().expect(\"path item should be a table\")\n}\n\nfn set_value(table: &mut Table, key: &str, value: Value) {\n table[key] = Item::Value(value);\n}\n\nfn remove_run_sandbox(doc: &mut DocumentMut) {\n if let Some(run) = doc.get_mut(\"run\").and_then(Item::as_table_mut) {\n run.remove(\"sandbox\");\n }\n}\n```\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 3: Add Daytona and Docker Field Mappings\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for direct legacy field mappings**\n\nAdd tests that assert resolved behavior, not only string contents:\n\n```rust\n#[test]\nfn daytona_snapshot_labels_lifecycle_and_volumes_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\npreserve = true\n\n[run.sandbox.env]\nNODE_ENV = \"development\"\n\n[run.sandbox.daytona]\nauto_stop_interval = 30\n\n[run.sandbox.daytona.labels]\nrepo = \"fabro-sh/fabro\"\n\n[run.sandbox.daytona.snapshot]\nname = \"fabro-v11\"\ncpu = 8\nmemory = \"16GB\"\ndisk = \"20GB\"\ndockerfile = { path = \"Dockerfile\" }\n\n[[run.sandbox.daytona.volumes]]\nvolume_id = \"vol_auth\"\nmount_path = \"/home/daytona/.config\"\nsubpath = \"agents\"\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.image.reference.as_deref(), Some(\"fabro-v11\"));\n assert_eq!(resolved.resources.cpu, Some(8));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(16_000_000_000));\n assert_eq!(resolved.resources.disk.map(|size| size.as_bytes()), Some(20_000_000_000));\n assert!(resolved.lifecycle.preserve);\n assert_eq!(resolved.lifecycle.auto_stop.map(|duration| duration.as_std().as_secs()), Some(1800));\n assert_eq!(resolved.labels.get(\"repo\").map(String::as_str), Some(\"fabro-sh/fabro\"));\n assert_eq!(resolved.env.get(\"NODE_ENV\").map(|value| value.as_source()).as_deref(), Some(\"development\"));\n assert_eq!(resolved.volumes.len(), 1);\n assert_eq!(resolved.volumes[0].id, \"vol_auth\");\n assert_eq!(resolved.volumes[0].mount_path, \"/home/daytona/.config\");\n assert_eq!(resolved.volumes[0].subpath.as_deref(), Some(\"agents\"));\n}\n\n#[test]\nfn docker_image_memory_and_cpu_quota_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\nimage = \"buildpack-deps:noble\"\nmemory_limit = \"4GB\"\ncpu_quota = 200000\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.provider, EnvironmentProvider::Docker);\n assert_eq!(resolved.image.reference.as_deref(), Some(\"buildpack-deps:noble\"));\n assert_eq!(resolved.resources.cpu, Some(2));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(4_000_000_000));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: FAIL because the two new nested-mapping tests are not implemented yet.\n\n- [ ] **Step 3: Implement table copying and value transforms**\n\nExtend `migrate_document` so it:\n\n- Allows top-level legacy keys `provider`, `preserve`, `env`, `daytona`, and `docker`.\n- Copies `run.sandbox.env` into `environments.default.env`.\n- Sets `environments.default.lifecycle.preserve` from `run.sandbox.preserve`.\n- Handles provider-specific nested mappings only for the selected provider.\n- Removes `run.sandbox` after successful migration.\n\nUse helper functions with these signatures:\n\n```rust\nfn migrate_daytona(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn migrate_docker(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn copy_table(source: &Item, target: &mut Table);\nfn copy_array_of_tables_with_volume_id(source: &Item, target: &mut Table, unsupported: &mut Vec<String>);\nfn item_path_keys(prefix: &str, item: &Item, out: &mut Vec<String>);\n```\n\nImplementation rules:\n\n- `auto_stop_interval` must be an integer. Store `format!(\"{minutes}m\")`.\n- `docker.cpu_quota` must be an integer divisible by `100000`; otherwise add `run.sandbox.docker.cpu_quota` to unsupported keys.\n- For Daytona volumes, each array entry may contain only `volume_id`, `mount_path`, and `subpath`; rename `volume_id` to `id`.\n- `daytona.snapshot.dockerfile` must be copied as the existing TOML value, preserving inline string or `{ path = \"...\" }`.\n- When collecting unsupported nested keys, report full paths such as `run.sandbox.daytona.snapshot.foo`.\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 4: Add File Rewrite and Loader Hook\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/load.rs`\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add file rewrite tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn migrate_settings_path_writes_backup_and_rewrites_original() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n let original = r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#;\n std::fs::write(&path, original).expect(\"write fixture\");\n\n let report = migrate_settings_path(&path, original)\n .expect(\"migration should succeed\")\n .expect(\"legacy config should migrate\");\n\n let rewritten = std::fs::read_to_string(&path).expect(\"read rewritten settings\");\n let backup = std::fs::read_to_string(&report.backup_path).expect(\"read backup\");\n\n assert_eq!(backup, original);\n assert!(rewritten.contains(\"[run.environment]\"));\n assert!(rewritten.contains(\"[environments.default]\"));\n assert!(report.warning.contains(\"temporary compatibility migration\"));\n}\n\n#[test]\nfn existing_backup_uses_numbered_suffix() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(path.with_file_name(\"settings.toml.legacy-sandbox-migration.bak\"), \"old\")\n .expect(\"write existing backup\");\n\n let next = next_backup_path(&path);\n\n assert!(next.ends_with(\"settings.toml.legacy-sandbox-migration.1.bak\"));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm current state**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS if Task 1 file-writing code compiled; otherwise fix only the migration module.\n\n- [ ] **Step 3: Hook migration into file loading**\n\nChange `load_settings_path` in `lib/crates/fabro-config/src/load.rs` to this shape:\n\n```rust\npub(crate) fn load_settings_path(path: &Path) -> Result<SettingsLayer> {\n let content = std::fs::read_to_string(path).map_err(|source| Error::read_file(path, source))?;\n let mut layer = match content.parse::<SettingsLayer>() {\n Ok(layer) => layer,\n Err(err) => match crate::legacy_sandbox_migration::migrate_settings_path(path, &content)? {\n Some(report) => {\n tracing::warn!(\"{}\", report.warning);\n eprintln!(\"{}\", report.warning);\n report.contents.parse::<SettingsLayer>().map_err(|err| {\n Error::parse_file(\"Migrated settings file is invalid\", path, err)\n })?\n }\n None => return Err(Error::parse_file(\"Failed to parse settings file\", path, err)),\n },\n };\n let base_dir = path.parent().unwrap_or_else(|| Path::new(\".\"));\n resolve_goal_file_paths(&mut layer, base_dir);\n Ok(layer)\n}\n```\n\n- [ ] **Step 4: Run loader-level verification**\n\nAdd a test in `load.rs` under `#[cfg(test)]` if the file does not already have a test module:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n #[test]\n fn load_settings_path_auto_migrates_legacy_sandbox_file() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(\n &path,\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n )\n .expect(\"write legacy settings\");\n\n let layer = load_settings_path(&path).expect(\"legacy settings should auto-migrate\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&layer)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(std::fs::read_to_string(&path)\n .expect(\"read rewritten settings\")\n .contains(\"[run.environment]\"));\n }\n}\n```\n\nRun:\n\n```bash\ncargo test -p fabro-config load_settings_path_auto_migrates_legacy_sandbox_file --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 5: Verify in-memory TOML parsing remains strict**\n\nRun the existing current-main rejection test:\n\n```bash\ncargo test -p fabro-config legacy_run_sandbox_is_rejected --quiet\n```\n\nExpected: PASS. Do not weaken `SettingsLayer` deserialization to accept `run.sandbox`; only `load_settings_path` should rewrite files from disk.\n\n## Task 5: Unsupported and Ambiguous Cases\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add failure tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn existing_new_environment_config_is_ambiguous() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.environment]\nid = \"default\"\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"mixed old and new config should fail\");\n\n assert!(err.to_string().contains(\"already contains [run.environment]\"));\n}\n\n#[test]\nfn unsupported_keys_are_reported_with_full_paths() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\n[run.sandbox.daytona]\nunknown = true\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"unsupported keys should fail migration\");\n\n let rendered = err.to_string();\n assert!(rendered.contains(\"run.sandbox.daytona.unknown\"));\n assert!(rendered.contains(\"docs/public/execution/environments.mdx\"));\n}\n\n#[test]\nfn unsupported_docker_cpu_quota_is_reported() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\ncpu_quota = 250000\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"non-divisible cpu quota should fail migration\");\n\n assert!(err.to_string().contains(\"run.sandbox.docker.cpu_quota\"));\n}\n```\n\n- [ ] **Step 2: Run failure tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 6: Documentation\n\n**Files:**\n- Modify: `docs/public/execution/environments.mdx`\n- Create: `docs/public/changelog/2026-05-23.mdx`\n\n- [ ] **Step 1: Document temporary auto-migration**\n\nAdd this note near the top of `docs/public/execution/environments.mdx`, after the initial environment/sandbox distinction:\n\n```mdx\n<Warning>\nOlder pre-v1.0 config files that still use `[run.sandbox]` are temporarily auto-migrated when Fabro loads them from disk. Fabro writes a sibling `*.legacy-sandbox-migration.bak` file, rewrites the config to `[run.environment]` plus `[environments.default]`, and then continues startup.\n\nThis compatibility rewrite only handles direct field mappings. Unsupported legacy fields fail with a migration message that lists the keys to edit manually. The rewrite path will be removed before v1.0.\n</Warning>\n```\n\n- [ ] **Step 2: Add a changelog note**\n\nCreate `docs/public/changelog/2026-05-23.mdx`:\n\n```mdx\n---\ntitle: \"Legacy sandbox config migration\"\ndate: \"2026-05-23\"\n---\n\n## Legacy sandbox config auto-migration\n\nFabro now temporarily rewrites confidently migratable pre-v1.0 `[run.sandbox]` config files to the named environment syntax. A backup is written next to the original file before rewriting. Ambiguous or unsupported legacy keys fail with a targeted migration message instead of the generic TOML unknown-field error.\n```\n\n- [ ] **Step 3: Check docs references**\n\nRun:\n\n```bash\nrg -n \"\\\\[run\\\\.sandbox\\\\]|legacy-sandbox-migration|run\\\\.environment\" docs/public/execution docs/public/changelog\n```\n\nExpected: remaining `[run.sandbox]` references are either historical changelog entries or explicit migration warnings.\n\n## Task 7: Full Verification\n\n**Files:**\n- All files touched above.\n\n- [ ] **Step 1: Run config crate tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 2: Run formatting check**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 fmt --check --all\n```\n\nExpected: PASS.\n\n- [ ] **Step 3: Optional workspace lint if formatting and tests pass**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings\n```\n\nExpected: PASS. If this is slow, record that it was not run and include the reason in the handoff.\n\n## Acceptance Criteria\n\n- Boot-time config loading rewrites simple legacy `[run.sandbox]` files without user action.\n- The rewritten file uses `[run.environment] id = \"default\"` and `[environments.default]`.\n- The original file is preserved in a sibling backup before rewrite.\n- Unsupported legacy keys fail with a targeted migration message listing exact keys.\n- Normal strict schema behavior remains unchanged for in-memory `from_toml` calls.\n- All legacy migration code is isolated in `legacy_sandbox_migration.rs` and removable before v1.0.\n"
},
"rankdir": {
"String": "LR"
},
"model_stylesheet": {
"String": "\n * { model: claude-opus-4-7; }\n "
}
}
},
"graph_source": "digraph ImplementPlan {\n graph [\n goal=\"Implement and simplify\",\n model_stylesheet=\"\n * { model: claude-opus-4-7; }\n \"\n ]\n rankdir=LR\n\n start [shape=Mdiamond, label=\"Start\"]\n exit [shape=Msquare, label=\"Exit\"]\n\n toolchain [label=\"Toolchain\", shape=parallelogram, script=\"command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1\", max_retries=0]\n preflight_compile [label=\"Preflight Compile\", shape=parallelogram, script=\"cargo check -q --workspace 2>&1\", max_retries=0]\n preflight_lint [label=\"Preflight Lint\", shape=parallelogram, script=\"cargo +nightly-2026-04-14 clippy -q --workspace --all-targets -- -D warnings 2>&1\", max_retries=0]\n fix_lints [label=\"Fix Lints\", prompt=\"The preflight lint step failed. Read the build output from context and fix all clippy lint warnings.\", max_visits=3]\n implement [label=\"Implement\", prompt=\"Read the plan file referenced in the goal and implement every step. Make all the code changes described in the plan. Use red/green TDD.\", model=\"gpt-55\", reasoning_effort=\"xhigh\"]\n simplify_opus [label=\"Simplify (Opus)\", prompt=\"@prompts/simplify.md\"]\n simplify_gpt [label=\"Simplify (GPT-55)\", prompt=\"@prompts/simplify.md\", model=\"gpt-55\"]\n verify [label=\"Verify\", shape=parallelogram, script=\"git fetch origin main 2>&1 && git merge --no-edit --no-stat origin/main 2>&1 && cargo +nightly-2026-04-14 fmt --all 2>&1 && cargo dev docs refresh 2>&1 && cargo +nightly-2026-04-14 fmt --check --all 2>&1 && ! rg -n 'AuthMode::Disabled|RunAuthMethod|RunSubjectProvenance|\\bActorRef\\b|\\bActorKind\\b|AuthenticatedSubject|AuthenticatedService|AuthorizeRunScoped|AuthorizeRunBlob|AuthorizeStageArtifact|AuthorizeCommandLog|auth_method\\s*==\\s*\\\"disabled\\\"' lib/crates apps lib/packages docs/public/api-reference/fabro-api.yaml 2>&1 && cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings 2>&1 && cargo nextest run --workspace --status-level slow --profile ci 2>&1 && cargo dev docs check 2>&1 && bun install --frozen-lockfile 2>&1 && (cd apps/fabro-web && bun run typecheck) 2>&1 && (cd apps/fabro-web && bun run test) 2>&1 && (cd lib/packages/fabro-api-client && bun run typecheck) 2>&1 && cargo dev build -- -p fabro-cli --release 2>&1\", goal_gate=true, retry_target=\"fixup\"]\n fixup [label=\"Fixup\", prompt=\"The verify step failed. Read the build output from context and fix all format, clippy, Rust test, docs, TypeScript typecheck/test, and build failures.\", max_visits=3]\n\n start -> toolchain\n toolchain -> preflight_compile [condition=\"outcome=succeeded\"]\n toolchain -> exit\n preflight_compile -> preflight_lint [condition=\"outcome=succeeded\"]\n preflight_compile -> exit\n preflight_lint -> implement [condition=\"outcome=succeeded\"]\n preflight_lint -> fix_lints\n fix_lints -> preflight_lint\n implement -> simplify_opus -> simplify_gpt -> verify\n verify -> exit [condition=\"outcome=succeeded\"]\n verify -> fixup\n fixup -> verify\n}\n",
"workflow_slug": "implement-plan",
"source_directory": "/Users/bhelmkamp/p/fabro-sh/fabro",
"provenance": {
"server": {
"version": "0.242.0-nightly.1"
},
"client": {
"user_agent": "fabro-cli/0.242.0-nightly.1",
"name": "fabro-cli",
"version": "0.242.0-nightly.1"
},
"subject": {
"kind": "user",
"identity": {
"issuer": "https://github.com",
"subject": "19"
},
"login": "brynary",
"auth_method": "github",
"avatar_url": "https://avatars.githubusercontent.com/u/19?v=4"
}
},
"manifest_blob": "2e610986f1415ebeebabbba8afd17489a99cf49202cea8bf06521dae025777df",
"definition_blob": "706cd3c883ee5cdedd79e85fe355771be58138e6a8308af811dce4901631b0de",
"git": {
"origin_url": "https://github.com/fabro-sh/fabro",
"branch": "main",
"sha": "dbe3e3966d1eec7a7d235e7db34a46919336cbd9",
"dirty": "dirty",
"push_outcome": {
"type": "not_attempted"
}
}
},
"web_url": "http://127.0.0.1:32276/runs/01KSB6HFNMJ802AXGBAV5JP7ZS",
"start": {
"start_time": "2026-05-23T19:56:21.662532Z",
"run_branch": "fabro/run/01KSB6HFNMJ802AXGBAV5JP7ZS",
"base_sha": "dbe3e3966d1eec7a7d235e7db34a46919336cbd9"
},
"status": {
"kind": "running"
},
"status_updated_at": "2026-05-23T19:56:21.662602Z",
"last_event_at": "2026-05-23T20:23:53.000860Z",
"pending_control": null,
"checkpoints": [
{
"seq": 21,
"checkpoint": {
"timestamp": "2026-05-23T19:56:23.484836Z",
"current_node": "start",
"completed_nodes": [
"start"
],
"node_retries": {},
"context_values": {
"internal.work_dir": "/home/daytona/workspace/fabro",
"failure_class": "",
"internal.thread_id": null,
"internal.fidelity": "compact",
"graph.goal": "# Legacy Sandbox Config Auto-Migration Implementation Plan\n\n> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.\n\n**Goal:** Automatically rewrite confidently migratable legacy `[run.sandbox]` config files to the named-environments syntax during startup.\n\n**Architecture:** Keep legacy behavior isolated in a removable `fabro-config` module. The normal settings schema stays strict; only file-based loads get a temporary parse-failure recovery path that rewrites the file, writes a backup, warns, and then resumes normal parsing.\n\n**Tech Stack:** Rust, `toml_edit`, existing `fabro-config` settings builders, `tracing`, `tempfile` tests, public docs under `docs/public`.\n\n---\n\n## File Structure\n\n- Create `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n - Owns detection, TOML rewriting, backup naming/writing, unsupported-key diagnostics, and tests for legacy mappings.\n- Modify `lib/crates/fabro-config/src/lib.rs`\n - Register the module privately.\n- Modify `lib/crates/fabro-config/Cargo.toml`\n - Add the existing workspace `toml_edit` dependency; current main does not depend on it from `fabro-config`.\n- Modify `lib/crates/fabro-config/src/load.rs`\n - Add a small parse-failure hook that delegates to the migration module, then returns to normal parsing.\n- Modify docs:\n - `docs/public/execution/environments.mdx`\n - Create `docs/public/changelog/2026-05-23.mdx` because current main's latest public changelog is `2026-05-22.mdx`.\n\n## Migration Contract\n\nOnly migrate when all of these are true:\n\n- The file is valid TOML as a document.\n- `[run.sandbox]` exists.\n- `[run.environment]` does not exist.\n- `[environments.default]` does not exist.\n- Every legacy sandbox key is in the supported mapping below.\n- The migrated content parses successfully as `SettingsLayer`.\n\nThis is intentionally a file-load migration only. Current in-memory parsing behavior, including `legacy_run_sandbox_is_rejected` in `lib/crates/fabro-config/src/tests/resolve_run.rs`, should remain strict and unchanged.\n\nSupported mappings:\n\n| Legacy key | New key |\n|---|---|\n| `run.sandbox.provider` | `run.environment.id = \"default\"` and `environments.default.provider` |\n| `run.sandbox.preserve` | `environments.default.lifecycle.preserve` |\n| `run.sandbox.env` | `environments.default.env` |\n| `run.sandbox.daytona.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.docker.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.daytona.auto_stop_interval = N` | `environments.default.lifecycle.auto_stop = \"{N}m\"` |\n| `run.sandbox.daytona.labels` | `environments.default.labels` |\n| `run.sandbox.daytona.snapshot.name` | `environments.default.image.ref` |\n| `run.sandbox.daytona.snapshot.cpu` | `environments.default.resources.cpu` |\n| `run.sandbox.daytona.snapshot.memory` | `environments.default.resources.memory` |\n| `run.sandbox.daytona.snapshot.disk` | `environments.default.resources.disk` |\n| `run.sandbox.daytona.snapshot.dockerfile` | `environments.default.image.dockerfile` |\n| `run.sandbox.daytona.volumes[].volume_id` | `environments.default.volumes[].id` |\n| `run.sandbox.daytona.volumes[].mount_path` | `environments.default.volumes[].mount_path` |\n| `run.sandbox.daytona.volumes[].subpath` | `environments.default.volumes[].subpath` |\n| `run.sandbox.docker.image` | `environments.default.image.ref` |\n| `run.sandbox.docker.memory_limit` | `environments.default.resources.memory` |\n| `run.sandbox.docker.cpu_quota` | `environments.default.resources.cpu` when divisible by `100000` |\n\nUnsupported or ambiguous cases fail with a message shaped like:\n\n```text\nLegacy [run.sandbox] settings in <path> could not be auto-migrated.\n\nUnsupported keys:\n - run.sandbox.daytona.foo\n - run.sandbox.docker.cpu_quota\n\nRename legacy sandbox configuration to [run.environment] and [environments.<slug>].\nSee docs/public/execution/environments.mdx.\n```\n\nSuccessful migration writes a backup next to the original file:\n\n```text\nsettings.toml.legacy-sandbox-migration.bak\nsettings.toml.legacy-sandbox-migration.1.bak\nsettings.toml.legacy-sandbox-migration.2.bak\n```\n\nSuccessful migration emits:\n\n```text\nMigrated legacy [run.sandbox] settings in <path> to [run.environment] and [environments.default]. Backup written to <backup>. This temporary compatibility migration will be removed before v1.0.\n```\n\n## Task 1: Add the Migration Module Skeleton\n\n**Files:**\n- Create: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n- Modify: `lib/crates/fabro-config/src/lib.rs`\n- Modify: `lib/crates/fabro-config/Cargo.toml`\n\n- [ ] **Step 1: Add the `toml_edit` dependency**\n\nAdd this to `[dependencies]` in `lib/crates/fabro-config/Cargo.toml`:\n\n```toml\ntoml_edit.workspace = true\n```\n\n- [ ] **Step 2: Register the module privately**\n\nAdd this beside the other private modules in `lib/crates/fabro-config/src/lib.rs`:\n\n```rust\nmod legacy_sandbox_migration;\n```\n\n- [ ] **Step 3: Create the module API**\n\nCreate `lib/crates/fabro-config/src/legacy_sandbox_migration.rs` with this starting shape:\n\n```rust\n#![expect(\n clippy::disallowed_methods,\n reason = \"temporary startup config migration uses synchronous file I/O before config is loaded\"\n)]\n\nuse std::fmt;\nuse std::path::{Path, PathBuf};\n\nuse toml_edit::{DocumentMut, Item, Table, Value};\n\nuse crate::{Error, Result, SettingsLayer};\n\npub(crate) const REMOVAL_NOTE: &str =\n \"This temporary compatibility migration will be removed before v1.0.\";\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub(crate) struct LegacySandboxMigrationReport {\n pub(crate) contents: String,\n pub(crate) backup_path: PathBuf,\n pub(crate) warning: String,\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\nstruct MigrationFailure {\n unsupported_keys: Vec<String>,\n}\n\nimpl fmt::Display for MigrationFailure {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n writeln!(f, \"Legacy [run.sandbox] settings could not be auto-migrated.\")?;\n writeln!(f)?;\n writeln!(f, \"Unsupported keys:\")?;\n for key in &self.unsupported_keys {\n writeln!(f, \" - {key}\")?;\n }\n writeln!(f)?;\n write!(\n f,\n \"Rename legacy sandbox configuration to [run.environment] and [environments.<slug>]. See docs/public/execution/environments.mdx.\"\n )\n }\n}\n\npub(crate) fn migrate_settings_path(\n path: &Path,\n original_contents: &str,\n) -> Result<Option<LegacySandboxMigrationReport>> {\n let Some(next_contents) = migrate_contents(original_contents, path)? else {\n return Ok(None);\n };\n\n next_contents\n .parse::<SettingsLayer>()\n .map_err(|err| Error::parse_file(\"Migrated settings file is invalid\", path, err))?;\n\n let backup_path = next_backup_path(path);\n std::fs::write(&backup_path, original_contents).map_err(|source| {\n Error::other(format!(\n \"writing legacy sandbox migration backup {}: {source}\",\n backup_path.display()\n ))\n })?;\n std::fs::write(path, &next_contents).map_err(|source| {\n Error::other(format!(\n \"writing migrated settings file {}: {source}\",\n path.display()\n ))\n })?;\n\n let warning = format!(\n \"Migrated legacy [run.sandbox] settings in {} to [run.environment] and [environments.default]. Backup written to {}. {REMOVAL_NOTE}\",\n path.display(),\n backup_path.display()\n );\n\n Ok(Some(LegacySandboxMigrationReport {\n contents: next_contents,\n backup_path,\n warning,\n }))\n}\n\nfn migrate_contents(original_contents: &str, path: &Path) -> Result<Option<String>> {\n let mut doc = match original_contents.parse::<DocumentMut>() {\n Ok(doc) => doc,\n Err(_) => return Ok(None),\n };\n\n if !has_legacy_run_sandbox(&doc) {\n return Ok(None);\n }\n if has_new_environment_config(&doc) {\n return Err(Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated because the file already contains [run.environment] or [environments.default]. Remove one config style and retry.\",\n path.display()\n )));\n }\n\n migrate_document(&mut doc).map_err(|failure| {\n Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated.\\n\\n{}\",\n path.display(),\n failure\n ))\n })?;\n\n Ok(Some(doc.to_string()))\n}\n\nfn has_legacy_run_sandbox(doc: &DocumentMut) -> bool {\n doc.get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n .is_some()\n}\n\nfn has_new_environment_config(doc: &DocumentMut) -> bool {\n let has_run_environment = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"environment\"))\n .is_some();\n let has_default_environment = doc\n .get(\"environments\")\n .and_then(Item::as_table)\n .and_then(|envs| envs.get(\"default\"))\n .is_some();\n has_run_environment || has_default_environment\n}\n\nfn next_backup_path(path: &Path) -> PathBuf {\n let base = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !base.exists() {\n return base;\n }\n\n for index in 1.. {\n let candidate = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.{index}.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !candidate.exists() {\n return candidate;\n }\n }\n unreachable!(\"unbounded backup suffix search should return\")\n}\n```\n\n- [ ] **Step 4: Add placeholder-free private stubs that compile**\n\nAdd private helpers with `unimplemented!()` only inside tests disabled by `#[cfg(test)]` is not allowed. Instead, make `migrate_document` return the one known unsupported failure until Task 2 fills it:\n\n```rust\nfn migrate_document(_doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n })\n}\n```\n\n- [ ] **Step 5: Run the focused compile check**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: compiles; there may be zero tests in this module at this point.\n\n## Task 2: Implement Provider-Only Migration\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for provider-only migration**\n\nAdd these tests inside `legacy_sandbox_migration.rs`:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n fn migrate(source: &str) -> String {\n migrate_contents(source, Path::new(\"settings.toml\"))\n .expect(\"migration should not error\")\n .expect(\"legacy sandbox should migrate\")\n }\n\n #[test]\n fn provider_only_daytona_config_migrates_to_default_environment() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n );\n\n let settings = migrated\n .parse::<SettingsLayer>()\n .expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.id, \"default\");\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(migrated.contains(\"[run.environment]\"));\n assert!(migrated.contains(\"[environments.default]\"));\n assert!(!migrated.contains(\"[run.sandbox]\"));\n }\n\n #[test]\n fn non_legacy_config_is_not_migrated() {\n let migrated = migrate_contents(\"_version = 1\\n\", Path::new(\"settings.toml\"))\n .expect(\"non-legacy TOML should not error\");\n\n assert!(migrated.is_none());\n }\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config provider_only_daytona_config_migrates_to_default_environment --quiet\n```\n\nExpected: FAIL because `migrate_document` still returns unsupported `run.sandbox`.\n\n- [ ] **Step 3: Replace `migrate_document` with provider migration**\n\nImplement the initial migration:\n\n```rust\nfn migrate_document(doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n let Some(sandbox_item) = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n else {\n return Ok(());\n };\n let Some(sandbox) = sandbox_item.as_table().cloned() else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n });\n };\n\n let mut unsupported = Vec::new();\n for (key, _) in sandbox.iter() {\n if key != \"provider\" {\n unsupported.push(format!(\"run.sandbox.{key}\"));\n }\n }\n if !unsupported.is_empty() {\n return Err(MigrationFailure {\n unsupported_keys: unsupported,\n });\n }\n\n let Some(provider) = sandbox.get(\"provider\").and_then(Item::as_str) else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox.provider\".to_string()],\n });\n };\n\n set_value(path_table(doc, &[\"run\", \"environment\"]), \"id\", Value::from(\"default\"));\n set_value(\n path_table(doc, &[\"environments\", \"default\"]),\n \"provider\",\n Value::from(provider),\n );\n\n remove_run_sandbox(doc);\n Ok(())\n}\n\nfn path_table<'a>(doc: &'a mut DocumentMut, path: &[&str]) -> &'a mut Table {\n let mut item = doc.as_item_mut();\n for segment in path {\n item = &mut item[segment];\n if !item.is_table() {\n *item = Item::Table(Table::new());\n }\n }\n item.as_table_mut().expect(\"path item should be a table\")\n}\n\nfn set_value(table: &mut Table, key: &str, value: Value) {\n table[key] = Item::Value(value);\n}\n\nfn remove_run_sandbox(doc: &mut DocumentMut) {\n if let Some(run) = doc.get_mut(\"run\").and_then(Item::as_table_mut) {\n run.remove(\"sandbox\");\n }\n}\n```\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 3: Add Daytona and Docker Field Mappings\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for direct legacy field mappings**\n\nAdd tests that assert resolved behavior, not only string contents:\n\n```rust\n#[test]\nfn daytona_snapshot_labels_lifecycle_and_volumes_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\npreserve = true\n\n[run.sandbox.env]\nNODE_ENV = \"development\"\n\n[run.sandbox.daytona]\nauto_stop_interval = 30\n\n[run.sandbox.daytona.labels]\nrepo = \"fabro-sh/fabro\"\n\n[run.sandbox.daytona.snapshot]\nname = \"fabro-v11\"\ncpu = 8\nmemory = \"16GB\"\ndisk = \"20GB\"\ndockerfile = { path = \"Dockerfile\" }\n\n[[run.sandbox.daytona.volumes]]\nvolume_id = \"vol_auth\"\nmount_path = \"/home/daytona/.config\"\nsubpath = \"agents\"\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.image.reference.as_deref(), Some(\"fabro-v11\"));\n assert_eq!(resolved.resources.cpu, Some(8));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(16_000_000_000));\n assert_eq!(resolved.resources.disk.map(|size| size.as_bytes()), Some(20_000_000_000));\n assert!(resolved.lifecycle.preserve);\n assert_eq!(resolved.lifecycle.auto_stop.map(|duration| duration.as_std().as_secs()), Some(1800));\n assert_eq!(resolved.labels.get(\"repo\").map(String::as_str), Some(\"fabro-sh/fabro\"));\n assert_eq!(resolved.env.get(\"NODE_ENV\").map(|value| value.as_source()).as_deref(), Some(\"development\"));\n assert_eq!(resolved.volumes.len(), 1);\n assert_eq!(resolved.volumes[0].id, \"vol_auth\");\n assert_eq!(resolved.volumes[0].mount_path, \"/home/daytona/.config\");\n assert_eq!(resolved.volumes[0].subpath.as_deref(), Some(\"agents\"));\n}\n\n#[test]\nfn docker_image_memory_and_cpu_quota_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\nimage = \"buildpack-deps:noble\"\nmemory_limit = \"4GB\"\ncpu_quota = 200000\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.provider, EnvironmentProvider::Docker);\n assert_eq!(resolved.image.reference.as_deref(), Some(\"buildpack-deps:noble\"));\n assert_eq!(resolved.resources.cpu, Some(2));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(4_000_000_000));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: FAIL because the two new nested-mapping tests are not implemented yet.\n\n- [ ] **Step 3: Implement table copying and value transforms**\n\nExtend `migrate_document` so it:\n\n- Allows top-level legacy keys `provider`, `preserve`, `env`, `daytona`, and `docker`.\n- Copies `run.sandbox.env` into `environments.default.env`.\n- Sets `environments.default.lifecycle.preserve` from `run.sandbox.preserve`.\n- Handles provider-specific nested mappings only for the selected provider.\n- Removes `run.sandbox` after successful migration.\n\nUse helper functions with these signatures:\n\n```rust\nfn migrate_daytona(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn migrate_docker(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn copy_table(source: &Item, target: &mut Table);\nfn copy_array_of_tables_with_volume_id(source: &Item, target: &mut Table, unsupported: &mut Vec<String>);\nfn item_path_keys(prefix: &str, item: &Item, out: &mut Vec<String>);\n```\n\nImplementation rules:\n\n- `auto_stop_interval` must be an integer. Store `format!(\"{minutes}m\")`.\n- `docker.cpu_quota` must be an integer divisible by `100000`; otherwise add `run.sandbox.docker.cpu_quota` to unsupported keys.\n- For Daytona volumes, each array entry may contain only `volume_id`, `mount_path`, and `subpath`; rename `volume_id` to `id`.\n- `daytona.snapshot.dockerfile` must be copied as the existing TOML value, preserving inline string or `{ path = \"...\" }`.\n- When collecting unsupported nested keys, report full paths such as `run.sandbox.daytona.snapshot.foo`.\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 4: Add File Rewrite and Loader Hook\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/load.rs`\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add file rewrite tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn migrate_settings_path_writes_backup_and_rewrites_original() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n let original = r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#;\n std::fs::write(&path, original).expect(\"write fixture\");\n\n let report = migrate_settings_path(&path, original)\n .expect(\"migration should succeed\")\n .expect(\"legacy config should migrate\");\n\n let rewritten = std::fs::read_to_string(&path).expect(\"read rewritten settings\");\n let backup = std::fs::read_to_string(&report.backup_path).expect(\"read backup\");\n\n assert_eq!(backup, original);\n assert!(rewritten.contains(\"[run.environment]\"));\n assert!(rewritten.contains(\"[environments.default]\"));\n assert!(report.warning.contains(\"temporary compatibility migration\"));\n}\n\n#[test]\nfn existing_backup_uses_numbered_suffix() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(path.with_file_name(\"settings.toml.legacy-sandbox-migration.bak\"), \"old\")\n .expect(\"write existing backup\");\n\n let next = next_backup_path(&path);\n\n assert!(next.ends_with(\"settings.toml.legacy-sandbox-migration.1.bak\"));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm current state**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS if Task 1 file-writing code compiled; otherwise fix only the migration module.\n\n- [ ] **Step 3: Hook migration into file loading**\n\nChange `load_settings_path` in `lib/crates/fabro-config/src/load.rs` to this shape:\n\n```rust\npub(crate) fn load_settings_path(path: &Path) -> Result<SettingsLayer> {\n let content = std::fs::read_to_string(path).map_err(|source| Error::read_file(path, source))?;\n let mut layer = match content.parse::<SettingsLayer>() {\n Ok(layer) => layer,\n Err(err) => match crate::legacy_sandbox_migration::migrate_settings_path(path, &content)? {\n Some(report) => {\n tracing::warn!(\"{}\", report.warning);\n eprintln!(\"{}\", report.warning);\n report.contents.parse::<SettingsLayer>().map_err(|err| {\n Error::parse_file(\"Migrated settings file is invalid\", path, err)\n })?\n }\n None => return Err(Error::parse_file(\"Failed to parse settings file\", path, err)),\n },\n };\n let base_dir = path.parent().unwrap_or_else(|| Path::new(\".\"));\n resolve_goal_file_paths(&mut layer, base_dir);\n Ok(layer)\n}\n```\n\n- [ ] **Step 4: Run loader-level verification**\n\nAdd a test in `load.rs` under `#[cfg(test)]` if the file does not already have a test module:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n #[test]\n fn load_settings_path_auto_migrates_legacy_sandbox_file() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(\n &path,\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n )\n .expect(\"write legacy settings\");\n\n let layer = load_settings_path(&path).expect(\"legacy settings should auto-migrate\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&layer)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(std::fs::read_to_string(&path)\n .expect(\"read rewritten settings\")\n .contains(\"[run.environment]\"));\n }\n}\n```\n\nRun:\n\n```bash\ncargo test -p fabro-config load_settings_path_auto_migrates_legacy_sandbox_file --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 5: Verify in-memory TOML parsing remains strict**\n\nRun the existing current-main rejection test:\n\n```bash\ncargo test -p fabro-config legacy_run_sandbox_is_rejected --quiet\n```\n\nExpected: PASS. Do not weaken `SettingsLayer` deserialization to accept `run.sandbox`; only `load_settings_path` should rewrite files from disk.\n\n## Task 5: Unsupported and Ambiguous Cases\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add failure tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn existing_new_environment_config_is_ambiguous() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.environment]\nid = \"default\"\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"mixed old and new config should fail\");\n\n assert!(err.to_string().contains(\"already contains [run.environment]\"));\n}\n\n#[test]\nfn unsupported_keys_are_reported_with_full_paths() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\n[run.sandbox.daytona]\nunknown = true\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"unsupported keys should fail migration\");\n\n let rendered = err.to_string();\n assert!(rendered.contains(\"run.sandbox.daytona.unknown\"));\n assert!(rendered.contains(\"docs/public/execution/environments.mdx\"));\n}\n\n#[test]\nfn unsupported_docker_cpu_quota_is_reported() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\ncpu_quota = 250000\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"non-divisible cpu quota should fail migration\");\n\n assert!(err.to_string().contains(\"run.sandbox.docker.cpu_quota\"));\n}\n```\n\n- [ ] **Step 2: Run failure tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 6: Documentation\n\n**Files:**\n- Modify: `docs/public/execution/environments.mdx`\n- Create: `docs/public/changelog/2026-05-23.mdx`\n\n- [ ] **Step 1: Document temporary auto-migration**\n\nAdd this note near the top of `docs/public/execution/environments.mdx`, after the initial environment/sandbox distinction:\n\n```mdx\n<Warning>\nOlder pre-v1.0 config files that still use `[run.sandbox]` are temporarily auto-migrated when Fabro loads them from disk. Fabro writes a sibling `*.legacy-sandbox-migration.bak` file, rewrites the config to `[run.environment]` plus `[environments.default]`, and then continues startup.\n\nThis compatibility rewrite only handles direct field mappings. Unsupported legacy fields fail with a migration message that lists the keys to edit manually. The rewrite path will be removed before v1.0.\n</Warning>\n```\n\n- [ ] **Step 2: Add a changelog note**\n\nCreate `docs/public/changelog/2026-05-23.mdx`:\n\n```mdx\n---\ntitle: \"Legacy sandbox config migration\"\ndate: \"2026-05-23\"\n---\n\n## Legacy sandbox config auto-migration\n\nFabro now temporarily rewrites confidently migratable pre-v1.0 `[run.sandbox]` config files to the named environment syntax. A backup is written next to the original file before rewriting. Ambiguous or unsupported legacy keys fail with a targeted migration message instead of the generic TOML unknown-field error.\n```\n\n- [ ] **Step 3: Check docs references**\n\nRun:\n\n```bash\nrg -n \"\\\\[run\\\\.sandbox\\\\]|legacy-sandbox-migration|run\\\\.environment\" docs/public/execution docs/public/changelog\n```\n\nExpected: remaining `[run.sandbox]` references are either historical changelog entries or explicit migration warnings.\n\n## Task 7: Full Verification\n\n**Files:**\n- All files touched above.\n\n- [ ] **Step 1: Run config crate tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 2: Run formatting check**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 fmt --check --all\n```\n\nExpected: PASS.\n\n- [ ] **Step 3: Optional workspace lint if formatting and tests pass**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings\n```\n\nExpected: PASS. If this is slow, record that it was not run and include the reason in the handoff.\n\n## Acceptance Criteria\n\n- Boot-time config loading rewrites simple legacy `[run.sandbox]` files without user action.\n- The rewritten file uses `[run.environment] id = \"default\"` and `[environments.default]`.\n- The original file is preserved in a sibling backup before rewrite.\n- Unsupported legacy keys fail with a targeted migration message listing exact keys.\n- Normal strict schema behavior remains unchanged for in-memory `from_toml` calls.\n- All legacy migration code is isolated in `legacy_sandbox_migration.rs` and removable before v1.0.\n",
"graph.model_stylesheet": "\n * { model: claude-opus-4-7; }\n ",
"failure_signature": "",
"internal.node_visit_count": 1,
"graph.rankdir": "LR",
"current_node": "start",
"internal.retry_count.start": 0,
"internal.run_id": "01KSB6HFNMJ802AXGBAV5JP7ZS",
"outcome": "succeeded"
},
"node_outcomes": {
"start": {
"status": "succeeded",
"usage": null
}
},
"next_node_id": "toolchain",
"node_visits": {
"start": 1
}
},
"diff": {}
},
{
"seq": 29,
"checkpoint": {
"timestamp": "2026-05-23T19:56:28.619158Z",
"current_node": "toolchain",
"completed_nodes": [
"start",
"toolchain"
],
"node_retries": {},
"context_values": {
"graph.model_stylesheet": "\n * { model: claude-opus-4-7; }\n ",
"internal.retry_count.toolchain": 0,
"thread.start.current_node": "toolchain",
"current_node": "toolchain",
"graph.goal": "# Legacy Sandbox Config Auto-Migration Implementation Plan\n\n> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.\n\n**Goal:** Automatically rewrite confidently migratable legacy `[run.sandbox]` config files to the named-environments syntax during startup.\n\n**Architecture:** Keep legacy behavior isolated in a removable `fabro-config` module. The normal settings schema stays strict; only file-based loads get a temporary parse-failure recovery path that rewrites the file, writes a backup, warns, and then resumes normal parsing.\n\n**Tech Stack:** Rust, `toml_edit`, existing `fabro-config` settings builders, `tracing`, `tempfile` tests, public docs under `docs/public`.\n\n---\n\n## File Structure\n\n- Create `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n - Owns detection, TOML rewriting, backup naming/writing, unsupported-key diagnostics, and tests for legacy mappings.\n- Modify `lib/crates/fabro-config/src/lib.rs`\n - Register the module privately.\n- Modify `lib/crates/fabro-config/Cargo.toml`\n - Add the existing workspace `toml_edit` dependency; current main does not depend on it from `fabro-config`.\n- Modify `lib/crates/fabro-config/src/load.rs`\n - Add a small parse-failure hook that delegates to the migration module, then returns to normal parsing.\n- Modify docs:\n - `docs/public/execution/environments.mdx`\n - Create `docs/public/changelog/2026-05-23.mdx` because current main's latest public changelog is `2026-05-22.mdx`.\n\n## Migration Contract\n\nOnly migrate when all of these are true:\n\n- The file is valid TOML as a document.\n- `[run.sandbox]` exists.\n- `[run.environment]` does not exist.\n- `[environments.default]` does not exist.\n- Every legacy sandbox key is in the supported mapping below.\n- The migrated content parses successfully as `SettingsLayer`.\n\nThis is intentionally a file-load migration only. Current in-memory parsing behavior, including `legacy_run_sandbox_is_rejected` in `lib/crates/fabro-config/src/tests/resolve_run.rs`, should remain strict and unchanged.\n\nSupported mappings:\n\n| Legacy key | New key |\n|---|---|\n| `run.sandbox.provider` | `run.environment.id = \"default\"` and `environments.default.provider` |\n| `run.sandbox.preserve` | `environments.default.lifecycle.preserve` |\n| `run.sandbox.env` | `environments.default.env` |\n| `run.sandbox.daytona.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.docker.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.daytona.auto_stop_interval = N` | `environments.default.lifecycle.auto_stop = \"{N}m\"` |\n| `run.sandbox.daytona.labels` | `environments.default.labels` |\n| `run.sandbox.daytona.snapshot.name` | `environments.default.image.ref` |\n| `run.sandbox.daytona.snapshot.cpu` | `environments.default.resources.cpu` |\n| `run.sandbox.daytona.snapshot.memory` | `environments.default.resources.memory` |\n| `run.sandbox.daytona.snapshot.disk` | `environments.default.resources.disk` |\n| `run.sandbox.daytona.snapshot.dockerfile` | `environments.default.image.dockerfile` |\n| `run.sandbox.daytona.volumes[].volume_id` | `environments.default.volumes[].id` |\n| `run.sandbox.daytona.volumes[].mount_path` | `environments.default.volumes[].mount_path` |\n| `run.sandbox.daytona.volumes[].subpath` | `environments.default.volumes[].subpath` |\n| `run.sandbox.docker.image` | `environments.default.image.ref` |\n| `run.sandbox.docker.memory_limit` | `environments.default.resources.memory` |\n| `run.sandbox.docker.cpu_quota` | `environments.default.resources.cpu` when divisible by `100000` |\n\nUnsupported or ambiguous cases fail with a message shaped like:\n\n```text\nLegacy [run.sandbox] settings in <path> could not be auto-migrated.\n\nUnsupported keys:\n - run.sandbox.daytona.foo\n - run.sandbox.docker.cpu_quota\n\nRename legacy sandbox configuration to [run.environment] and [environments.<slug>].\nSee docs/public/execution/environments.mdx.\n```\n\nSuccessful migration writes a backup next to the original file:\n\n```text\nsettings.toml.legacy-sandbox-migration.bak\nsettings.toml.legacy-sandbox-migration.1.bak\nsettings.toml.legacy-sandbox-migration.2.bak\n```\n\nSuccessful migration emits:\n\n```text\nMigrated legacy [run.sandbox] settings in <path> to [run.environment] and [environments.default]. Backup written to <backup>. This temporary compatibility migration will be removed before v1.0.\n```\n\n## Task 1: Add the Migration Module Skeleton\n\n**Files:**\n- Create: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n- Modify: `lib/crates/fabro-config/src/lib.rs`\n- Modify: `lib/crates/fabro-config/Cargo.toml`\n\n- [ ] **Step 1: Add the `toml_edit` dependency**\n\nAdd this to `[dependencies]` in `lib/crates/fabro-config/Cargo.toml`:\n\n```toml\ntoml_edit.workspace = true\n```\n\n- [ ] **Step 2: Register the module privately**\n\nAdd this beside the other private modules in `lib/crates/fabro-config/src/lib.rs`:\n\n```rust\nmod legacy_sandbox_migration;\n```\n\n- [ ] **Step 3: Create the module API**\n\nCreate `lib/crates/fabro-config/src/legacy_sandbox_migration.rs` with this starting shape:\n\n```rust\n#![expect(\n clippy::disallowed_methods,\n reason = \"temporary startup config migration uses synchronous file I/O before config is loaded\"\n)]\n\nuse std::fmt;\nuse std::path::{Path, PathBuf};\n\nuse toml_edit::{DocumentMut, Item, Table, Value};\n\nuse crate::{Error, Result, SettingsLayer};\n\npub(crate) const REMOVAL_NOTE: &str =\n \"This temporary compatibility migration will be removed before v1.0.\";\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub(crate) struct LegacySandboxMigrationReport {\n pub(crate) contents: String,\n pub(crate) backup_path: PathBuf,\n pub(crate) warning: String,\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\nstruct MigrationFailure {\n unsupported_keys: Vec<String>,\n}\n\nimpl fmt::Display for MigrationFailure {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n writeln!(f, \"Legacy [run.sandbox] settings could not be auto-migrated.\")?;\n writeln!(f)?;\n writeln!(f, \"Unsupported keys:\")?;\n for key in &self.unsupported_keys {\n writeln!(f, \" - {key}\")?;\n }\n writeln!(f)?;\n write!(\n f,\n \"Rename legacy sandbox configuration to [run.environment] and [environments.<slug>]. See docs/public/execution/environments.mdx.\"\n )\n }\n}\n\npub(crate) fn migrate_settings_path(\n path: &Path,\n original_contents: &str,\n) -> Result<Option<LegacySandboxMigrationReport>> {\n let Some(next_contents) = migrate_contents(original_contents, path)? else {\n return Ok(None);\n };\n\n next_contents\n .parse::<SettingsLayer>()\n .map_err(|err| Error::parse_file(\"Migrated settings file is invalid\", path, err))?;\n\n let backup_path = next_backup_path(path);\n std::fs::write(&backup_path, original_contents).map_err(|source| {\n Error::other(format!(\n \"writing legacy sandbox migration backup {}: {source}\",\n backup_path.display()\n ))\n })?;\n std::fs::write(path, &next_contents).map_err(|source| {\n Error::other(format!(\n \"writing migrated settings file {}: {source}\",\n path.display()\n ))\n })?;\n\n let warning = format!(\n \"Migrated legacy [run.sandbox] settings in {} to [run.environment] and [environments.default]. Backup written to {}. {REMOVAL_NOTE}\",\n path.display(),\n backup_path.display()\n );\n\n Ok(Some(LegacySandboxMigrationReport {\n contents: next_contents,\n backup_path,\n warning,\n }))\n}\n\nfn migrate_contents(original_contents: &str, path: &Path) -> Result<Option<String>> {\n let mut doc = match original_contents.parse::<DocumentMut>() {\n Ok(doc) => doc,\n Err(_) => return Ok(None),\n };\n\n if !has_legacy_run_sandbox(&doc) {\n return Ok(None);\n }\n if has_new_environment_config(&doc) {\n return Err(Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated because the file already contains [run.environment] or [environments.default]. Remove one config style and retry.\",\n path.display()\n )));\n }\n\n migrate_document(&mut doc).map_err(|failure| {\n Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated.\\n\\n{}\",\n path.display(),\n failure\n ))\n })?;\n\n Ok(Some(doc.to_string()))\n}\n\nfn has_legacy_run_sandbox(doc: &DocumentMut) -> bool {\n doc.get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n .is_some()\n}\n\nfn has_new_environment_config(doc: &DocumentMut) -> bool {\n let has_run_environment = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"environment\"))\n .is_some();\n let has_default_environment = doc\n .get(\"environments\")\n .and_then(Item::as_table)\n .and_then(|envs| envs.get(\"default\"))\n .is_some();\n has_run_environment || has_default_environment\n}\n\nfn next_backup_path(path: &Path) -> PathBuf {\n let base = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !base.exists() {\n return base;\n }\n\n for index in 1.. {\n let candidate = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.{index}.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !candidate.exists() {\n return candidate;\n }\n }\n unreachable!(\"unbounded backup suffix search should return\")\n}\n```\n\n- [ ] **Step 4: Add placeholder-free private stubs that compile**\n\nAdd private helpers with `unimplemented!()` only inside tests disabled by `#[cfg(test)]` is not allowed. Instead, make `migrate_document` return the one known unsupported failure until Task 2 fills it:\n\n```rust\nfn migrate_document(_doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n })\n}\n```\n\n- [ ] **Step 5: Run the focused compile check**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: compiles; there may be zero tests in this module at this point.\n\n## Task 2: Implement Provider-Only Migration\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for provider-only migration**\n\nAdd these tests inside `legacy_sandbox_migration.rs`:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n fn migrate(source: &str) -> String {\n migrate_contents(source, Path::new(\"settings.toml\"))\n .expect(\"migration should not error\")\n .expect(\"legacy sandbox should migrate\")\n }\n\n #[test]\n fn provider_only_daytona_config_migrates_to_default_environment() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n );\n\n let settings = migrated\n .parse::<SettingsLayer>()\n .expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.id, \"default\");\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(migrated.contains(\"[run.environment]\"));\n assert!(migrated.contains(\"[environments.default]\"));\n assert!(!migrated.contains(\"[run.sandbox]\"));\n }\n\n #[test]\n fn non_legacy_config_is_not_migrated() {\n let migrated = migrate_contents(\"_version = 1\\n\", Path::new(\"settings.toml\"))\n .expect(\"non-legacy TOML should not error\");\n\n assert!(migrated.is_none());\n }\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config provider_only_daytona_config_migrates_to_default_environment --quiet\n```\n\nExpected: FAIL because `migrate_document` still returns unsupported `run.sandbox`.\n\n- [ ] **Step 3: Replace `migrate_document` with provider migration**\n\nImplement the initial migration:\n\n```rust\nfn migrate_document(doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n let Some(sandbox_item) = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n else {\n return Ok(());\n };\n let Some(sandbox) = sandbox_item.as_table().cloned() else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n });\n };\n\n let mut unsupported = Vec::new();\n for (key, _) in sandbox.iter() {\n if key != \"provider\" {\n unsupported.push(format!(\"run.sandbox.{key}\"));\n }\n }\n if !unsupported.is_empty() {\n return Err(MigrationFailure {\n unsupported_keys: unsupported,\n });\n }\n\n let Some(provider) = sandbox.get(\"provider\").and_then(Item::as_str) else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox.provider\".to_string()],\n });\n };\n\n set_value(path_table(doc, &[\"run\", \"environment\"]), \"id\", Value::from(\"default\"));\n set_value(\n path_table(doc, &[\"environments\", \"default\"]),\n \"provider\",\n Value::from(provider),\n );\n\n remove_run_sandbox(doc);\n Ok(())\n}\n\nfn path_table<'a>(doc: &'a mut DocumentMut, path: &[&str]) -> &'a mut Table {\n let mut item = doc.as_item_mut();\n for segment in path {\n item = &mut item[segment];\n if !item.is_table() {\n *item = Item::Table(Table::new());\n }\n }\n item.as_table_mut().expect(\"path item should be a table\")\n}\n\nfn set_value(table: &mut Table, key: &str, value: Value) {\n table[key] = Item::Value(value);\n}\n\nfn remove_run_sandbox(doc: &mut DocumentMut) {\n if let Some(run) = doc.get_mut(\"run\").and_then(Item::as_table_mut) {\n run.remove(\"sandbox\");\n }\n}\n```\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 3: Add Daytona and Docker Field Mappings\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for direct legacy field mappings**\n\nAdd tests that assert resolved behavior, not only string contents:\n\n```rust\n#[test]\nfn daytona_snapshot_labels_lifecycle_and_volumes_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\npreserve = true\n\n[run.sandbox.env]\nNODE_ENV = \"development\"\n\n[run.sandbox.daytona]\nauto_stop_interval = 30\n\n[run.sandbox.daytona.labels]\nrepo = \"fabro-sh/fabro\"\n\n[run.sandbox.daytona.snapshot]\nname = \"fabro-v11\"\ncpu = 8\nmemory = \"16GB\"\ndisk = \"20GB\"\ndockerfile = { path = \"Dockerfile\" }\n\n[[run.sandbox.daytona.volumes]]\nvolume_id = \"vol_auth\"\nmount_path = \"/home/daytona/.config\"\nsubpath = \"agents\"\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.image.reference.as_deref(), Some(\"fabro-v11\"));\n assert_eq!(resolved.resources.cpu, Some(8));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(16_000_000_000));\n assert_eq!(resolved.resources.disk.map(|size| size.as_bytes()), Some(20_000_000_000));\n assert!(resolved.lifecycle.preserve);\n assert_eq!(resolved.lifecycle.auto_stop.map(|duration| duration.as_std().as_secs()), Some(1800));\n assert_eq!(resolved.labels.get(\"repo\").map(String::as_str), Some(\"fabro-sh/fabro\"));\n assert_eq!(resolved.env.get(\"NODE_ENV\").map(|value| value.as_source()).as_deref(), Some(\"development\"));\n assert_eq!(resolved.volumes.len(), 1);\n assert_eq!(resolved.volumes[0].id, \"vol_auth\");\n assert_eq!(resolved.volumes[0].mount_path, \"/home/daytona/.config\");\n assert_eq!(resolved.volumes[0].subpath.as_deref(), Some(\"agents\"));\n}\n\n#[test]\nfn docker_image_memory_and_cpu_quota_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\nimage = \"buildpack-deps:noble\"\nmemory_limit = \"4GB\"\ncpu_quota = 200000\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.provider, EnvironmentProvider::Docker);\n assert_eq!(resolved.image.reference.as_deref(), Some(\"buildpack-deps:noble\"));\n assert_eq!(resolved.resources.cpu, Some(2));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(4_000_000_000));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: FAIL because the two new nested-mapping tests are not implemented yet.\n\n- [ ] **Step 3: Implement table copying and value transforms**\n\nExtend `migrate_document` so it:\n\n- Allows top-level legacy keys `provider`, `preserve`, `env`, `daytona`, and `docker`.\n- Copies `run.sandbox.env` into `environments.default.env`.\n- Sets `environments.default.lifecycle.preserve` from `run.sandbox.preserve`.\n- Handles provider-specific nested mappings only for the selected provider.\n- Removes `run.sandbox` after successful migration.\n\nUse helper functions with these signatures:\n\n```rust\nfn migrate_daytona(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn migrate_docker(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn copy_table(source: &Item, target: &mut Table);\nfn copy_array_of_tables_with_volume_id(source: &Item, target: &mut Table, unsupported: &mut Vec<String>);\nfn item_path_keys(prefix: &str, item: &Item, out: &mut Vec<String>);\n```\n\nImplementation rules:\n\n- `auto_stop_interval` must be an integer. Store `format!(\"{minutes}m\")`.\n- `docker.cpu_quota` must be an integer divisible by `100000`; otherwise add `run.sandbox.docker.cpu_quota` to unsupported keys.\n- For Daytona volumes, each array entry may contain only `volume_id`, `mount_path`, and `subpath`; rename `volume_id` to `id`.\n- `daytona.snapshot.dockerfile` must be copied as the existing TOML value, preserving inline string or `{ path = \"...\" }`.\n- When collecting unsupported nested keys, report full paths such as `run.sandbox.daytona.snapshot.foo`.\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 4: Add File Rewrite and Loader Hook\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/load.rs`\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add file rewrite tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn migrate_settings_path_writes_backup_and_rewrites_original() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n let original = r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#;\n std::fs::write(&path, original).expect(\"write fixture\");\n\n let report = migrate_settings_path(&path, original)\n .expect(\"migration should succeed\")\n .expect(\"legacy config should migrate\");\n\n let rewritten = std::fs::read_to_string(&path).expect(\"read rewritten settings\");\n let backup = std::fs::read_to_string(&report.backup_path).expect(\"read backup\");\n\n assert_eq!(backup, original);\n assert!(rewritten.contains(\"[run.environment]\"));\n assert!(rewritten.contains(\"[environments.default]\"));\n assert!(report.warning.contains(\"temporary compatibility migration\"));\n}\n\n#[test]\nfn existing_backup_uses_numbered_suffix() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(path.with_file_name(\"settings.toml.legacy-sandbox-migration.bak\"), \"old\")\n .expect(\"write existing backup\");\n\n let next = next_backup_path(&path);\n\n assert!(next.ends_with(\"settings.toml.legacy-sandbox-migration.1.bak\"));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm current state**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS if Task 1 file-writing code compiled; otherwise fix only the migration module.\n\n- [ ] **Step 3: Hook migration into file loading**\n\nChange `load_settings_path` in `lib/crates/fabro-config/src/load.rs` to this shape:\n\n```rust\npub(crate) fn load_settings_path(path: &Path) -> Result<SettingsLayer> {\n let content = std::fs::read_to_string(path).map_err(|source| Error::read_file(path, source))?;\n let mut layer = match content.parse::<SettingsLayer>() {\n Ok(layer) => layer,\n Err(err) => match crate::legacy_sandbox_migration::migrate_settings_path(path, &content)? {\n Some(report) => {\n tracing::warn!(\"{}\", report.warning);\n eprintln!(\"{}\", report.warning);\n report.contents.parse::<SettingsLayer>().map_err(|err| {\n Error::parse_file(\"Migrated settings file is invalid\", path, err)\n })?\n }\n None => return Err(Error::parse_file(\"Failed to parse settings file\", path, err)),\n },\n };\n let base_dir = path.parent().unwrap_or_else(|| Path::new(\".\"));\n resolve_goal_file_paths(&mut layer, base_dir);\n Ok(layer)\n}\n```\n\n- [ ] **Step 4: Run loader-level verification**\n\nAdd a test in `load.rs` under `#[cfg(test)]` if the file does not already have a test module:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n #[test]\n fn load_settings_path_auto_migrates_legacy_sandbox_file() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(\n &path,\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n )\n .expect(\"write legacy settings\");\n\n let layer = load_settings_path(&path).expect(\"legacy settings should auto-migrate\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&layer)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(std::fs::read_to_string(&path)\n .expect(\"read rewritten settings\")\n .contains(\"[run.environment]\"));\n }\n}\n```\n\nRun:\n\n```bash\ncargo test -p fabro-config load_settings_path_auto_migrates_legacy_sandbox_file --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 5: Verify in-memory TOML parsing remains strict**\n\nRun the existing current-main rejection test:\n\n```bash\ncargo test -p fabro-config legacy_run_sandbox_is_rejected --quiet\n```\n\nExpected: PASS. Do not weaken `SettingsLayer` deserialization to accept `run.sandbox`; only `load_settings_path` should rewrite files from disk.\n\n## Task 5: Unsupported and Ambiguous Cases\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add failure tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn existing_new_environment_config_is_ambiguous() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.environment]\nid = \"default\"\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"mixed old and new config should fail\");\n\n assert!(err.to_string().contains(\"already contains [run.environment]\"));\n}\n\n#[test]\nfn unsupported_keys_are_reported_with_full_paths() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\n[run.sandbox.daytona]\nunknown = true\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"unsupported keys should fail migration\");\n\n let rendered = err.to_string();\n assert!(rendered.contains(\"run.sandbox.daytona.unknown\"));\n assert!(rendered.contains(\"docs/public/execution/environments.mdx\"));\n}\n\n#[test]\nfn unsupported_docker_cpu_quota_is_reported() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\ncpu_quota = 250000\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"non-divisible cpu quota should fail migration\");\n\n assert!(err.to_string().contains(\"run.sandbox.docker.cpu_quota\"));\n}\n```\n\n- [ ] **Step 2: Run failure tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 6: Documentation\n\n**Files:**\n- Modify: `docs/public/execution/environments.mdx`\n- Create: `docs/public/changelog/2026-05-23.mdx`\n\n- [ ] **Step 1: Document temporary auto-migration**\n\nAdd this note near the top of `docs/public/execution/environments.mdx`, after the initial environment/sandbox distinction:\n\n```mdx\n<Warning>\nOlder pre-v1.0 config files that still use `[run.sandbox]` are temporarily auto-migrated when Fabro loads them from disk. Fabro writes a sibling `*.legacy-sandbox-migration.bak` file, rewrites the config to `[run.environment]` plus `[environments.default]`, and then continues startup.\n\nThis compatibility rewrite only handles direct field mappings. Unsupported legacy fields fail with a migration message that lists the keys to edit manually. The rewrite path will be removed before v1.0.\n</Warning>\n```\n\n- [ ] **Step 2: Add a changelog note**\n\nCreate `docs/public/changelog/2026-05-23.mdx`:\n\n```mdx\n---\ntitle: \"Legacy sandbox config migration\"\ndate: \"2026-05-23\"\n---\n\n## Legacy sandbox config auto-migration\n\nFabro now temporarily rewrites confidently migratable pre-v1.0 `[run.sandbox]` config files to the named environment syntax. A backup is written next to the original file before rewriting. Ambiguous or unsupported legacy keys fail with a targeted migration message instead of the generic TOML unknown-field error.\n```\n\n- [ ] **Step 3: Check docs references**\n\nRun:\n\n```bash\nrg -n \"\\\\[run\\\\.sandbox\\\\]|legacy-sandbox-migration|run\\\\.environment\" docs/public/execution docs/public/changelog\n```\n\nExpected: remaining `[run.sandbox]` references are either historical changelog entries or explicit migration warnings.\n\n## Task 7: Full Verification\n\n**Files:**\n- All files touched above.\n\n- [ ] **Step 1: Run config crate tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 2: Run formatting check**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 fmt --check --all\n```\n\nExpected: PASS.\n\n- [ ] **Step 3: Optional workspace lint if formatting and tests pass**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings\n```\n\nExpected: PASS. If this is slow, record that it was not run and include the reason in the handoff.\n\n## Acceptance Criteria\n\n- Boot-time config loading rewrites simple legacy `[run.sandbox]` files without user action.\n- The rewritten file uses `[run.environment] id = \"default\"` and `[environments.default]`.\n- The original file is preserved in a sibling backup before rewrite.\n- Unsupported legacy keys fail with a targeted migration message listing exact keys.\n- Normal strict schema behavior remains unchanged for in-memory `from_toml` calls.\n- All legacy migration code is isolated in `legacy_sandbox_migration.rs` and removable before v1.0.\n",
"failure_signature": "",
"internal.run_id": "01KSB6HFNMJ802AXGBAV5JP7ZS",
"graph.rankdir": "LR",
"internal.node_visit_count": 1,
"failure_class": "",
"command.output": "blob://sha256/fc14b2ba2d770e5cd3169df7a29525c962adfc4cfa3097b9098c63ebd61a748c",
"internal.fidelity": "compact",
"internal.retry_count.start": 0,
"internal.work_dir": "/home/daytona/workspace/fabro",
"internal.thread_id": "start",
"outcome": "succeeded"
},
"node_outcomes": {
"toolchain": {
"status": "succeeded",
"context_updates": {
"command.output": "blob://sha256/fc14b2ba2d770e5cd3169df7a29525c962adfc4cfa3097b9098c63ebd61a748c"
},
"notes": "Script completed: command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1",
"usage": null
},
"start": {
"status": "succeeded",
"usage": null
}
},
"next_node_id": "preflight_compile",
"git_commit_sha": "4a837d6de2f1cc38ccebc0cf7324008406e13f19",
"node_visits": {
"toolchain": 1,
"start": 1
}
},
"diff": {
"summary": {
"files_changed": 0,
"additions": 0,
"deletions": 0
}
}
},
{
"seq": 39,
"checkpoint": {
"timestamp": "2026-05-23T19:58:37.363260Z",
"current_node": "preflight_compile",
"completed_nodes": [
"start",
"toolchain",
"preflight_compile"
],
"node_retries": {},
"context_values": {
"internal.thread_id": "toolchain",
"internal.work_dir": "/home/daytona/workspace/fabro",
"thread.start.current_node": "toolchain",
"thread.toolchain.current_node": "preflight_compile",
"failure_signature": "",
"graph.goal": "# Legacy Sandbox Config Auto-Migration Implementation Plan\n\n> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.\n\n**Goal:** Automatically rewrite confidently migratable legacy `[run.sandbox]` config files to the named-environments syntax during startup.\n\n**Architecture:** Keep legacy behavior isolated in a removable `fabro-config` module. The normal settings schema stays strict; only file-based loads get a temporary parse-failure recovery path that rewrites the file, writes a backup, warns, and then resumes normal parsing.\n\n**Tech Stack:** Rust, `toml_edit`, existing `fabro-config` settings builders, `tracing`, `tempfile` tests, public docs under `docs/public`.\n\n---\n\n## File Structure\n\n- Create `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n - Owns detection, TOML rewriting, backup naming/writing, unsupported-key diagnostics, and tests for legacy mappings.\n- Modify `lib/crates/fabro-config/src/lib.rs`\n - Register the module privately.\n- Modify `lib/crates/fabro-config/Cargo.toml`\n - Add the existing workspace `toml_edit` dependency; current main does not depend on it from `fabro-config`.\n- Modify `lib/crates/fabro-config/src/load.rs`\n - Add a small parse-failure hook that delegates to the migration module, then returns to normal parsing.\n- Modify docs:\n - `docs/public/execution/environments.mdx`\n - Create `docs/public/changelog/2026-05-23.mdx` because current main's latest public changelog is `2026-05-22.mdx`.\n\n## Migration Contract\n\nOnly migrate when all of these are true:\n\n- The file is valid TOML as a document.\n- `[run.sandbox]` exists.\n- `[run.environment]` does not exist.\n- `[environments.default]` does not exist.\n- Every legacy sandbox key is in the supported mapping below.\n- The migrated content parses successfully as `SettingsLayer`.\n\nThis is intentionally a file-load migration only. Current in-memory parsing behavior, including `legacy_run_sandbox_is_rejected` in `lib/crates/fabro-config/src/tests/resolve_run.rs`, should remain strict and unchanged.\n\nSupported mappings:\n\n| Legacy key | New key |\n|---|---|\n| `run.sandbox.provider` | `run.environment.id = \"default\"` and `environments.default.provider` |\n| `run.sandbox.preserve` | `environments.default.lifecycle.preserve` |\n| `run.sandbox.env` | `environments.default.env` |\n| `run.sandbox.daytona.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.docker.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.daytona.auto_stop_interval = N` | `environments.default.lifecycle.auto_stop = \"{N}m\"` |\n| `run.sandbox.daytona.labels` | `environments.default.labels` |\n| `run.sandbox.daytona.snapshot.name` | `environments.default.image.ref` |\n| `run.sandbox.daytona.snapshot.cpu` | `environments.default.resources.cpu` |\n| `run.sandbox.daytona.snapshot.memory` | `environments.default.resources.memory` |\n| `run.sandbox.daytona.snapshot.disk` | `environments.default.resources.disk` |\n| `run.sandbox.daytona.snapshot.dockerfile` | `environments.default.image.dockerfile` |\n| `run.sandbox.daytona.volumes[].volume_id` | `environments.default.volumes[].id` |\n| `run.sandbox.daytona.volumes[].mount_path` | `environments.default.volumes[].mount_path` |\n| `run.sandbox.daytona.volumes[].subpath` | `environments.default.volumes[].subpath` |\n| `run.sandbox.docker.image` | `environments.default.image.ref` |\n| `run.sandbox.docker.memory_limit` | `environments.default.resources.memory` |\n| `run.sandbox.docker.cpu_quota` | `environments.default.resources.cpu` when divisible by `100000` |\n\nUnsupported or ambiguous cases fail with a message shaped like:\n\n```text\nLegacy [run.sandbox] settings in <path> could not be auto-migrated.\n\nUnsupported keys:\n - run.sandbox.daytona.foo\n - run.sandbox.docker.cpu_quota\n\nRename legacy sandbox configuration to [run.environment] and [environments.<slug>].\nSee docs/public/execution/environments.mdx.\n```\n\nSuccessful migration writes a backup next to the original file:\n\n```text\nsettings.toml.legacy-sandbox-migration.bak\nsettings.toml.legacy-sandbox-migration.1.bak\nsettings.toml.legacy-sandbox-migration.2.bak\n```\n\nSuccessful migration emits:\n\n```text\nMigrated legacy [run.sandbox] settings in <path> to [run.environment] and [environments.default]. Backup written to <backup>. This temporary compatibility migration will be removed before v1.0.\n```\n\n## Task 1: Add the Migration Module Skeleton\n\n**Files:**\n- Create: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n- Modify: `lib/crates/fabro-config/src/lib.rs`\n- Modify: `lib/crates/fabro-config/Cargo.toml`\n\n- [ ] **Step 1: Add the `toml_edit` dependency**\n\nAdd this to `[dependencies]` in `lib/crates/fabro-config/Cargo.toml`:\n\n```toml\ntoml_edit.workspace = true\n```\n\n- [ ] **Step 2: Register the module privately**\n\nAdd this beside the other private modules in `lib/crates/fabro-config/src/lib.rs`:\n\n```rust\nmod legacy_sandbox_migration;\n```\n\n- [ ] **Step 3: Create the module API**\n\nCreate `lib/crates/fabro-config/src/legacy_sandbox_migration.rs` with this starting shape:\n\n```rust\n#![expect(\n clippy::disallowed_methods,\n reason = \"temporary startup config migration uses synchronous file I/O before config is loaded\"\n)]\n\nuse std::fmt;\nuse std::path::{Path, PathBuf};\n\nuse toml_edit::{DocumentMut, Item, Table, Value};\n\nuse crate::{Error, Result, SettingsLayer};\n\npub(crate) const REMOVAL_NOTE: &str =\n \"This temporary compatibility migration will be removed before v1.0.\";\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub(crate) struct LegacySandboxMigrationReport {\n pub(crate) contents: String,\n pub(crate) backup_path: PathBuf,\n pub(crate) warning: String,\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\nstruct MigrationFailure {\n unsupported_keys: Vec<String>,\n}\n\nimpl fmt::Display for MigrationFailure {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n writeln!(f, \"Legacy [run.sandbox] settings could not be auto-migrated.\")?;\n writeln!(f)?;\n writeln!(f, \"Unsupported keys:\")?;\n for key in &self.unsupported_keys {\n writeln!(f, \" - {key}\")?;\n }\n writeln!(f)?;\n write!(\n f,\n \"Rename legacy sandbox configuration to [run.environment] and [environments.<slug>]. See docs/public/execution/environments.mdx.\"\n )\n }\n}\n\npub(crate) fn migrate_settings_path(\n path: &Path,\n original_contents: &str,\n) -> Result<Option<LegacySandboxMigrationReport>> {\n let Some(next_contents) = migrate_contents(original_contents, path)? else {\n return Ok(None);\n };\n\n next_contents\n .parse::<SettingsLayer>()\n .map_err(|err| Error::parse_file(\"Migrated settings file is invalid\", path, err))?;\n\n let backup_path = next_backup_path(path);\n std::fs::write(&backup_path, original_contents).map_err(|source| {\n Error::other(format!(\n \"writing legacy sandbox migration backup {}: {source}\",\n backup_path.display()\n ))\n })?;\n std::fs::write(path, &next_contents).map_err(|source| {\n Error::other(format!(\n \"writing migrated settings file {}: {source}\",\n path.display()\n ))\n })?;\n\n let warning = format!(\n \"Migrated legacy [run.sandbox] settings in {} to [run.environment] and [environments.default]. Backup written to {}. {REMOVAL_NOTE}\",\n path.display(),\n backup_path.display()\n );\n\n Ok(Some(LegacySandboxMigrationReport {\n contents: next_contents,\n backup_path,\n warning,\n }))\n}\n\nfn migrate_contents(original_contents: &str, path: &Path) -> Result<Option<String>> {\n let mut doc = match original_contents.parse::<DocumentMut>() {\n Ok(doc) => doc,\n Err(_) => return Ok(None),\n };\n\n if !has_legacy_run_sandbox(&doc) {\n return Ok(None);\n }\n if has_new_environment_config(&doc) {\n return Err(Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated because the file already contains [run.environment] or [environments.default]. Remove one config style and retry.\",\n path.display()\n )));\n }\n\n migrate_document(&mut doc).map_err(|failure| {\n Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated.\\n\\n{}\",\n path.display(),\n failure\n ))\n })?;\n\n Ok(Some(doc.to_string()))\n}\n\nfn has_legacy_run_sandbox(doc: &DocumentMut) -> bool {\n doc.get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n .is_some()\n}\n\nfn has_new_environment_config(doc: &DocumentMut) -> bool {\n let has_run_environment = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"environment\"))\n .is_some();\n let has_default_environment = doc\n .get(\"environments\")\n .and_then(Item::as_table)\n .and_then(|envs| envs.get(\"default\"))\n .is_some();\n has_run_environment || has_default_environment\n}\n\nfn next_backup_path(path: &Path) -> PathBuf {\n let base = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !base.exists() {\n return base;\n }\n\n for index in 1.. {\n let candidate = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.{index}.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !candidate.exists() {\n return candidate;\n }\n }\n unreachable!(\"unbounded backup suffix search should return\")\n}\n```\n\n- [ ] **Step 4: Add placeholder-free private stubs that compile**\n\nAdd private helpers with `unimplemented!()` only inside tests disabled by `#[cfg(test)]` is not allowed. Instead, make `migrate_document` return the one known unsupported failure until Task 2 fills it:\n\n```rust\nfn migrate_document(_doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n })\n}\n```\n\n- [ ] **Step 5: Run the focused compile check**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: compiles; there may be zero tests in this module at this point.\n\n## Task 2: Implement Provider-Only Migration\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for provider-only migration**\n\nAdd these tests inside `legacy_sandbox_migration.rs`:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n fn migrate(source: &str) -> String {\n migrate_contents(source, Path::new(\"settings.toml\"))\n .expect(\"migration should not error\")\n .expect(\"legacy sandbox should migrate\")\n }\n\n #[test]\n fn provider_only_daytona_config_migrates_to_default_environment() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n );\n\n let settings = migrated\n .parse::<SettingsLayer>()\n .expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.id, \"default\");\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(migrated.contains(\"[run.environment]\"));\n assert!(migrated.contains(\"[environments.default]\"));\n assert!(!migrated.contains(\"[run.sandbox]\"));\n }\n\n #[test]\n fn non_legacy_config_is_not_migrated() {\n let migrated = migrate_contents(\"_version = 1\\n\", Path::new(\"settings.toml\"))\n .expect(\"non-legacy TOML should not error\");\n\n assert!(migrated.is_none());\n }\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config provider_only_daytona_config_migrates_to_default_environment --quiet\n```\n\nExpected: FAIL because `migrate_document` still returns unsupported `run.sandbox`.\n\n- [ ] **Step 3: Replace `migrate_document` with provider migration**\n\nImplement the initial migration:\n\n```rust\nfn migrate_document(doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n let Some(sandbox_item) = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n else {\n return Ok(());\n };\n let Some(sandbox) = sandbox_item.as_table().cloned() else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n });\n };\n\n let mut unsupported = Vec::new();\n for (key, _) in sandbox.iter() {\n if key != \"provider\" {\n unsupported.push(format!(\"run.sandbox.{key}\"));\n }\n }\n if !unsupported.is_empty() {\n return Err(MigrationFailure {\n unsupported_keys: unsupported,\n });\n }\n\n let Some(provider) = sandbox.get(\"provider\").and_then(Item::as_str) else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox.provider\".to_string()],\n });\n };\n\n set_value(path_table(doc, &[\"run\", \"environment\"]), \"id\", Value::from(\"default\"));\n set_value(\n path_table(doc, &[\"environments\", \"default\"]),\n \"provider\",\n Value::from(provider),\n );\n\n remove_run_sandbox(doc);\n Ok(())\n}\n\nfn path_table<'a>(doc: &'a mut DocumentMut, path: &[&str]) -> &'a mut Table {\n let mut item = doc.as_item_mut();\n for segment in path {\n item = &mut item[segment];\n if !item.is_table() {\n *item = Item::Table(Table::new());\n }\n }\n item.as_table_mut().expect(\"path item should be a table\")\n}\n\nfn set_value(table: &mut Table, key: &str, value: Value) {\n table[key] = Item::Value(value);\n}\n\nfn remove_run_sandbox(doc: &mut DocumentMut) {\n if let Some(run) = doc.get_mut(\"run\").and_then(Item::as_table_mut) {\n run.remove(\"sandbox\");\n }\n}\n```\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 3: Add Daytona and Docker Field Mappings\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for direct legacy field mappings**\n\nAdd tests that assert resolved behavior, not only string contents:\n\n```rust\n#[test]\nfn daytona_snapshot_labels_lifecycle_and_volumes_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\npreserve = true\n\n[run.sandbox.env]\nNODE_ENV = \"development\"\n\n[run.sandbox.daytona]\nauto_stop_interval = 30\n\n[run.sandbox.daytona.labels]\nrepo = \"fabro-sh/fabro\"\n\n[run.sandbox.daytona.snapshot]\nname = \"fabro-v11\"\ncpu = 8\nmemory = \"16GB\"\ndisk = \"20GB\"\ndockerfile = { path = \"Dockerfile\" }\n\n[[run.sandbox.daytona.volumes]]\nvolume_id = \"vol_auth\"\nmount_path = \"/home/daytona/.config\"\nsubpath = \"agents\"\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.image.reference.as_deref(), Some(\"fabro-v11\"));\n assert_eq!(resolved.resources.cpu, Some(8));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(16_000_000_000));\n assert_eq!(resolved.resources.disk.map(|size| size.as_bytes()), Some(20_000_000_000));\n assert!(resolved.lifecycle.preserve);\n assert_eq!(resolved.lifecycle.auto_stop.map(|duration| duration.as_std().as_secs()), Some(1800));\n assert_eq!(resolved.labels.get(\"repo\").map(String::as_str), Some(\"fabro-sh/fabro\"));\n assert_eq!(resolved.env.get(\"NODE_ENV\").map(|value| value.as_source()).as_deref(), Some(\"development\"));\n assert_eq!(resolved.volumes.len(), 1);\n assert_eq!(resolved.volumes[0].id, \"vol_auth\");\n assert_eq!(resolved.volumes[0].mount_path, \"/home/daytona/.config\");\n assert_eq!(resolved.volumes[0].subpath.as_deref(), Some(\"agents\"));\n}\n\n#[test]\nfn docker_image_memory_and_cpu_quota_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\nimage = \"buildpack-deps:noble\"\nmemory_limit = \"4GB\"\ncpu_quota = 200000\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.provider, EnvironmentProvider::Docker);\n assert_eq!(resolved.image.reference.as_deref(), Some(\"buildpack-deps:noble\"));\n assert_eq!(resolved.resources.cpu, Some(2));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(4_000_000_000));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: FAIL because the two new nested-mapping tests are not implemented yet.\n\n- [ ] **Step 3: Implement table copying and value transforms**\n\nExtend `migrate_document` so it:\n\n- Allows top-level legacy keys `provider`, `preserve`, `env`, `daytona`, and `docker`.\n- Copies `run.sandbox.env` into `environments.default.env`.\n- Sets `environments.default.lifecycle.preserve` from `run.sandbox.preserve`.\n- Handles provider-specific nested mappings only for the selected provider.\n- Removes `run.sandbox` after successful migration.\n\nUse helper functions with these signatures:\n\n```rust\nfn migrate_daytona(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn migrate_docker(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn copy_table(source: &Item, target: &mut Table);\nfn copy_array_of_tables_with_volume_id(source: &Item, target: &mut Table, unsupported: &mut Vec<String>);\nfn item_path_keys(prefix: &str, item: &Item, out: &mut Vec<String>);\n```\n\nImplementation rules:\n\n- `auto_stop_interval` must be an integer. Store `format!(\"{minutes}m\")`.\n- `docker.cpu_quota` must be an integer divisible by `100000`; otherwise add `run.sandbox.docker.cpu_quota` to unsupported keys.\n- For Daytona volumes, each array entry may contain only `volume_id`, `mount_path`, and `subpath`; rename `volume_id` to `id`.\n- `daytona.snapshot.dockerfile` must be copied as the existing TOML value, preserving inline string or `{ path = \"...\" }`.\n- When collecting unsupported nested keys, report full paths such as `run.sandbox.daytona.snapshot.foo`.\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 4: Add File Rewrite and Loader Hook\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/load.rs`\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add file rewrite tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn migrate_settings_path_writes_backup_and_rewrites_original() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n let original = r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#;\n std::fs::write(&path, original).expect(\"write fixture\");\n\n let report = migrate_settings_path(&path, original)\n .expect(\"migration should succeed\")\n .expect(\"legacy config should migrate\");\n\n let rewritten = std::fs::read_to_string(&path).expect(\"read rewritten settings\");\n let backup = std::fs::read_to_string(&report.backup_path).expect(\"read backup\");\n\n assert_eq!(backup, original);\n assert!(rewritten.contains(\"[run.environment]\"));\n assert!(rewritten.contains(\"[environments.default]\"));\n assert!(report.warning.contains(\"temporary compatibility migration\"));\n}\n\n#[test]\nfn existing_backup_uses_numbered_suffix() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(path.with_file_name(\"settings.toml.legacy-sandbox-migration.bak\"), \"old\")\n .expect(\"write existing backup\");\n\n let next = next_backup_path(&path);\n\n assert!(next.ends_with(\"settings.toml.legacy-sandbox-migration.1.bak\"));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm current state**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS if Task 1 file-writing code compiled; otherwise fix only the migration module.\n\n- [ ] **Step 3: Hook migration into file loading**\n\nChange `load_settings_path` in `lib/crates/fabro-config/src/load.rs` to this shape:\n\n```rust\npub(crate) fn load_settings_path(path: &Path) -> Result<SettingsLayer> {\n let content = std::fs::read_to_string(path).map_err(|source| Error::read_file(path, source))?;\n let mut layer = match content.parse::<SettingsLayer>() {\n Ok(layer) => layer,\n Err(err) => match crate::legacy_sandbox_migration::migrate_settings_path(path, &content)? {\n Some(report) => {\n tracing::warn!(\"{}\", report.warning);\n eprintln!(\"{}\", report.warning);\n report.contents.parse::<SettingsLayer>().map_err(|err| {\n Error::parse_file(\"Migrated settings file is invalid\", path, err)\n })?\n }\n None => return Err(Error::parse_file(\"Failed to parse settings file\", path, err)),\n },\n };\n let base_dir = path.parent().unwrap_or_else(|| Path::new(\".\"));\n resolve_goal_file_paths(&mut layer, base_dir);\n Ok(layer)\n}\n```\n\n- [ ] **Step 4: Run loader-level verification**\n\nAdd a test in `load.rs` under `#[cfg(test)]` if the file does not already have a test module:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n #[test]\n fn load_settings_path_auto_migrates_legacy_sandbox_file() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(\n &path,\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n )\n .expect(\"write legacy settings\");\n\n let layer = load_settings_path(&path).expect(\"legacy settings should auto-migrate\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&layer)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(std::fs::read_to_string(&path)\n .expect(\"read rewritten settings\")\n .contains(\"[run.environment]\"));\n }\n}\n```\n\nRun:\n\n```bash\ncargo test -p fabro-config load_settings_path_auto_migrates_legacy_sandbox_file --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 5: Verify in-memory TOML parsing remains strict**\n\nRun the existing current-main rejection test:\n\n```bash\ncargo test -p fabro-config legacy_run_sandbox_is_rejected --quiet\n```\n\nExpected: PASS. Do not weaken `SettingsLayer` deserialization to accept `run.sandbox`; only `load_settings_path` should rewrite files from disk.\n\n## Task 5: Unsupported and Ambiguous Cases\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add failure tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn existing_new_environment_config_is_ambiguous() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.environment]\nid = \"default\"\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"mixed old and new config should fail\");\n\n assert!(err.to_string().contains(\"already contains [run.environment]\"));\n}\n\n#[test]\nfn unsupported_keys_are_reported_with_full_paths() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\n[run.sandbox.daytona]\nunknown = true\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"unsupported keys should fail migration\");\n\n let rendered = err.to_string();\n assert!(rendered.contains(\"run.sandbox.daytona.unknown\"));\n assert!(rendered.contains(\"docs/public/execution/environments.mdx\"));\n}\n\n#[test]\nfn unsupported_docker_cpu_quota_is_reported() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\ncpu_quota = 250000\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"non-divisible cpu quota should fail migration\");\n\n assert!(err.to_string().contains(\"run.sandbox.docker.cpu_quota\"));\n}\n```\n\n- [ ] **Step 2: Run failure tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 6: Documentation\n\n**Files:**\n- Modify: `docs/public/execution/environments.mdx`\n- Create: `docs/public/changelog/2026-05-23.mdx`\n\n- [ ] **Step 1: Document temporary auto-migration**\n\nAdd this note near the top of `docs/public/execution/environments.mdx`, after the initial environment/sandbox distinction:\n\n```mdx\n<Warning>\nOlder pre-v1.0 config files that still use `[run.sandbox]` are temporarily auto-migrated when Fabro loads them from disk. Fabro writes a sibling `*.legacy-sandbox-migration.bak` file, rewrites the config to `[run.environment]` plus `[environments.default]`, and then continues startup.\n\nThis compatibility rewrite only handles direct field mappings. Unsupported legacy fields fail with a migration message that lists the keys to edit manually. The rewrite path will be removed before v1.0.\n</Warning>\n```\n\n- [ ] **Step 2: Add a changelog note**\n\nCreate `docs/public/changelog/2026-05-23.mdx`:\n\n```mdx\n---\ntitle: \"Legacy sandbox config migration\"\ndate: \"2026-05-23\"\n---\n\n## Legacy sandbox config auto-migration\n\nFabro now temporarily rewrites confidently migratable pre-v1.0 `[run.sandbox]` config files to the named environment syntax. A backup is written next to the original file before rewriting. Ambiguous or unsupported legacy keys fail with a targeted migration message instead of the generic TOML unknown-field error.\n```\n\n- [ ] **Step 3: Check docs references**\n\nRun:\n\n```bash\nrg -n \"\\\\[run\\\\.sandbox\\\\]|legacy-sandbox-migration|run\\\\.environment\" docs/public/execution docs/public/changelog\n```\n\nExpected: remaining `[run.sandbox]` references are either historical changelog entries or explicit migration warnings.\n\n## Task 7: Full Verification\n\n**Files:**\n- All files touched above.\n\n- [ ] **Step 1: Run config crate tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 2: Run formatting check**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 fmt --check --all\n```\n\nExpected: PASS.\n\n- [ ] **Step 3: Optional workspace lint if formatting and tests pass**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings\n```\n\nExpected: PASS. If this is slow, record that it was not run and include the reason in the handoff.\n\n## Acceptance Criteria\n\n- Boot-time config loading rewrites simple legacy `[run.sandbox]` files without user action.\n- The rewritten file uses `[run.environment] id = \"default\"` and `[environments.default]`.\n- The original file is preserved in a sibling backup before rewrite.\n- Unsupported legacy keys fail with a targeted migration message listing exact keys.\n- Normal strict schema behavior remains unchanged for in-memory `from_toml` calls.\n- All legacy migration code is isolated in `legacy_sandbox_migration.rs` and removable before v1.0.\n",
"outcome": "succeeded",
"internal.retry_count.start": 0,
"internal.fidelity": "compact",
"command.output": "blob://sha256/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126",
"current_node": "preflight_compile",
"failure_class": "",
"internal.retry_count.preflight_compile": 0,
"graph.rankdir": "LR",
"internal.node_visit_count": 1,
"internal.retry_count.toolchain": 0,
"graph.model_stylesheet": "\n * { model: claude-opus-4-7; }\n ",
"internal.run_id": "01KSB6HFNMJ802AXGBAV5JP7ZS"
},
"node_outcomes": {
"preflight_compile": {
"status": "succeeded",
"context_updates": {
"command.output": "blob://sha256/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126"
},
"notes": "Script completed: cargo check -q --workspace 2>&1",
"usage": null
},
"start": {
"status": "succeeded",
"usage": null
},
"toolchain": {
"status": "succeeded",
"context_updates": {
"command.output": "blob://sha256/fc14b2ba2d770e5cd3169df7a29525c962adfc4cfa3097b9098c63ebd61a748c"
},
"notes": "Script completed: command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1",
"usage": null
}
},
"next_node_id": "preflight_lint",
"git_commit_sha": "d832993a871b4c8f1864d9d002aee4376312abc0",
"node_visits": {
"preflight_compile": 1,
"start": 1,
"toolchain": 1
}
},
"diff": {
"summary": {
"files_changed": 0,
"additions": 0,
"deletions": 0
}
}
},
{
"seq": 84,
"checkpoint": {
"timestamp": "2026-05-23T20:00:58.519795Z",
"current_node": "preflight_lint",
"completed_nodes": [
"start",
"toolchain",
"preflight_compile",
"preflight_lint"
],
"node_retries": {},
"context_values": {
"failure_signature": "",
"graph.model_stylesheet": "\n * { model: claude-opus-4-7; }\n ",
"graph.rankdir": "LR",
"internal.run_id": "01KSB6HFNMJ802AXGBAV5JP7ZS",
"internal.retry_count.start": 0,
"internal.node_visit_count": 1,
"outcome": "succeeded",
"command.output": "blob://sha256/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126",
"internal.thread_id": "preflight_compile",
"thread.start.current_node": "toolchain",
"graph.goal": "# Legacy Sandbox Config Auto-Migration Implementation Plan\n\n> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.\n\n**Goal:** Automatically rewrite confidently migratable legacy `[run.sandbox]` config files to the named-environments syntax during startup.\n\n**Architecture:** Keep legacy behavior isolated in a removable `fabro-config` module. The normal settings schema stays strict; only file-based loads get a temporary parse-failure recovery path that rewrites the file, writes a backup, warns, and then resumes normal parsing.\n\n**Tech Stack:** Rust, `toml_edit`, existing `fabro-config` settings builders, `tracing`, `tempfile` tests, public docs under `docs/public`.\n\n---\n\n## File Structure\n\n- Create `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n - Owns detection, TOML rewriting, backup naming/writing, unsupported-key diagnostics, and tests for legacy mappings.\n- Modify `lib/crates/fabro-config/src/lib.rs`\n - Register the module privately.\n- Modify `lib/crates/fabro-config/Cargo.toml`\n - Add the existing workspace `toml_edit` dependency; current main does not depend on it from `fabro-config`.\n- Modify `lib/crates/fabro-config/src/load.rs`\n - Add a small parse-failure hook that delegates to the migration module, then returns to normal parsing.\n- Modify docs:\n - `docs/public/execution/environments.mdx`\n - Create `docs/public/changelog/2026-05-23.mdx` because current main's latest public changelog is `2026-05-22.mdx`.\n\n## Migration Contract\n\nOnly migrate when all of these are true:\n\n- The file is valid TOML as a document.\n- `[run.sandbox]` exists.\n- `[run.environment]` does not exist.\n- `[environments.default]` does not exist.\n- Every legacy sandbox key is in the supported mapping below.\n- The migrated content parses successfully as `SettingsLayer`.\n\nThis is intentionally a file-load migration only. Current in-memory parsing behavior, including `legacy_run_sandbox_is_rejected` in `lib/crates/fabro-config/src/tests/resolve_run.rs`, should remain strict and unchanged.\n\nSupported mappings:\n\n| Legacy key | New key |\n|---|---|\n| `run.sandbox.provider` | `run.environment.id = \"default\"` and `environments.default.provider` |\n| `run.sandbox.preserve` | `environments.default.lifecycle.preserve` |\n| `run.sandbox.env` | `environments.default.env` |\n| `run.sandbox.daytona.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.docker.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.daytona.auto_stop_interval = N` | `environments.default.lifecycle.auto_stop = \"{N}m\"` |\n| `run.sandbox.daytona.labels` | `environments.default.labels` |\n| `run.sandbox.daytona.snapshot.name` | `environments.default.image.ref` |\n| `run.sandbox.daytona.snapshot.cpu` | `environments.default.resources.cpu` |\n| `run.sandbox.daytona.snapshot.memory` | `environments.default.resources.memory` |\n| `run.sandbox.daytona.snapshot.disk` | `environments.default.resources.disk` |\n| `run.sandbox.daytona.snapshot.dockerfile` | `environments.default.image.dockerfile` |\n| `run.sandbox.daytona.volumes[].volume_id` | `environments.default.volumes[].id` |\n| `run.sandbox.daytona.volumes[].mount_path` | `environments.default.volumes[].mount_path` |\n| `run.sandbox.daytona.volumes[].subpath` | `environments.default.volumes[].subpath` |\n| `run.sandbox.docker.image` | `environments.default.image.ref` |\n| `run.sandbox.docker.memory_limit` | `environments.default.resources.memory` |\n| `run.sandbox.docker.cpu_quota` | `environments.default.resources.cpu` when divisible by `100000` |\n\nUnsupported or ambiguous cases fail with a message shaped like:\n\n```text\nLegacy [run.sandbox] settings in <path> could not be auto-migrated.\n\nUnsupported keys:\n - run.sandbox.daytona.foo\n - run.sandbox.docker.cpu_quota\n\nRename legacy sandbox configuration to [run.environment] and [environments.<slug>].\nSee docs/public/execution/environments.mdx.\n```\n\nSuccessful migration writes a backup next to the original file:\n\n```text\nsettings.toml.legacy-sandbox-migration.bak\nsettings.toml.legacy-sandbox-migration.1.bak\nsettings.toml.legacy-sandbox-migration.2.bak\n```\n\nSuccessful migration emits:\n\n```text\nMigrated legacy [run.sandbox] settings in <path> to [run.environment] and [environments.default]. Backup written to <backup>. This temporary compatibility migration will be removed before v1.0.\n```\n\n## Task 1: Add the Migration Module Skeleton\n\n**Files:**\n- Create: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n- Modify: `lib/crates/fabro-config/src/lib.rs`\n- Modify: `lib/crates/fabro-config/Cargo.toml`\n\n- [ ] **Step 1: Add the `toml_edit` dependency**\n\nAdd this to `[dependencies]` in `lib/crates/fabro-config/Cargo.toml`:\n\n```toml\ntoml_edit.workspace = true\n```\n\n- [ ] **Step 2: Register the module privately**\n\nAdd this beside the other private modules in `lib/crates/fabro-config/src/lib.rs`:\n\n```rust\nmod legacy_sandbox_migration;\n```\n\n- [ ] **Step 3: Create the module API**\n\nCreate `lib/crates/fabro-config/src/legacy_sandbox_migration.rs` with this starting shape:\n\n```rust\n#![expect(\n clippy::disallowed_methods,\n reason = \"temporary startup config migration uses synchronous file I/O before config is loaded\"\n)]\n\nuse std::fmt;\nuse std::path::{Path, PathBuf};\n\nuse toml_edit::{DocumentMut, Item, Table, Value};\n\nuse crate::{Error, Result, SettingsLayer};\n\npub(crate) const REMOVAL_NOTE: &str =\n \"This temporary compatibility migration will be removed before v1.0.\";\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub(crate) struct LegacySandboxMigrationReport {\n pub(crate) contents: String,\n pub(crate) backup_path: PathBuf,\n pub(crate) warning: String,\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\nstruct MigrationFailure {\n unsupported_keys: Vec<String>,\n}\n\nimpl fmt::Display for MigrationFailure {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n writeln!(f, \"Legacy [run.sandbox] settings could not be auto-migrated.\")?;\n writeln!(f)?;\n writeln!(f, \"Unsupported keys:\")?;\n for key in &self.unsupported_keys {\n writeln!(f, \" - {key}\")?;\n }\n writeln!(f)?;\n write!(\n f,\n \"Rename legacy sandbox configuration to [run.environment] and [environments.<slug>]. See docs/public/execution/environments.mdx.\"\n )\n }\n}\n\npub(crate) fn migrate_settings_path(\n path: &Path,\n original_contents: &str,\n) -> Result<Option<LegacySandboxMigrationReport>> {\n let Some(next_contents) = migrate_contents(original_contents, path)? else {\n return Ok(None);\n };\n\n next_contents\n .parse::<SettingsLayer>()\n .map_err(|err| Error::parse_file(\"Migrated settings file is invalid\", path, err))?;\n\n let backup_path = next_backup_path(path);\n std::fs::write(&backup_path, original_contents).map_err(|source| {\n Error::other(format!(\n \"writing legacy sandbox migration backup {}: {source}\",\n backup_path.display()\n ))\n })?;\n std::fs::write(path, &next_contents).map_err(|source| {\n Error::other(format!(\n \"writing migrated settings file {}: {source}\",\n path.display()\n ))\n })?;\n\n let warning = format!(\n \"Migrated legacy [run.sandbox] settings in {} to [run.environment] and [environments.default]. Backup written to {}. {REMOVAL_NOTE}\",\n path.display(),\n backup_path.display()\n );\n\n Ok(Some(LegacySandboxMigrationReport {\n contents: next_contents,\n backup_path,\n warning,\n }))\n}\n\nfn migrate_contents(original_contents: &str, path: &Path) -> Result<Option<String>> {\n let mut doc = match original_contents.parse::<DocumentMut>() {\n Ok(doc) => doc,\n Err(_) => return Ok(None),\n };\n\n if !has_legacy_run_sandbox(&doc) {\n return Ok(None);\n }\n if has_new_environment_config(&doc) {\n return Err(Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated because the file already contains [run.environment] or [environments.default]. Remove one config style and retry.\",\n path.display()\n )));\n }\n\n migrate_document(&mut doc).map_err(|failure| {\n Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated.\\n\\n{}\",\n path.display(),\n failure\n ))\n })?;\n\n Ok(Some(doc.to_string()))\n}\n\nfn has_legacy_run_sandbox(doc: &DocumentMut) -> bool {\n doc.get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n .is_some()\n}\n\nfn has_new_environment_config(doc: &DocumentMut) -> bool {\n let has_run_environment = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"environment\"))\n .is_some();\n let has_default_environment = doc\n .get(\"environments\")\n .and_then(Item::as_table)\n .and_then(|envs| envs.get(\"default\"))\n .is_some();\n has_run_environment || has_default_environment\n}\n\nfn next_backup_path(path: &Path) -> PathBuf {\n let base = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !base.exists() {\n return base;\n }\n\n for index in 1.. {\n let candidate = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.{index}.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !candidate.exists() {\n return candidate;\n }\n }\n unreachable!(\"unbounded backup suffix search should return\")\n}\n```\n\n- [ ] **Step 4: Add placeholder-free private stubs that compile**\n\nAdd private helpers with `unimplemented!()` only inside tests disabled by `#[cfg(test)]` is not allowed. Instead, make `migrate_document` return the one known unsupported failure until Task 2 fills it:\n\n```rust\nfn migrate_document(_doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n })\n}\n```\n\n- [ ] **Step 5: Run the focused compile check**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: compiles; there may be zero tests in this module at this point.\n\n## Task 2: Implement Provider-Only Migration\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for provider-only migration**\n\nAdd these tests inside `legacy_sandbox_migration.rs`:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n fn migrate(source: &str) -> String {\n migrate_contents(source, Path::new(\"settings.toml\"))\n .expect(\"migration should not error\")\n .expect(\"legacy sandbox should migrate\")\n }\n\n #[test]\n fn provider_only_daytona_config_migrates_to_default_environment() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n );\n\n let settings = migrated\n .parse::<SettingsLayer>()\n .expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.id, \"default\");\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(migrated.contains(\"[run.environment]\"));\n assert!(migrated.contains(\"[environments.default]\"));\n assert!(!migrated.contains(\"[run.sandbox]\"));\n }\n\n #[test]\n fn non_legacy_config_is_not_migrated() {\n let migrated = migrate_contents(\"_version = 1\\n\", Path::new(\"settings.toml\"))\n .expect(\"non-legacy TOML should not error\");\n\n assert!(migrated.is_none());\n }\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config provider_only_daytona_config_migrates_to_default_environment --quiet\n```\n\nExpected: FAIL because `migrate_document` still returns unsupported `run.sandbox`.\n\n- [ ] **Step 3: Replace `migrate_document` with provider migration**\n\nImplement the initial migration:\n\n```rust\nfn migrate_document(doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n let Some(sandbox_item) = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n else {\n return Ok(());\n };\n let Some(sandbox) = sandbox_item.as_table().cloned() else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n });\n };\n\n let mut unsupported = Vec::new();\n for (key, _) in sandbox.iter() {\n if key != \"provider\" {\n unsupported.push(format!(\"run.sandbox.{key}\"));\n }\n }\n if !unsupported.is_empty() {\n return Err(MigrationFailure {\n unsupported_keys: unsupported,\n });\n }\n\n let Some(provider) = sandbox.get(\"provider\").and_then(Item::as_str) else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox.provider\".to_string()],\n });\n };\n\n set_value(path_table(doc, &[\"run\", \"environment\"]), \"id\", Value::from(\"default\"));\n set_value(\n path_table(doc, &[\"environments\", \"default\"]),\n \"provider\",\n Value::from(provider),\n );\n\n remove_run_sandbox(doc);\n Ok(())\n}\n\nfn path_table<'a>(doc: &'a mut DocumentMut, path: &[&str]) -> &'a mut Table {\n let mut item = doc.as_item_mut();\n for segment in path {\n item = &mut item[segment];\n if !item.is_table() {\n *item = Item::Table(Table::new());\n }\n }\n item.as_table_mut().expect(\"path item should be a table\")\n}\n\nfn set_value(table: &mut Table, key: &str, value: Value) {\n table[key] = Item::Value(value);\n}\n\nfn remove_run_sandbox(doc: &mut DocumentMut) {\n if let Some(run) = doc.get_mut(\"run\").and_then(Item::as_table_mut) {\n run.remove(\"sandbox\");\n }\n}\n```\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 3: Add Daytona and Docker Field Mappings\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for direct legacy field mappings**\n\nAdd tests that assert resolved behavior, not only string contents:\n\n```rust\n#[test]\nfn daytona_snapshot_labels_lifecycle_and_volumes_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\npreserve = true\n\n[run.sandbox.env]\nNODE_ENV = \"development\"\n\n[run.sandbox.daytona]\nauto_stop_interval = 30\n\n[run.sandbox.daytona.labels]\nrepo = \"fabro-sh/fabro\"\n\n[run.sandbox.daytona.snapshot]\nname = \"fabro-v11\"\ncpu = 8\nmemory = \"16GB\"\ndisk = \"20GB\"\ndockerfile = { path = \"Dockerfile\" }\n\n[[run.sandbox.daytona.volumes]]\nvolume_id = \"vol_auth\"\nmount_path = \"/home/daytona/.config\"\nsubpath = \"agents\"\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.image.reference.as_deref(), Some(\"fabro-v11\"));\n assert_eq!(resolved.resources.cpu, Some(8));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(16_000_000_000));\n assert_eq!(resolved.resources.disk.map(|size| size.as_bytes()), Some(20_000_000_000));\n assert!(resolved.lifecycle.preserve);\n assert_eq!(resolved.lifecycle.auto_stop.map(|duration| duration.as_std().as_secs()), Some(1800));\n assert_eq!(resolved.labels.get(\"repo\").map(String::as_str), Some(\"fabro-sh/fabro\"));\n assert_eq!(resolved.env.get(\"NODE_ENV\").map(|value| value.as_source()).as_deref(), Some(\"development\"));\n assert_eq!(resolved.volumes.len(), 1);\n assert_eq!(resolved.volumes[0].id, \"vol_auth\");\n assert_eq!(resolved.volumes[0].mount_path, \"/home/daytona/.config\");\n assert_eq!(resolved.volumes[0].subpath.as_deref(), Some(\"agents\"));\n}\n\n#[test]\nfn docker_image_memory_and_cpu_quota_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\nimage = \"buildpack-deps:noble\"\nmemory_limit = \"4GB\"\ncpu_quota = 200000\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.provider, EnvironmentProvider::Docker);\n assert_eq!(resolved.image.reference.as_deref(), Some(\"buildpack-deps:noble\"));\n assert_eq!(resolved.resources.cpu, Some(2));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(4_000_000_000));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: FAIL because the two new nested-mapping tests are not implemented yet.\n\n- [ ] **Step 3: Implement table copying and value transforms**\n\nExtend `migrate_document` so it:\n\n- Allows top-level legacy keys `provider`, `preserve`, `env`, `daytona`, and `docker`.\n- Copies `run.sandbox.env` into `environments.default.env`.\n- Sets `environments.default.lifecycle.preserve` from `run.sandbox.preserve`.\n- Handles provider-specific nested mappings only for the selected provider.\n- Removes `run.sandbox` after successful migration.\n\nUse helper functions with these signatures:\n\n```rust\nfn migrate_daytona(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn migrate_docker(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn copy_table(source: &Item, target: &mut Table);\nfn copy_array_of_tables_with_volume_id(source: &Item, target: &mut Table, unsupported: &mut Vec<String>);\nfn item_path_keys(prefix: &str, item: &Item, out: &mut Vec<String>);\n```\n\nImplementation rules:\n\n- `auto_stop_interval` must be an integer. Store `format!(\"{minutes}m\")`.\n- `docker.cpu_quota` must be an integer divisible by `100000`; otherwise add `run.sandbox.docker.cpu_quota` to unsupported keys.\n- For Daytona volumes, each array entry may contain only `volume_id`, `mount_path`, and `subpath`; rename `volume_id` to `id`.\n- `daytona.snapshot.dockerfile` must be copied as the existing TOML value, preserving inline string or `{ path = \"...\" }`.\n- When collecting unsupported nested keys, report full paths such as `run.sandbox.daytona.snapshot.foo`.\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 4: Add File Rewrite and Loader Hook\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/load.rs`\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add file rewrite tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn migrate_settings_path_writes_backup_and_rewrites_original() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n let original = r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#;\n std::fs::write(&path, original).expect(\"write fixture\");\n\n let report = migrate_settings_path(&path, original)\n .expect(\"migration should succeed\")\n .expect(\"legacy config should migrate\");\n\n let rewritten = std::fs::read_to_string(&path).expect(\"read rewritten settings\");\n let backup = std::fs::read_to_string(&report.backup_path).expect(\"read backup\");\n\n assert_eq!(backup, original);\n assert!(rewritten.contains(\"[run.environment]\"));\n assert!(rewritten.contains(\"[environments.default]\"));\n assert!(report.warning.contains(\"temporary compatibility migration\"));\n}\n\n#[test]\nfn existing_backup_uses_numbered_suffix() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(path.with_file_name(\"settings.toml.legacy-sandbox-migration.bak\"), \"old\")\n .expect(\"write existing backup\");\n\n let next = next_backup_path(&path);\n\n assert!(next.ends_with(\"settings.toml.legacy-sandbox-migration.1.bak\"));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm current state**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS if Task 1 file-writing code compiled; otherwise fix only the migration module.\n\n- [ ] **Step 3: Hook migration into file loading**\n\nChange `load_settings_path` in `lib/crates/fabro-config/src/load.rs` to this shape:\n\n```rust\npub(crate) fn load_settings_path(path: &Path) -> Result<SettingsLayer> {\n let content = std::fs::read_to_string(path).map_err(|source| Error::read_file(path, source))?;\n let mut layer = match content.parse::<SettingsLayer>() {\n Ok(layer) => layer,\n Err(err) => match crate::legacy_sandbox_migration::migrate_settings_path(path, &content)? {\n Some(report) => {\n tracing::warn!(\"{}\", report.warning);\n eprintln!(\"{}\", report.warning);\n report.contents.parse::<SettingsLayer>().map_err(|err| {\n Error::parse_file(\"Migrated settings file is invalid\", path, err)\n })?\n }\n None => return Err(Error::parse_file(\"Failed to parse settings file\", path, err)),\n },\n };\n let base_dir = path.parent().unwrap_or_else(|| Path::new(\".\"));\n resolve_goal_file_paths(&mut layer, base_dir);\n Ok(layer)\n}\n```\n\n- [ ] **Step 4: Run loader-level verification**\n\nAdd a test in `load.rs` under `#[cfg(test)]` if the file does not already have a test module:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n #[test]\n fn load_settings_path_auto_migrates_legacy_sandbox_file() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(\n &path,\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n )\n .expect(\"write legacy settings\");\n\n let layer = load_settings_path(&path).expect(\"legacy settings should auto-migrate\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&layer)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(std::fs::read_to_string(&path)\n .expect(\"read rewritten settings\")\n .contains(\"[run.environment]\"));\n }\n}\n```\n\nRun:\n\n```bash\ncargo test -p fabro-config load_settings_path_auto_migrates_legacy_sandbox_file --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 5: Verify in-memory TOML parsing remains strict**\n\nRun the existing current-main rejection test:\n\n```bash\ncargo test -p fabro-config legacy_run_sandbox_is_rejected --quiet\n```\n\nExpected: PASS. Do not weaken `SettingsLayer` deserialization to accept `run.sandbox`; only `load_settings_path` should rewrite files from disk.\n\n## Task 5: Unsupported and Ambiguous Cases\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add failure tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn existing_new_environment_config_is_ambiguous() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.environment]\nid = \"default\"\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"mixed old and new config should fail\");\n\n assert!(err.to_string().contains(\"already contains [run.environment]\"));\n}\n\n#[test]\nfn unsupported_keys_are_reported_with_full_paths() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\n[run.sandbox.daytona]\nunknown = true\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"unsupported keys should fail migration\");\n\n let rendered = err.to_string();\n assert!(rendered.contains(\"run.sandbox.daytona.unknown\"));\n assert!(rendered.contains(\"docs/public/execution/environments.mdx\"));\n}\n\n#[test]\nfn unsupported_docker_cpu_quota_is_reported() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\ncpu_quota = 250000\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"non-divisible cpu quota should fail migration\");\n\n assert!(err.to_string().contains(\"run.sandbox.docker.cpu_quota\"));\n}\n```\n\n- [ ] **Step 2: Run failure tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 6: Documentation\n\n**Files:**\n- Modify: `docs/public/execution/environments.mdx`\n- Create: `docs/public/changelog/2026-05-23.mdx`\n\n- [ ] **Step 1: Document temporary auto-migration**\n\nAdd this note near the top of `docs/public/execution/environments.mdx`, after the initial environment/sandbox distinction:\n\n```mdx\n<Warning>\nOlder pre-v1.0 config files that still use `[run.sandbox]` are temporarily auto-migrated when Fabro loads them from disk. Fabro writes a sibling `*.legacy-sandbox-migration.bak` file, rewrites the config to `[run.environment]` plus `[environments.default]`, and then continues startup.\n\nThis compatibility rewrite only handles direct field mappings. Unsupported legacy fields fail with a migration message that lists the keys to edit manually. The rewrite path will be removed before v1.0.\n</Warning>\n```\n\n- [ ] **Step 2: Add a changelog note**\n\nCreate `docs/public/changelog/2026-05-23.mdx`:\n\n```mdx\n---\ntitle: \"Legacy sandbox config migration\"\ndate: \"2026-05-23\"\n---\n\n## Legacy sandbox config auto-migration\n\nFabro now temporarily rewrites confidently migratable pre-v1.0 `[run.sandbox]` config files to the named environment syntax. A backup is written next to the original file before rewriting. Ambiguous or unsupported legacy keys fail with a targeted migration message instead of the generic TOML unknown-field error.\n```\n\n- [ ] **Step 3: Check docs references**\n\nRun:\n\n```bash\nrg -n \"\\\\[run\\\\.sandbox\\\\]|legacy-sandbox-migration|run\\\\.environment\" docs/public/execution docs/public/changelog\n```\n\nExpected: remaining `[run.sandbox]` references are either historical changelog entries or explicit migration warnings.\n\n## Task 7: Full Verification\n\n**Files:**\n- All files touched above.\n\n- [ ] **Step 1: Run config crate tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 2: Run formatting check**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 fmt --check --all\n```\n\nExpected: PASS.\n\n- [ ] **Step 3: Optional workspace lint if formatting and tests pass**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings\n```\n\nExpected: PASS. If this is slow, record that it was not run and include the reason in the handoff.\n\n## Acceptance Criteria\n\n- Boot-time config loading rewrites simple legacy `[run.sandbox]` files without user action.\n- The rewritten file uses `[run.environment] id = \"default\"` and `[environments.default]`.\n- The original file is preserved in a sibling backup before rewrite.\n- Unsupported legacy keys fail with a targeted migration message listing exact keys.\n- Normal strict schema behavior remains unchanged for in-memory `from_toml` calls.\n- All legacy migration code is isolated in `legacy_sandbox_migration.rs` and removable before v1.0.\n",
"internal.retry_count.toolchain": 0,
"internal.retry_count.preflight_compile": 0,
"internal.work_dir": "/home/daytona/workspace/fabro",
"thread.toolchain.current_node": "preflight_compile",
"thread.preflight_compile.current_node": "preflight_lint",
"current_node": "preflight_lint",
"failure_class": "",
"internal.fidelity": "compact",
"internal.retry_count.preflight_lint": 0
},
"node_outcomes": {
"preflight_lint": {
"status": "succeeded",
"context_updates": {
"command.output": "blob://sha256/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126"
},
"notes": "Script completed: cargo +nightly-2026-04-14 clippy -q --workspace --all-targets -- -D warnings 2>&1",
"usage": null
},
"preflight_compile": {
"status": "succeeded",
"context_updates": {
"command.output": "blob://sha256/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126"
},
"notes": "Script completed: cargo check -q --workspace 2>&1",
"usage": null
},
"toolchain": {
"status": "succeeded",
"context_updates": {
"command.output": "blob://sha256/fc14b2ba2d770e5cd3169df7a29525c962adfc4cfa3097b9098c63ebd61a748c"
},
"notes": "Script completed: command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1",
"usage": null
},
"start": {
"status": "succeeded",
"usage": null
}
},
"next_node_id": "implement",
"git_commit_sha": "d170dc33ad493567f947930b961f9310d1e59d3d",
"node_visits": {
"start": 1,
"preflight_compile": 1,
"preflight_lint": 1,
"toolchain": 1
}
},
"diff": {
"summary": {
"files_changed": 0,
"additions": 0,
"deletions": 0
}
}
},
{
"seq": 507,
"checkpoint": {
"timestamp": "2026-05-23T20:13:19.147537Z",
"current_node": "implement",
"completed_nodes": [
"start",
"toolchain",
"preflight_compile",
"preflight_lint",
"implement"
],
"node_retries": {},
"context_values": {
"graph.rankdir": "LR",
"internal.retry_count.preflight_lint": 0,
"current_node": "implement",
"internal.retry_count.start": 0,
"thread.preflight_lint.current_node": "implement",
"thread.toolchain.current_node": "preflight_compile",
"internal.work_dir": "/home/daytona/workspace/fabro",
"internal.retry_count.toolchain": 0,
"graph.model_stylesheet": "\n * { model: claude-opus-4-7; }\n ",
"internal.retry_count.implement": 0,
"internal.retry_count.preflight_compile": 0,
"response.implement": "Implemented the legacy `[run.sandbox]` auto-migration.\n\nSummary:\n- Added isolated `fabro-config` migration module:\n - Detects legacy `[run.sandbox]`\n - Rewrites to `[run.environment] id = \"default\"` plus `[environments.default]`\n - Supports Daytona/Docker field mappings, `preserve`, `env`, `skip_clone = true`, labels, snapshots, volumes, Docker image/memory/cpu quota\n - Writes numbered sibling backups\n - Reports unsupported/ambiguous keys with full paths\n- Hooked migration only into file loading via `load_settings_path`; in-memory parsing remains strict.\n- Added migration tests, loader test, backup tests, failure diagnostics tests, and `skip_clone` coverage.\n- Added docs warning and new changelog entry.\n- Added a small existing test isolation fix in `fabro-config/src/user.rs` to prevent `FABRO_HOME` races during full crate tests.\n\nVerification run:\n- `cargo test -p fabro-config --quiet` ✅\n- `cargo +nightly-2026-04-14 fmt --check --all` ✅\n- `cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings` ✅\n- `cargo test -p fabro-config legacy_run_sandbox_is_rejected --quiet` ✅\n- Loader migration focused test ✅\n\nDocs reference check:\n- Requested `rg ...` command could not run because `rg` is not installed in the environment.\n- Used an equivalent `grep -R -n -E ...` check instead; remaining `[run.sandbox]` references are migration/removal notes or historical changelog entries.",
"failure_signature": "",
"internal.run_id": "01KSB6HFNMJ802AXGBAV5JP7ZS",
"failure_class": "",
"command.output": "blob://sha256/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126",
"internal.thread_id": "preflight_lint",
"last_response": "Implemented the legacy `[run.sandbox]` auto-migration.\n\nSummary:\n- Added isolated `fabro-config` migration module:\n - Detects legacy `[run.sandbox]`\n - Rewrites to `[run.environment] id = \"default\"`",
"last_stage": "implement",
"outcome": "succeeded",
"thread.preflight_compile.current_node": "preflight_lint",
"thread.start.current_node": "toolchain",
"graph.goal": "# Legacy Sandbox Config Auto-Migration Implementation Plan\n\n> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.\n\n**Goal:** Automatically rewrite confidently migratable legacy `[run.sandbox]` config files to the named-environments syntax during startup.\n\n**Architecture:** Keep legacy behavior isolated in a removable `fabro-config` module. The normal settings schema stays strict; only file-based loads get a temporary parse-failure recovery path that rewrites the file, writes a backup, warns, and then resumes normal parsing.\n\n**Tech Stack:** Rust, `toml_edit`, existing `fabro-config` settings builders, `tracing`, `tempfile` tests, public docs under `docs/public`.\n\n---\n\n## File Structure\n\n- Create `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n - Owns detection, TOML rewriting, backup naming/writing, unsupported-key diagnostics, and tests for legacy mappings.\n- Modify `lib/crates/fabro-config/src/lib.rs`\n - Register the module privately.\n- Modify `lib/crates/fabro-config/Cargo.toml`\n - Add the existing workspace `toml_edit` dependency; current main does not depend on it from `fabro-config`.\n- Modify `lib/crates/fabro-config/src/load.rs`\n - Add a small parse-failure hook that delegates to the migration module, then returns to normal parsing.\n- Modify docs:\n - `docs/public/execution/environments.mdx`\n - Create `docs/public/changelog/2026-05-23.mdx` because current main's latest public changelog is `2026-05-22.mdx`.\n\n## Migration Contract\n\nOnly migrate when all of these are true:\n\n- The file is valid TOML as a document.\n- `[run.sandbox]` exists.\n- `[run.environment]` does not exist.\n- `[environments.default]` does not exist.\n- Every legacy sandbox key is in the supported mapping below.\n- The migrated content parses successfully as `SettingsLayer`.\n\nThis is intentionally a file-load migration only. Current in-memory parsing behavior, including `legacy_run_sandbox_is_rejected` in `lib/crates/fabro-config/src/tests/resolve_run.rs`, should remain strict and unchanged.\n\nSupported mappings:\n\n| Legacy key | New key |\n|---|---|\n| `run.sandbox.provider` | `run.environment.id = \"default\"` and `environments.default.provider` |\n| `run.sandbox.preserve` | `environments.default.lifecycle.preserve` |\n| `run.sandbox.env` | `environments.default.env` |\n| `run.sandbox.daytona.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.docker.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.daytona.auto_stop_interval = N` | `environments.default.lifecycle.auto_stop = \"{N}m\"` |\n| `run.sandbox.daytona.labels` | `environments.default.labels` |\n| `run.sandbox.daytona.snapshot.name` | `environments.default.image.ref` |\n| `run.sandbox.daytona.snapshot.cpu` | `environments.default.resources.cpu` |\n| `run.sandbox.daytona.snapshot.memory` | `environments.default.resources.memory` |\n| `run.sandbox.daytona.snapshot.disk` | `environments.default.resources.disk` |\n| `run.sandbox.daytona.snapshot.dockerfile` | `environments.default.image.dockerfile` |\n| `run.sandbox.daytona.volumes[].volume_id` | `environments.default.volumes[].id` |\n| `run.sandbox.daytona.volumes[].mount_path` | `environments.default.volumes[].mount_path` |\n| `run.sandbox.daytona.volumes[].subpath` | `environments.default.volumes[].subpath` |\n| `run.sandbox.docker.image` | `environments.default.image.ref` |\n| `run.sandbox.docker.memory_limit` | `environments.default.resources.memory` |\n| `run.sandbox.docker.cpu_quota` | `environments.default.resources.cpu` when divisible by `100000` |\n\nUnsupported or ambiguous cases fail with a message shaped like:\n\n```text\nLegacy [run.sandbox] settings in <path> could not be auto-migrated.\n\nUnsupported keys:\n - run.sandbox.daytona.foo\n - run.sandbox.docker.cpu_quota\n\nRename legacy sandbox configuration to [run.environment] and [environments.<slug>].\nSee docs/public/execution/environments.mdx.\n```\n\nSuccessful migration writes a backup next to the original file:\n\n```text\nsettings.toml.legacy-sandbox-migration.bak\nsettings.toml.legacy-sandbox-migration.1.bak\nsettings.toml.legacy-sandbox-migration.2.bak\n```\n\nSuccessful migration emits:\n\n```text\nMigrated legacy [run.sandbox] settings in <path> to [run.environment] and [environments.default]. Backup written to <backup>. This temporary compatibility migration will be removed before v1.0.\n```\n\n## Task 1: Add the Migration Module Skeleton\n\n**Files:**\n- Create: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n- Modify: `lib/crates/fabro-config/src/lib.rs`\n- Modify: `lib/crates/fabro-config/Cargo.toml`\n\n- [ ] **Step 1: Add the `toml_edit` dependency**\n\nAdd this to `[dependencies]` in `lib/crates/fabro-config/Cargo.toml`:\n\n```toml\ntoml_edit.workspace = true\n```\n\n- [ ] **Step 2: Register the module privately**\n\nAdd this beside the other private modules in `lib/crates/fabro-config/src/lib.rs`:\n\n```rust\nmod legacy_sandbox_migration;\n```\n\n- [ ] **Step 3: Create the module API**\n\nCreate `lib/crates/fabro-config/src/legacy_sandbox_migration.rs` with this starting shape:\n\n```rust\n#![expect(\n clippy::disallowed_methods,\n reason = \"temporary startup config migration uses synchronous file I/O before config is loaded\"\n)]\n\nuse std::fmt;\nuse std::path::{Path, PathBuf};\n\nuse toml_edit::{DocumentMut, Item, Table, Value};\n\nuse crate::{Error, Result, SettingsLayer};\n\npub(crate) const REMOVAL_NOTE: &str =\n \"This temporary compatibility migration will be removed before v1.0.\";\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub(crate) struct LegacySandboxMigrationReport {\n pub(crate) contents: String,\n pub(crate) backup_path: PathBuf,\n pub(crate) warning: String,\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\nstruct MigrationFailure {\n unsupported_keys: Vec<String>,\n}\n\nimpl fmt::Display for MigrationFailure {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n writeln!(f, \"Legacy [run.sandbox] settings could not be auto-migrated.\")?;\n writeln!(f)?;\n writeln!(f, \"Unsupported keys:\")?;\n for key in &self.unsupported_keys {\n writeln!(f, \" - {key}\")?;\n }\n writeln!(f)?;\n write!(\n f,\n \"Rename legacy sandbox configuration to [run.environment] and [environments.<slug>]. See docs/public/execution/environments.mdx.\"\n )\n }\n}\n\npub(crate) fn migrate_settings_path(\n path: &Path,\n original_contents: &str,\n) -> Result<Option<LegacySandboxMigrationReport>> {\n let Some(next_contents) = migrate_contents(original_contents, path)? else {\n return Ok(None);\n };\n\n next_contents\n .parse::<SettingsLayer>()\n .map_err(|err| Error::parse_file(\"Migrated settings file is invalid\", path, err))?;\n\n let backup_path = next_backup_path(path);\n std::fs::write(&backup_path, original_contents).map_err(|source| {\n Error::other(format!(\n \"writing legacy sandbox migration backup {}: {source}\",\n backup_path.display()\n ))\n })?;\n std::fs::write(path, &next_contents).map_err(|source| {\n Error::other(format!(\n \"writing migrated settings file {}: {source}\",\n path.display()\n ))\n })?;\n\n let warning = format!(\n \"Migrated legacy [run.sandbox] settings in {} to [run.environment] and [environments.default]. Backup written to {}. {REMOVAL_NOTE}\",\n path.display(),\n backup_path.display()\n );\n\n Ok(Some(LegacySandboxMigrationReport {\n contents: next_contents,\n backup_path,\n warning,\n }))\n}\n\nfn migrate_contents(original_contents: &str, path: &Path) -> Result<Option<String>> {\n let mut doc = match original_contents.parse::<DocumentMut>() {\n Ok(doc) => doc,\n Err(_) => return Ok(None),\n };\n\n if !has_legacy_run_sandbox(&doc) {\n return Ok(None);\n }\n if has_new_environment_config(&doc) {\n return Err(Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated because the file already contains [run.environment] or [environments.default]. Remove one config style and retry.\",\n path.display()\n )));\n }\n\n migrate_document(&mut doc).map_err(|failure| {\n Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated.\\n\\n{}\",\n path.display(),\n failure\n ))\n })?;\n\n Ok(Some(doc.to_string()))\n}\n\nfn has_legacy_run_sandbox(doc: &DocumentMut) -> bool {\n doc.get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n .is_some()\n}\n\nfn has_new_environment_config(doc: &DocumentMut) -> bool {\n let has_run_environment = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"environment\"))\n .is_some();\n let has_default_environment = doc\n .get(\"environments\")\n .and_then(Item::as_table)\n .and_then(|envs| envs.get(\"default\"))\n .is_some();\n has_run_environment || has_default_environment\n}\n\nfn next_backup_path(path: &Path) -> PathBuf {\n let base = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !base.exists() {\n return base;\n }\n\n for index in 1.. {\n let candidate = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.{index}.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !candidate.exists() {\n return candidate;\n }\n }\n unreachable!(\"unbounded backup suffix search should return\")\n}\n```\n\n- [ ] **Step 4: Add placeholder-free private stubs that compile**\n\nAdd private helpers with `unimplemented!()` only inside tests disabled by `#[cfg(test)]` is not allowed. Instead, make `migrate_document` return the one known unsupported failure until Task 2 fills it:\n\n```rust\nfn migrate_document(_doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n })\n}\n```\n\n- [ ] **Step 5: Run the focused compile check**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: compiles; there may be zero tests in this module at this point.\n\n## Task 2: Implement Provider-Only Migration\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for provider-only migration**\n\nAdd these tests inside `legacy_sandbox_migration.rs`:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n fn migrate(source: &str) -> String {\n migrate_contents(source, Path::new(\"settings.toml\"))\n .expect(\"migration should not error\")\n .expect(\"legacy sandbox should migrate\")\n }\n\n #[test]\n fn provider_only_daytona_config_migrates_to_default_environment() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n );\n\n let settings = migrated\n .parse::<SettingsLayer>()\n .expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.id, \"default\");\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(migrated.contains(\"[run.environment]\"));\n assert!(migrated.contains(\"[environments.default]\"));\n assert!(!migrated.contains(\"[run.sandbox]\"));\n }\n\n #[test]\n fn non_legacy_config_is_not_migrated() {\n let migrated = migrate_contents(\"_version = 1\\n\", Path::new(\"settings.toml\"))\n .expect(\"non-legacy TOML should not error\");\n\n assert!(migrated.is_none());\n }\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config provider_only_daytona_config_migrates_to_default_environment --quiet\n```\n\nExpected: FAIL because `migrate_document` still returns unsupported `run.sandbox`.\n\n- [ ] **Step 3: Replace `migrate_document` with provider migration**\n\nImplement the initial migration:\n\n```rust\nfn migrate_document(doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n let Some(sandbox_item) = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n else {\n return Ok(());\n };\n let Some(sandbox) = sandbox_item.as_table().cloned() else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n });\n };\n\n let mut unsupported = Vec::new();\n for (key, _) in sandbox.iter() {\n if key != \"provider\" {\n unsupported.push(format!(\"run.sandbox.{key}\"));\n }\n }\n if !unsupported.is_empty() {\n return Err(MigrationFailure {\n unsupported_keys: unsupported,\n });\n }\n\n let Some(provider) = sandbox.get(\"provider\").and_then(Item::as_str) else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox.provider\".to_string()],\n });\n };\n\n set_value(path_table(doc, &[\"run\", \"environment\"]), \"id\", Value::from(\"default\"));\n set_value(\n path_table(doc, &[\"environments\", \"default\"]),\n \"provider\",\n Value::from(provider),\n );\n\n remove_run_sandbox(doc);\n Ok(())\n}\n\nfn path_table<'a>(doc: &'a mut DocumentMut, path: &[&str]) -> &'a mut Table {\n let mut item = doc.as_item_mut();\n for segment in path {\n item = &mut item[segment];\n if !item.is_table() {\n *item = Item::Table(Table::new());\n }\n }\n item.as_table_mut().expect(\"path item should be a table\")\n}\n\nfn set_value(table: &mut Table, key: &str, value: Value) {\n table[key] = Item::Value(value);\n}\n\nfn remove_run_sandbox(doc: &mut DocumentMut) {\n if let Some(run) = doc.get_mut(\"run\").and_then(Item::as_table_mut) {\n run.remove(\"sandbox\");\n }\n}\n```\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 3: Add Daytona and Docker Field Mappings\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for direct legacy field mappings**\n\nAdd tests that assert resolved behavior, not only string contents:\n\n```rust\n#[test]\nfn daytona_snapshot_labels_lifecycle_and_volumes_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\npreserve = true\n\n[run.sandbox.env]\nNODE_ENV = \"development\"\n\n[run.sandbox.daytona]\nauto_stop_interval = 30\n\n[run.sandbox.daytona.labels]\nrepo = \"fabro-sh/fabro\"\n\n[run.sandbox.daytona.snapshot]\nname = \"fabro-v11\"\ncpu = 8\nmemory = \"16GB\"\ndisk = \"20GB\"\ndockerfile = { path = \"Dockerfile\" }\n\n[[run.sandbox.daytona.volumes]]\nvolume_id = \"vol_auth\"\nmount_path = \"/home/daytona/.config\"\nsubpath = \"agents\"\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.image.reference.as_deref(), Some(\"fabro-v11\"));\n assert_eq!(resolved.resources.cpu, Some(8));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(16_000_000_000));\n assert_eq!(resolved.resources.disk.map(|size| size.as_bytes()), Some(20_000_000_000));\n assert!(resolved.lifecycle.preserve);\n assert_eq!(resolved.lifecycle.auto_stop.map(|duration| duration.as_std().as_secs()), Some(1800));\n assert_eq!(resolved.labels.get(\"repo\").map(String::as_str), Some(\"fabro-sh/fabro\"));\n assert_eq!(resolved.env.get(\"NODE_ENV\").map(|value| value.as_source()).as_deref(), Some(\"development\"));\n assert_eq!(resolved.volumes.len(), 1);\n assert_eq!(resolved.volumes[0].id, \"vol_auth\");\n assert_eq!(resolved.volumes[0].mount_path, \"/home/daytona/.config\");\n assert_eq!(resolved.volumes[0].subpath.as_deref(), Some(\"agents\"));\n}\n\n#[test]\nfn docker_image_memory_and_cpu_quota_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\nimage = \"buildpack-deps:noble\"\nmemory_limit = \"4GB\"\ncpu_quota = 200000\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.provider, EnvironmentProvider::Docker);\n assert_eq!(resolved.image.reference.as_deref(), Some(\"buildpack-deps:noble\"));\n assert_eq!(resolved.resources.cpu, Some(2));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(4_000_000_000));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: FAIL because the two new nested-mapping tests are not implemented yet.\n\n- [ ] **Step 3: Implement table copying and value transforms**\n\nExtend `migrate_document` so it:\n\n- Allows top-level legacy keys `provider`, `preserve`, `env`, `daytona`, and `docker`.\n- Copies `run.sandbox.env` into `environments.default.env`.\n- Sets `environments.default.lifecycle.preserve` from `run.sandbox.preserve`.\n- Handles provider-specific nested mappings only for the selected provider.\n- Removes `run.sandbox` after successful migration.\n\nUse helper functions with these signatures:\n\n```rust\nfn migrate_daytona(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn migrate_docker(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn copy_table(source: &Item, target: &mut Table);\nfn copy_array_of_tables_with_volume_id(source: &Item, target: &mut Table, unsupported: &mut Vec<String>);\nfn item_path_keys(prefix: &str, item: &Item, out: &mut Vec<String>);\n```\n\nImplementation rules:\n\n- `auto_stop_interval` must be an integer. Store `format!(\"{minutes}m\")`.\n- `docker.cpu_quota` must be an integer divisible by `100000`; otherwise add `run.sandbox.docker.cpu_quota` to unsupported keys.\n- For Daytona volumes, each array entry may contain only `volume_id`, `mount_path`, and `subpath`; rename `volume_id` to `id`.\n- `daytona.snapshot.dockerfile` must be copied as the existing TOML value, preserving inline string or `{ path = \"...\" }`.\n- When collecting unsupported nested keys, report full paths such as `run.sandbox.daytona.snapshot.foo`.\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 4: Add File Rewrite and Loader Hook\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/load.rs`\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add file rewrite tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn migrate_settings_path_writes_backup_and_rewrites_original() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n let original = r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#;\n std::fs::write(&path, original).expect(\"write fixture\");\n\n let report = migrate_settings_path(&path, original)\n .expect(\"migration should succeed\")\n .expect(\"legacy config should migrate\");\n\n let rewritten = std::fs::read_to_string(&path).expect(\"read rewritten settings\");\n let backup = std::fs::read_to_string(&report.backup_path).expect(\"read backup\");\n\n assert_eq!(backup, original);\n assert!(rewritten.contains(\"[run.environment]\"));\n assert!(rewritten.contains(\"[environments.default]\"));\n assert!(report.warning.contains(\"temporary compatibility migration\"));\n}\n\n#[test]\nfn existing_backup_uses_numbered_suffix() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(path.with_file_name(\"settings.toml.legacy-sandbox-migration.bak\"), \"old\")\n .expect(\"write existing backup\");\n\n let next = next_backup_path(&path);\n\n assert!(next.ends_with(\"settings.toml.legacy-sandbox-migration.1.bak\"));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm current state**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS if Task 1 file-writing code compiled; otherwise fix only the migration module.\n\n- [ ] **Step 3: Hook migration into file loading**\n\nChange `load_settings_path` in `lib/crates/fabro-config/src/load.rs` to this shape:\n\n```rust\npub(crate) fn load_settings_path(path: &Path) -> Result<SettingsLayer> {\n let content = std::fs::read_to_string(path).map_err(|source| Error::read_file(path, source))?;\n let mut layer = match content.parse::<SettingsLayer>() {\n Ok(layer) => layer,\n Err(err) => match crate::legacy_sandbox_migration::migrate_settings_path(path, &content)? {\n Some(report) => {\n tracing::warn!(\"{}\", report.warning);\n eprintln!(\"{}\", report.warning);\n report.contents.parse::<SettingsLayer>().map_err(|err| {\n Error::parse_file(\"Migrated settings file is invalid\", path, err)\n })?\n }\n None => return Err(Error::parse_file(\"Failed to parse settings file\", path, err)),\n },\n };\n let base_dir = path.parent().unwrap_or_else(|| Path::new(\".\"));\n resolve_goal_file_paths(&mut layer, base_dir);\n Ok(layer)\n}\n```\n\n- [ ] **Step 4: Run loader-level verification**\n\nAdd a test in `load.rs` under `#[cfg(test)]` if the file does not already have a test module:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n #[test]\n fn load_settings_path_auto_migrates_legacy_sandbox_file() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(\n &path,\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n )\n .expect(\"write legacy settings\");\n\n let layer = load_settings_path(&path).expect(\"legacy settings should auto-migrate\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&layer)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(std::fs::read_to_string(&path)\n .expect(\"read rewritten settings\")\n .contains(\"[run.environment]\"));\n }\n}\n```\n\nRun:\n\n```bash\ncargo test -p fabro-config load_settings_path_auto_migrates_legacy_sandbox_file --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 5: Verify in-memory TOML parsing remains strict**\n\nRun the existing current-main rejection test:\n\n```bash\ncargo test -p fabro-config legacy_run_sandbox_is_rejected --quiet\n```\n\nExpected: PASS. Do not weaken `SettingsLayer` deserialization to accept `run.sandbox`; only `load_settings_path` should rewrite files from disk.\n\n## Task 5: Unsupported and Ambiguous Cases\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add failure tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn existing_new_environment_config_is_ambiguous() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.environment]\nid = \"default\"\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"mixed old and new config should fail\");\n\n assert!(err.to_string().contains(\"already contains [run.environment]\"));\n}\n\n#[test]\nfn unsupported_keys_are_reported_with_full_paths() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\n[run.sandbox.daytona]\nunknown = true\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"unsupported keys should fail migration\");\n\n let rendered = err.to_string();\n assert!(rendered.contains(\"run.sandbox.daytona.unknown\"));\n assert!(rendered.contains(\"docs/public/execution/environments.mdx\"));\n}\n\n#[test]\nfn unsupported_docker_cpu_quota_is_reported() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\ncpu_quota = 250000\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"non-divisible cpu quota should fail migration\");\n\n assert!(err.to_string().contains(\"run.sandbox.docker.cpu_quota\"));\n}\n```\n\n- [ ] **Step 2: Run failure tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 6: Documentation\n\n**Files:**\n- Modify: `docs/public/execution/environments.mdx`\n- Create: `docs/public/changelog/2026-05-23.mdx`\n\n- [ ] **Step 1: Document temporary auto-migration**\n\nAdd this note near the top of `docs/public/execution/environments.mdx`, after the initial environment/sandbox distinction:\n\n```mdx\n<Warning>\nOlder pre-v1.0 config files that still use `[run.sandbox]` are temporarily auto-migrated when Fabro loads them from disk. Fabro writes a sibling `*.legacy-sandbox-migration.bak` file, rewrites the config to `[run.environment]` plus `[environments.default]`, and then continues startup.\n\nThis compatibility rewrite only handles direct field mappings. Unsupported legacy fields fail with a migration message that lists the keys to edit manually. The rewrite path will be removed before v1.0.\n</Warning>\n```\n\n- [ ] **Step 2: Add a changelog note**\n\nCreate `docs/public/changelog/2026-05-23.mdx`:\n\n```mdx\n---\ntitle: \"Legacy sandbox config migration\"\ndate: \"2026-05-23\"\n---\n\n## Legacy sandbox config auto-migration\n\nFabro now temporarily rewrites confidently migratable pre-v1.0 `[run.sandbox]` config files to the named environment syntax. A backup is written next to the original file before rewriting. Ambiguous or unsupported legacy keys fail with a targeted migration message instead of the generic TOML unknown-field error.\n```\n\n- [ ] **Step 3: Check docs references**\n\nRun:\n\n```bash\nrg -n \"\\\\[run\\\\.sandbox\\\\]|legacy-sandbox-migration|run\\\\.environment\" docs/public/execution docs/public/changelog\n```\n\nExpected: remaining `[run.sandbox]` references are either historical changelog entries or explicit migration warnings.\n\n## Task 7: Full Verification\n\n**Files:**\n- All files touched above.\n\n- [ ] **Step 1: Run config crate tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 2: Run formatting check**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 fmt --check --all\n```\n\nExpected: PASS.\n\n- [ ] **Step 3: Optional workspace lint if formatting and tests pass**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings\n```\n\nExpected: PASS. If this is slow, record that it was not run and include the reason in the handoff.\n\n## Acceptance Criteria\n\n- Boot-time config loading rewrites simple legacy `[run.sandbox]` files without user action.\n- The rewritten file uses `[run.environment] id = \"default\"` and `[environments.default]`.\n- The original file is preserved in a sibling backup before rewrite.\n- Unsupported legacy keys fail with a targeted migration message listing exact keys.\n- Normal strict schema behavior remains unchanged for in-memory `from_toml` calls.\n- All legacy migration code is isolated in `legacy_sandbox_migration.rs` and removable before v1.0.\n",
"internal.fidelity": "compact",
"internal.node_visit_count": 1
},
"node_outcomes": {
"start": {
"status": "succeeded",
"usage": null
},
"toolchain": {
"status": "succeeded",
"context_updates": {
"command.output": "blob://sha256/fc14b2ba2d770e5cd3169df7a29525c962adfc4cfa3097b9098c63ebd61a748c"
},
"notes": "Script completed: command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1",
"usage": null
},
"implement": {
"status": "succeeded",
"context_updates": {
"response.implement": "Implemented the legacy `[run.sandbox]` auto-migration.\n\nSummary:\n- Added isolated `fabro-config` migration module:\n - Detects legacy `[run.sandbox]`\n - Rewrites to `[run.environment] id = \"default\"` plus `[environments.default]`\n - Supports Daytona/Docker field mappings, `preserve`, `env`, `skip_clone = true`, labels, snapshots, volumes, Docker image/memory/cpu quota\n - Writes numbered sibling backups\n - Reports unsupported/ambiguous keys with full paths\n- Hooked migration only into file loading via `load_settings_path`; in-memory parsing remains strict.\n- Added migration tests, loader test, backup tests, failure diagnostics tests, and `skip_clone` coverage.\n- Added docs warning and new changelog entry.\n- Added a small existing test isolation fix in `fabro-config/src/user.rs` to prevent `FABRO_HOME` races during full crate tests.\n\nVerification run:\n- `cargo test -p fabro-config --quiet` ✅\n- `cargo +nightly-2026-04-14 fmt --check --all` ✅\n- `cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings` ✅\n- `cargo test -p fabro-config legacy_run_sandbox_is_rejected --quiet` ✅\n- Loader migration focused test ✅\n\nDocs reference check:\n- Requested `rg ...` command could not run because `rg` is not installed in the environment.\n- Used an equivalent `grep -R -n -E ...` check instead; remaining `[run.sandbox]` references are migration/removal notes or historical changelog entries.",
"last_stage": "implement",
"last_response": "Implemented the legacy `[run.sandbox]` auto-migration.\n\nSummary:\n- Added isolated `fabro-config` migration module:\n - Detects legacy `[run.sandbox]`\n - Rewrites to `[run.environment] id = \"default\"`"
},
"notes": "Stage completed: implement",
"usage": {
"input": {
"usage": {
"model": {
"provider": "openai",
"model_id": "gpt-5.5"
},
"tokens": {
"input_tokens": 148246,
"output_tokens": 18262,
"reasoning_tokens": 13644,
"cache_read_tokens": 8010240,
"cache_write_tokens": 0
}
},
"facts": {
"algorithm": "openai"
}
},
"total_usd_micros": 5703530
}
},
"preflight_lint": {
"status": "succeeded",
"context_updates": {
"command.output": "blob://sha256/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126"
},
"notes": "Script completed: cargo +nightly-2026-04-14 clippy -q --workspace --all-targets -- -D warnings 2>&1",
"usage": null
},
"preflight_compile": {
"status": "succeeded",
"context_updates": {
"command.output": "blob://sha256/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126"
},
"notes": "Script completed: cargo check -q --workspace 2>&1",
"usage": null
}
},
"next_node_id": "simplify_opus",
"git_commit_sha": "b8c87afb29aa1e477b14528e4e6dc49f5c8c1347",
"node_visits": {
"implement": 1,
"preflight_compile": 1,
"start": 1,
"preflight_lint": 1,
"toolchain": 1
}
},
"diff": {
"patch": "diff --git a/Cargo.lock b/Cargo.lock\nindex c50b6c665..bddde03c4 100644\n--- a/Cargo.lock\n+++ b/Cargo.lock\n@@ -1859,6 +1859,7 @@ dependencies = [\n \"tempfile\",\n \"thiserror 2.0.18\",\n \"toml 0.8.23\",\n+ \"toml_edit\",\n \"tracing\",\n \"tracing-subscriber\",\n \"ulid\",\ndiff --git a/docs/public/changelog/2026-05-23.mdx b/docs/public/changelog/2026-05-23.mdx\nnew file mode 100644\nindex 000000000..a5c1843ad\n--- /dev/null\n+++ b/docs/public/changelog/2026-05-23.mdx\n@@ -0,0 +1,8 @@\n+---\n+title: \"Legacy sandbox config migration\"\n+date: \"2026-05-23\"\n+---\n+\n+## Legacy sandbox config auto-migration\n+\n+Fabro now temporarily rewrites confidently migratable pre-v1.0 `[run.sandbox]` config files to the named environment syntax. A backup is written next to the original file before rewriting. Ambiguous or unsupported legacy keys fail with a targeted migration message instead of the generic TOML unknown-field error.\ndiff --git a/docs/public/execution/environments.mdx b/docs/public/execution/environments.mdx\nindex c75686e24..b45c4eb74 100644\n--- a/docs/public/execution/environments.mdx\n+++ b/docs/public/execution/environments.mdx\n@@ -8,6 +8,12 @@ Fabro separates **environments** from **sandboxes**:\n - An **environment** is reusable desired configuration: provider, image, resources, network, lifecycle, labels, volumes, and environment variables.\n - A **sandbox** is the concrete runtime instance Fabro creates for a run from the selected environment.\n \n+<Warning>\n+Older pre-v1.0 config files that still use `[run.sandbox]` are temporarily auto-migrated when Fabro loads them from disk. Fabro writes a sibling `*.legacy-sandbox-migration.bak` file, rewrites the config to `[run.environment]` plus `[environments.default]`, and then continues startup.\n+\n+This compatibility rewrite only handles direct field mappings. Unsupported legacy fields fail with a migration message that lists the keys to edit manually. The rewrite path will be removed before v1.0.\n+</Warning>\n+\n Runs select environments by slug:\n \n ```toml title=\"workflow.toml\"\ndiff --git a/lib/crates/fabro-config/Cargo.toml b/lib/crates/fabro-config/Cargo.toml\nindex 7e8290f6a..feb448314 100644\n--- a/lib/crates/fabro-config/Cargo.toml\n+++ b/lib/crates/fabro-config/Cargo.toml\n@@ -34,6 +34,7 @@ serde_json.workspace = true\n strsim = \"0.11\"\n tempfile = \"3\"\n toml.workspace = true\n+toml_edit.workspace = true\n tracing.workspace = true\n tracing-subscriber.workspace = true\n thiserror.workspace = true\ndiff --git a/lib/crates/fabro-config/src/legacy_sandbox_migration.rs b/lib/crates/fabro-config/src/legacy_sandbox_migration.rs\nnew file mode 100644\nindex 000000000..a8d428929\n--- /dev/null\n+++ b/lib/crates/fabro-config/src/legacy_sandbox_migration.rs\n@@ -0,0 +1,799 @@\n+#![expect(\n+ clippy::disallowed_methods,\n+ reason = \"temporary startup config migration uses synchronous file I/O before config is loaded\"\n+)]\n+\n+use std::fmt;\n+use std::path::{Path, PathBuf};\n+\n+use toml_edit::{ArrayOfTables, DocumentMut, Item, Table, Value};\n+\n+use crate::{Error, Result, SettingsLayer};\n+\n+pub(crate) const REMOVAL_NOTE: &str =\n+ \"This temporary compatibility migration will be removed before v1.0.\";\n+\n+#[derive(Debug, Clone, PartialEq, Eq)]\n+pub(crate) struct LegacySandboxMigrationReport {\n+ pub(crate) contents: String,\n+ pub(crate) backup_path: PathBuf,\n+ pub(crate) warning: String,\n+}\n+\n+#[derive(Debug, Clone, PartialEq, Eq)]\n+struct MigrationFailure {\n+ unsupported_keys: Vec<String>,\n+}\n+\n+impl fmt::Display for MigrationFailure {\n+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n+ writeln!(f, \"Unsupported keys:\")?;\n+ for key in &self.unsupported_keys {\n+ writeln!(f, \" - {key}\")?;\n+ }\n+ writeln!(f)?;\n+ write!(\n+ f,\n+ \"Rename legacy sandbox configuration to [run.environment] and [environments.<slug>]. See docs/public/execution/environments.mdx.\"\n+ )\n+ }\n+}\n+\n+pub(crate) fn migrate_settings_path(\n+ path: &Path,\n+ original_contents: &str,\n+) -> Result<Option<LegacySandboxMigrationReport>> {\n+ let Some(next_contents) = migrate_contents(original_contents, path)? else {\n+ return Ok(None);\n+ };\n+\n+ next_contents\n+ .parse::<SettingsLayer>()\n+ .map_err(|err| Error::parse_file(\"Migrated settings file is invalid\", path, err))?;\n+\n+ let backup_path = next_backup_path(path);\n+ std::fs::write(&backup_path, original_contents).map_err(|source| {\n+ Error::other(format!(\n+ \"writing legacy sandbox migration backup {}: {source}\",\n+ backup_path.display()\n+ ))\n+ })?;\n+ std::fs::write(path, &next_contents).map_err(|source| {\n+ Error::other(format!(\n+ \"writing migrated settings file {}: {source}\",\n+ path.display()\n+ ))\n+ })?;\n+\n+ let warning = format!(\n+ \"Migrated legacy [run.sandbox] settings in {} to [run.environment] and [environments.default]. Backup written to {}. {REMOVAL_NOTE}\",\n+ path.display(),\n+ backup_path.display()\n+ );\n+\n+ Ok(Some(LegacySandboxMigrationReport {\n+ contents: next_contents,\n+ backup_path,\n+ warning,\n+ }))\n+}\n+\n+fn migrate_contents(original_contents: &str, path: &Path) -> Result<Option<String>> {\n+ let Ok(mut doc) = original_contents.parse::<DocumentMut>() else {\n+ return Ok(None);\n+ };\n+\n+ if !has_legacy_run_sandbox(&doc) {\n+ return Ok(None);\n+ }\n+ if has_new_environment_config(&doc) {\n+ return Err(Error::other(format!(\n+ \"Legacy [run.sandbox] settings in {} could not be auto-migrated because the file already contains [run.environment] or [environments.default]. Remove one config style and retry.\",\n+ path.display()\n+ )));\n+ }\n+\n+ migrate_document(&mut doc).map_err(|failure| {\n+ Error::other(format!(\n+ \"Legacy [run.sandbox] settings in {} could not be auto-migrated.\\n\\n{}\",\n+ path.display(),\n+ failure\n+ ))\n+ })?;\n+\n+ Ok(Some(doc.to_string()))\n+}\n+\n+fn has_legacy_run_sandbox(doc: &DocumentMut) -> bool {\n+ doc.get(\"run\")\n+ .and_then(Item::as_table)\n+ .and_then(|run| run.get(\"sandbox\"))\n+ .is_some()\n+}\n+\n+fn has_new_environment_config(doc: &DocumentMut) -> bool {\n+ let has_run_environment = doc\n+ .get(\"run\")\n+ .and_then(Item::as_table)\n+ .and_then(|run| run.get(\"environment\"))\n+ .is_some();\n+ let has_default_environment = doc\n+ .get(\"environments\")\n+ .and_then(Item::as_table)\n+ .and_then(|envs| envs.get(\"default\"))\n+ .is_some();\n+ has_run_environment || has_default_environment\n+}\n+\n+fn migrate_document(doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n+ let Some(sandbox_item) = doc\n+ .get(\"run\")\n+ .and_then(Item::as_table)\n+ .and_then(|run| run.get(\"sandbox\"))\n+ else {\n+ return Ok(());\n+ };\n+ let Some(sandbox) = sandbox_item.as_table().cloned() else {\n+ return Err(MigrationFailure {\n+ unsupported_keys: vec![\"run.sandbox\".to_string()],\n+ });\n+ };\n+\n+ let mut unsupported = Vec::new();\n+ for (key, item) in &sandbox {\n+ if !matches!(key, \"provider\" | \"preserve\" | \"env\" | \"daytona\" | \"docker\") {\n+ item_path_keys(&format!(\"run.sandbox.{key}\"), item, &mut unsupported);\n+ }\n+ }\n+\n+ let provider = sandbox.get(\"provider\").and_then(Item::as_str);\n+ let provider_key = provider.unwrap_or_default().to_ascii_lowercase();\n+ if provider.is_none() {\n+ unsupported.push(\"run.sandbox.provider\".to_string());\n+ }\n+\n+ match provider_key.as_str() {\n+ \"daytona\" => {\n+ migrate_skip_clone(doc, &sandbox, \"daytona\");\n+ reject_provider_table(&sandbox, \"docker\", &mut unsupported);\n+ }\n+ \"docker\" => {\n+ migrate_skip_clone(doc, &sandbox, \"docker\");\n+ reject_provider_table(&sandbox, \"daytona\", &mut unsupported);\n+ }\n+ _ => {\n+ reject_provider_table(&sandbox, \"daytona\", &mut unsupported);\n+ reject_provider_table(&sandbox, \"docker\", &mut unsupported);\n+ }\n+ }\n+\n+ set_value(\n+ path_table(doc, &[\"run\", \"environment\"]),\n+ \"id\",\n+ Value::from(\"default\"),\n+ );\n+ if let Some(provider) = provider {\n+ set_value(\n+ path_table(doc, &[\"environments\", \"default\"]),\n+ \"provider\",\n+ Value::from(provider),\n+ );\n+ }\n+\n+ let env = path_table(doc, &[\"environments\", \"default\"]);\n+ if let Some(preserve) = sandbox.get(\"preserve\") {\n+ if preserve.as_bool().is_some() {\n+ set_item(\n+ path_table_in_table(env, &[\"lifecycle\"]),\n+ \"preserve\",\n+ preserve.clone(),\n+ );\n+ } else {\n+ unsupported.push(\"run.sandbox.preserve\".to_string());\n+ }\n+ }\n+ if let Some(env_item) = sandbox.get(\"env\") {\n+ if is_table_like(env_item) {\n+ copy_table(env_item, path_table_in_table(env, &[\"env\"]));\n+ } else {\n+ unsupported.push(\"run.sandbox.env\".to_string());\n+ }\n+ }\n+\n+ match provider_key.as_str() {\n+ \"daytona\" => migrate_daytona(&sandbox, env, &mut unsupported),\n+ \"docker\" => migrate_docker(&sandbox, env, &mut unsupported),\n+ _ => {}\n+ }\n+\n+ if !unsupported.is_empty() {\n+ return Err(MigrationFailure {\n+ unsupported_keys: unsupported,\n+ });\n+ }\n+\n+ remove_run_sandbox(doc);\n+ Ok(())\n+}\n+\n+fn migrate_skip_clone(doc: &mut DocumentMut, sandbox: &Table, provider: &str) {\n+ let Some(provider_table) = sandbox.get(provider).and_then(Item::as_table) else {\n+ return;\n+ };\n+ if provider_table\n+ .get(\"skip_clone\")\n+ .and_then(Item::as_bool)\n+ .unwrap_or(false)\n+ {\n+ set_value(\n+ path_table(doc, &[\"run\", \"clone\"]),\n+ \"enabled\",\n+ Value::from(false),\n+ );\n+ }\n+}\n+\n+fn reject_provider_table(sandbox: &Table, provider: &str, unsupported: &mut Vec<String>) {\n+ if let Some(item) = sandbox.get(provider) {\n+ item_path_keys(&format!(\"run.sandbox.{provider}\"), item, unsupported);\n+ }\n+}\n+\n+fn migrate_daytona(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>) {\n+ let Some(daytona_item) = sandbox.get(\"daytona\") else {\n+ return;\n+ };\n+ let Some(daytona) = daytona_item.as_table() else {\n+ unsupported.push(\"run.sandbox.daytona\".to_string());\n+ return;\n+ };\n+\n+ for (key, item) in daytona {\n+ match key {\n+ \"skip_clone\" => {\n+ if item.as_bool() != Some(true) {\n+ unsupported.push(\"run.sandbox.daytona.skip_clone\".to_string());\n+ }\n+ }\n+ \"auto_stop_interval\" => {\n+ if let Some(minutes) = item.as_integer().filter(|minutes| *minutes >= 0) {\n+ set_value(\n+ path_table_in_table(env, &[\"lifecycle\"]),\n+ \"auto_stop\",\n+ Value::from(format!(\"{minutes}m\")),\n+ );\n+ } else {\n+ unsupported.push(\"run.sandbox.daytona.auto_stop_interval\".to_string());\n+ }\n+ }\n+ \"labels\" => {\n+ if is_table_like(item) {\n+ copy_table(item, path_table_in_table(env, &[\"labels\"]));\n+ } else {\n+ unsupported.push(\"run.sandbox.daytona.labels\".to_string());\n+ }\n+ }\n+ \"snapshot\" => migrate_daytona_snapshot(item, env, unsupported),\n+ \"volumes\" => copy_array_of_tables_with_volume_id(item, env, unsupported),\n+ _ => item_path_keys(&format!(\"run.sandbox.daytona.{key}\"), item, unsupported),\n+ }\n+ }\n+}\n+\n+fn migrate_daytona_snapshot(snapshot_item: &Item, env: &mut Table, unsupported: &mut Vec<String>) {\n+ let Some(snapshot) = snapshot_item.as_table() else {\n+ unsupported.push(\"run.sandbox.daytona.snapshot\".to_string());\n+ return;\n+ };\n+\n+ for (key, item) in snapshot {\n+ match key {\n+ \"name\" => set_item(path_table_in_table(env, &[\"image\"]), \"ref\", item.clone()),\n+ \"cpu\" => set_item(\n+ path_table_in_table(env, &[\"resources\"]),\n+ \"cpu\",\n+ item.clone(),\n+ ),\n+ \"memory\" => set_item(\n+ path_table_in_table(env, &[\"resources\"]),\n+ \"memory\",\n+ item.clone(),\n+ ),\n+ \"disk\" => set_item(\n+ path_table_in_table(env, &[\"resources\"]),\n+ \"disk\",\n+ item.clone(),\n+ ),\n+ \"dockerfile\" => set_item(\n+ path_table_in_table(env, &[\"image\"]),\n+ \"dockerfile\",\n+ item.clone(),\n+ ),\n+ _ => item_path_keys(\n+ &format!(\"run.sandbox.daytona.snapshot.{key}\"),\n+ item,\n+ unsupported,\n+ ),\n+ }\n+ }\n+}\n+\n+fn migrate_docker(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>) {\n+ let Some(docker_item) = sandbox.get(\"docker\") else {\n+ return;\n+ };\n+ let Some(docker) = docker_item.as_table() else {\n+ unsupported.push(\"run.sandbox.docker\".to_string());\n+ return;\n+ };\n+\n+ for (key, item) in docker {\n+ match key {\n+ \"skip_clone\" => {\n+ if item.as_bool() != Some(true) {\n+ unsupported.push(\"run.sandbox.docker.skip_clone\".to_string());\n+ }\n+ }\n+ \"image\" => set_item(path_table_in_table(env, &[\"image\"]), \"ref\", item.clone()),\n+ \"memory_limit\" => set_item(\n+ path_table_in_table(env, &[\"resources\"]),\n+ \"memory\",\n+ item.clone(),\n+ ),\n+ \"cpu_quota\" => {\n+ if let Some(cpu_quota) = item.as_integer() {\n+ let cpu_count = cpu_quota / 100_000;\n+ if cpu_quota > 0 && cpu_quota % 100_000 == 0 && i32::try_from(cpu_count).is_ok()\n+ {\n+ set_value(\n+ path_table_in_table(env, &[\"resources\"]),\n+ \"cpu\",\n+ Value::from(cpu_count),\n+ );\n+ } else {\n+ unsupported.push(\"run.sandbox.docker.cpu_quota\".to_string());\n+ }\n+ } else {\n+ unsupported.push(\"run.sandbox.docker.cpu_quota\".to_string());\n+ }\n+ }\n+ _ => item_path_keys(&format!(\"run.sandbox.docker.{key}\"), item, unsupported),\n+ }\n+ }\n+}\n+\n+fn path_table<'a>(doc: &'a mut DocumentMut, path: &[&str]) -> &'a mut Table {\n+ let mut item = doc.as_item_mut();\n+ for segment in path {\n+ item = &mut item[segment];\n+ if !item.is_table() {\n+ *item = Item::Table(Table::new());\n+ }\n+ }\n+ item.as_table_mut().expect(\"path item should be a table\")\n+}\n+\n+fn path_table_in_table<'a>(table: &'a mut Table, path: &[&str]) -> &'a mut Table {\n+ let mut table = table;\n+ for segment in path {\n+ let item = &mut table[segment];\n+ if !item.is_table() {\n+ *item = Item::Table(Table::new());\n+ }\n+ table = item.as_table_mut().expect(\"path item should be a table\");\n+ }\n+ table\n+}\n+\n+fn set_value(table: &mut Table, key: &str, value: Value) {\n+ table[key] = Item::Value(value);\n+}\n+\n+fn set_item(table: &mut Table, key: &str, item: Item) {\n+ table[key] = item;\n+}\n+\n+fn is_table_like(item: &Item) -> bool {\n+ item.is_table() || item.as_value().and_then(Value::as_inline_table).is_some()\n+}\n+\n+fn copy_table(source: &Item, target: &mut Table) {\n+ if let Some(table) = source.as_table() {\n+ for (key, item) in table {\n+ target[key] = item.clone();\n+ }\n+ return;\n+ }\n+\n+ if let Some(inline_table) = source.as_value().and_then(Value::as_inline_table) {\n+ for (key, value) in inline_table {\n+ target[key] = Item::Value(value.clone());\n+ }\n+ }\n+}\n+\n+fn copy_array_of_tables_with_volume_id(\n+ source: &Item,\n+ target: &mut Table,\n+ unsupported: &mut Vec<String>,\n+) {\n+ let Some(volumes) = source.as_array_of_tables() else {\n+ unsupported.push(\"run.sandbox.daytona.volumes\".to_string());\n+ return;\n+ };\n+\n+ let mut migrated = ArrayOfTables::new();\n+ for volume in volumes {\n+ let mut migrated_volume = Table::new();\n+ let mut has_id = false;\n+ let mut has_mount_path = false;\n+ for (key, item) in volume {\n+ match key {\n+ \"volume_id\" => {\n+ has_id = true;\n+ set_item(&mut migrated_volume, \"id\", item.clone());\n+ }\n+ \"mount_path\" => {\n+ has_mount_path = true;\n+ set_item(&mut migrated_volume, \"mount_path\", item.clone());\n+ }\n+ \"subpath\" => set_item(&mut migrated_volume, \"subpath\", item.clone()),\n+ _ => item_path_keys(\n+ &format!(\"run.sandbox.daytona.volumes.{key}\"),\n+ item,\n+ unsupported,\n+ ),\n+ }\n+ }\n+ if !has_id {\n+ unsupported.push(\"run.sandbox.daytona.volumes.volume_id\".to_string());\n+ }\n+ if !has_mount_path {\n+ unsupported.push(\"run.sandbox.daytona.volumes.mount_path\".to_string());\n+ }\n+ migrated.push(migrated_volume);\n+ }\n+ target[\"volumes\"] = Item::ArrayOfTables(migrated);\n+}\n+\n+fn item_path_keys(prefix: &str, item: &Item, out: &mut Vec<String>) {\n+ if let Some(table) = item.as_table() {\n+ if table.is_empty() {\n+ out.push(prefix.to_string());\n+ }\n+ for (key, child) in table {\n+ item_path_keys(&format!(\"{prefix}.{key}\"), child, out);\n+ }\n+ return;\n+ }\n+\n+ if let Some(array) = item.as_array_of_tables() {\n+ if array.is_empty() {\n+ out.push(prefix.to_string());\n+ }\n+ for table in array {\n+ if table.is_empty() {\n+ out.push(prefix.to_string());\n+ }\n+ for (key, child) in table {\n+ item_path_keys(&format!(\"{prefix}.{key}\"), child, out);\n+ }\n+ }\n+ return;\n+ }\n+\n+ out.push(prefix.to_string());\n+}\n+\n+fn remove_run_sandbox(doc: &mut DocumentMut) {\n+ if let Some(run) = doc.get_mut(\"run\").and_then(Item::as_table_mut) {\n+ run.remove(\"sandbox\");\n+ }\n+}\n+\n+fn next_backup_path(path: &Path) -> PathBuf {\n+ let base = path.with_file_name(format!(\n+ \"{}.legacy-sandbox-migration.bak\",\n+ path.file_name()\n+ .and_then(|name| name.to_str())\n+ .unwrap_or(\"settings.toml\")\n+ ));\n+ if !base.exists() {\n+ return base;\n+ }\n+\n+ for index in 1.. {\n+ let candidate = path.with_file_name(format!(\n+ \"{}.legacy-sandbox-migration.{index}.bak\",\n+ path.file_name()\n+ .and_then(|name| name.to_str())\n+ .unwrap_or(\"settings.toml\")\n+ ));\n+ if !candidate.exists() {\n+ return candidate;\n+ }\n+ }\n+ unreachable!(\"unbounded backup suffix search should return\")\n+}\n+\n+#[cfg(test)]\n+mod tests {\n+ use fabro_types::settings::InterpString;\n+ use fabro_types::settings::run::EnvironmentProvider;\n+\n+ use super::*;\n+\n+ fn migrate(source: &str) -> String {\n+ migrate_contents(source, Path::new(\"settings.toml\"))\n+ .expect(\"migration should not error\")\n+ .expect(\"legacy sandbox should migrate\")\n+ }\n+\n+ #[test]\n+ fn provider_only_daytona_config_migrates_to_default_environment() {\n+ let migrated = migrate(\n+ r#\"\n+_version = 1\n+\n+[run.sandbox]\n+provider = \"daytona\"\n+\"#,\n+ );\n+\n+ let settings = migrated\n+ .parse::<SettingsLayer>()\n+ .expect(\"migrated TOML should parse\");\n+ let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n+ .expect(\"migrated settings should resolve\")\n+ .run;\n+\n+ assert_eq!(resolved.environment.id, \"default\");\n+ assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n+ assert!(migrated.contains(\"[run.environment]\"));\n+ assert!(migrated.contains(\"[environments.default]\"));\n+ assert!(!migrated.contains(\"[run.sandbox]\"));\n+ }\n+\n+ #[test]\n+ fn non_legacy_config_is_not_migrated() {\n+ let migrated = migrate_contents(\"_version = 1\\n\", Path::new(\"settings.toml\"))\n+ .expect(\"non-legacy TOML should not error\");\n+\n+ assert!(migrated.is_none());\n+ }\n+\n+ #[test]\n+ fn daytona_snapshot_labels_lifecycle_and_volumes_migrate() {\n+ let migrated = migrate(\n+ r#\"\n+_version = 1\n+\n+[run.sandbox]\n+provider = \"daytona\"\n+preserve = true\n+\n+[run.sandbox.env]\n+NODE_ENV = \"development\"\n+\n+[run.sandbox.daytona]\n+auto_stop_interval = 30\n+\n+[run.sandbox.daytona.labels]\n+repo = \"fabro-sh/fabro\"\n+\n+[run.sandbox.daytona.snapshot]\n+name = \"fabro-v11\"\n+cpu = 8\n+memory = \"16GB\"\n+disk = \"20GB\"\n+dockerfile = { path = \"Dockerfile\" }\n+\n+[[run.sandbox.daytona.volumes]]\n+volume_id = \"vol_auth\"\n+mount_path = \"/home/daytona/.config\"\n+subpath = \"agents\"\n+\"#,\n+ );\n+\n+ let settings = migrated\n+ .parse::<SettingsLayer>()\n+ .expect(\"migrated TOML should parse\");\n+ let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n+ .expect(\"migrated settings should resolve\")\n+ .run\n+ .environment;\n+\n+ assert_eq!(resolved.image.reference.as_deref(), Some(\"fabro-v11\"));\n+ assert_eq!(resolved.resources.cpu, Some(8));\n+ assert_eq!(\n+ resolved.resources.memory.map(|size| size.as_bytes()),\n+ Some(16_000_000_000)\n+ );\n+ assert_eq!(\n+ resolved.resources.disk.map(|size| size.as_bytes()),\n+ Some(20_000_000_000)\n+ );\n+ assert!(resolved.lifecycle.preserve);\n+ assert_eq!(\n+ resolved\n+ .lifecycle\n+ .auto_stop\n+ .map(|duration| duration.as_std().as_secs()),\n+ Some(1800)\n+ );\n+ assert_eq!(\n+ resolved.labels.get(\"repo\").map(String::as_str),\n+ Some(\"fabro-sh/fabro\")\n+ );\n+ assert_eq!(\n+ resolved.env.get(\"NODE_ENV\").map(InterpString::as_source),\n+ Some(\"development\".to_string())\n+ );\n+ assert_eq!(resolved.volumes.len(), 1);\n+ assert_eq!(resolved.volumes[0].id, \"vol_auth\");\n+ assert_eq!(resolved.volumes[0].mount_path, \"/home/daytona/.config\");\n+ assert_eq!(resolved.volumes[0].subpath.as_deref(), Some(\"agents\"));\n+ }\n+\n+ #[test]\n+ fn docker_image_memory_and_cpu_quota_migrate() {\n+ let migrated = migrate(\n+ r#\"\n+_version = 1\n+\n+[run.sandbox]\n+provider = \"docker\"\n+\n+[run.sandbox.docker]\n+image = \"buildpack-deps:noble\"\n+memory_limit = \"4GB\"\n+cpu_quota = 200000\n+\"#,\n+ );\n+\n+ let settings = migrated\n+ .parse::<SettingsLayer>()\n+ .expect(\"migrated TOML should parse\");\n+ let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n+ .expect(\"migrated settings should resolve\")\n+ .run\n+ .environment;\n+\n+ assert_eq!(resolved.provider, EnvironmentProvider::Docker);\n+ assert_eq!(\n+ resolved.image.reference.as_deref(),\n+ Some(\"buildpack-deps:noble\")\n+ );\n+ assert_eq!(resolved.resources.cpu, Some(2));\n+ assert_eq!(\n+ resolved.resources.memory.map(|size| size.as_bytes()),\n+ Some(4_000_000_000)\n+ );\n+ }\n+\n+ #[test]\n+ fn provider_skip_clone_true_migrates_to_run_clone_disabled() {\n+ let migrated = migrate(\n+ r#\"\n+_version = 1\n+\n+[run.sandbox]\n+provider = \"docker\"\n+\n+[run.sandbox.docker]\n+skip_clone = true\n+\"#,\n+ );\n+\n+ let settings = migrated\n+ .parse::<SettingsLayer>()\n+ .expect(\"migrated TOML should parse\");\n+ let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n+ .expect(\"migrated settings should resolve\")\n+ .run;\n+\n+ assert!(!resolved.clone.enabled);\n+ }\n+\n+ #[test]\n+ fn migrate_settings_path_writes_backup_and_rewrites_original() {\n+ let dir = tempfile::tempdir().expect(\"temp dir\");\n+ let path = dir.path().join(\"settings.toml\");\n+ let original = r#\"\n+_version = 1\n+\n+[run.sandbox]\n+provider = \"daytona\"\n+\"#;\n+ std::fs::write(&path, original).expect(\"write fixture\");\n+\n+ let report = migrate_settings_path(&path, original)\n+ .expect(\"migration should succeed\")\n+ .expect(\"legacy config should migrate\");\n+\n+ let rewritten = std::fs::read_to_string(&path).expect(\"read rewritten settings\");\n+ let backup = std::fs::read_to_string(&report.backup_path).expect(\"read backup\");\n+\n+ assert_eq!(backup, original);\n+ assert!(rewritten.contains(\"[run.environment]\"));\n+ assert!(rewritten.contains(\"[environments.default]\"));\n+ assert!(report.warning.contains(\"temporary compatibility migration\"));\n+ }\n+\n+ #[test]\n+ fn existing_backup_uses_numbered_suffix() {\n+ let dir = tempfile::tempdir().expect(\"temp dir\");\n+ let path = dir.path().join(\"settings.toml\");\n+ std::fs::write(\n+ path.with_file_name(\"settings.toml.legacy-sandbox-migration.bak\"),\n+ \"old\",\n+ )\n+ .expect(\"write existing backup\");\n+\n+ let next = next_backup_path(&path);\n+\n+ assert!(next.ends_with(\"settings.toml.legacy-sandbox-migration.1.bak\"));\n+ }\n+\n+ #[test]\n+ fn existing_new_environment_config_is_ambiguous() {\n+ let err = migrate_contents(\n+ r#\"\n+_version = 1\n+\n+[run.environment]\n+id = \"default\"\n+\n+[run.sandbox]\n+provider = \"daytona\"\n+\"#,\n+ Path::new(\"settings.toml\"),\n+ )\n+ .expect_err(\"mixed old and new config should fail\");\n+\n+ assert!(\n+ err.to_string()\n+ .contains(\"already contains [run.environment]\")\n+ );\n+ }\n+\n+ #[test]\n+ fn unsupported_keys_are_reported_with_full_paths() {\n+ let err = migrate_contents(\n+ r#\"\n+_version = 1\n+\n+[run.sandbox]\n+provider = \"daytona\"\n+\n+[run.sandbox.daytona]\n+unknown = true\n+\"#,\n+ Path::new(\"settings.toml\"),\n+ )\n+ .expect_err(\"unsupported keys should fail migration\");\n+\n+ let rendered = err.to_string();\n+ assert!(rendered.contains(\"run.sandbox.daytona.unknown\"));\n+ assert!(rendered.contains(\"docs/public/execution/environments.mdx\"));\n+ }\n+\n+ #[test]\n+ fn unsupported_docker_cpu_quota_is_reported() {\n+ let err = migrate_contents(\n+ r#\"\n+_version = 1\n+\n+[run.sandbox]\n+provider = \"docker\"\n+\n+[run.sandbox.docker]\n+cpu_quota = 250000\n+\"#,\n+ Path::new(\"settings.toml\"),\n+ )\n+ .expect_err(\"non-divisible cpu quota should fail migration\");\n+\n+ assert!(err.to_string().contains(\"run.sandbox.docker.cpu_quota\"));\n+ }\n+}\ndiff --git a/lib/crates/fabro-config/src/lib.rs b/lib/crates/fabro-config/src/lib.rs\nindex e2b6fb3b8..7ae698007 100644\n--- a/lib/crates/fabro-config/src/lib.rs\n+++ b/lib/crates/fabro-config/src/lib.rs\n@@ -16,6 +16,7 @@ pub mod envfile;\n pub mod error;\n pub mod home;\n pub mod input_overrides;\n+mod legacy_sandbox_migration;\n mod load;\n pub mod logging;\n pub mod parse;\ndiff --git a/lib/crates/fabro-config/src/load.rs b/lib/crates/fabro-config/src/load.rs\nindex 5a2254603..94eba41fc 100644\n--- a/lib/crates/fabro-config/src/load.rs\n+++ b/lib/crates/fabro-config/src/load.rs\n@@ -7,13 +7,33 @@ use std::path::{Path, PathBuf};\n \n use fabro_types::settings::InterpString;\n \n-use crate::{Error, Result, RunGoalLayer, SettingsLayer};\n+use crate::{Error, Result, RunGoalLayer, SettingsLayer, legacy_sandbox_migration};\n \n+#[expect(\n+ clippy::print_stderr,\n+ reason = \"startup config auto-migration warning must be visible before caller logging is configured\"\n+)]\n pub(crate) fn load_settings_path(path: &Path) -> Result<SettingsLayer> {\n let content = std::fs::read_to_string(path).map_err(|source| Error::read_file(path, source))?;\n- let mut layer = content\n- .parse::<SettingsLayer>()\n- .map_err(|err| Error::parse_file(\"Failed to parse settings file\", path, err))?;\n+ let mut layer = match content.parse::<SettingsLayer>() {\n+ Ok(layer) => layer,\n+ Err(err) => match legacy_sandbox_migration::migrate_settings_path(path, &content)? {\n+ Some(report) => {\n+ tracing::warn!(\"{}\", report.warning);\n+ eprintln!(\"{}\", report.warning);\n+ report.contents.parse::<SettingsLayer>().map_err(|err| {\n+ Error::parse_file(\"Migrated settings file is invalid\", path, err)\n+ })?\n+ }\n+ None => {\n+ return Err(Error::parse_file(\n+ \"Failed to parse settings file\",\n+ path,\n+ err,\n+ ));\n+ }\n+ },\n+ };\n let base_dir = path.parent().unwrap_or_else(|| Path::new(\".\"));\n resolve_goal_file_paths(&mut layer, base_dir);\n Ok(layer)\n@@ -45,3 +65,38 @@ pub(crate) fn resolve_goal_file_path(path_str: &str, base_dir: &Path) -> PathBuf\n base_dir.join(path)\n }\n }\n+\n+#[cfg(test)]\n+mod tests {\n+ use fabro_types::settings::run::EnvironmentProvider;\n+\n+ use super::*;\n+\n+ #[test]\n+ fn load_settings_path_auto_migrates_legacy_sandbox_file() {\n+ let dir = tempfile::tempdir().expect(\"temp dir\");\n+ let path = dir.path().join(\"settings.toml\");\n+ std::fs::write(\n+ &path,\n+ r#\"\n+_version = 1\n+\n+[run.sandbox]\n+provider = \"daytona\"\n+\"#,\n+ )\n+ .expect(\"write legacy settings\");\n+\n+ let layer = load_settings_path(&path).expect(\"legacy settings should auto-migrate\");\n+ let resolved = crate::WorkflowSettingsBuilder::from_layer(&layer)\n+ .expect(\"migrated settings should resolve\")\n+ .run;\n+\n+ assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n+ assert!(\n+ std::fs::read_to_string(&path)\n+ .expect(\"read rewritten settings\")\n+ .contains(\"[run.environment]\")\n+ );\n+ }\n+}\ndiff --git a/lib/crates/fabro-config/src/user.rs b/lib/crates/fabro-config/src/user.rs\nindex 030a234b2..7554a3429 100644\n--- a/lib/crates/fabro-config/src/user.rs\n+++ b/lib/crates/fabro-config/src/user.rs\n@@ -72,6 +72,9 @@ fn load_v2_layer_from_path(path: &Path) -> Result<SettingsLayer> {\n \n #[cfg(test)]\n mod tests {\n+ use fabro_static::EnvVars;\n+ use temp_env::with_var;\n+\n use super::{\n SETTINGS_CONFIG_FILENAME, active_settings_path_with_lookup, default_settings_path,\n default_socket_path, default_storage_dir,\n@@ -79,14 +82,16 @@ mod tests {\n \n #[test]\n fn settings_paths_use_expected_filenames() {\n- let home = dirs::home_dir().unwrap();\n-\n- assert_eq!(\n- default_settings_path(),\n- home.join(\".fabro\").join(SETTINGS_CONFIG_FILENAME)\n- );\n- assert_eq!(default_storage_dir(), home.join(\".fabro/storage\"));\n- assert_eq!(default_socket_path(), home.join(\".fabro/fabro.sock\"));\n+ with_var(EnvVars::FABRO_HOME, None::<&str>, || {\n+ let home = dirs::home_dir().unwrap();\n+\n+ assert_eq!(\n+ default_settings_path(),\n+ home.join(\".fabro\").join(SETTINGS_CONFIG_FILENAME)\n+ );\n+ assert_eq!(default_storage_dir(), home.join(\".fabro/storage\"));\n+ assert_eq!(default_socket_path(), home.join(\".fabro/fabro.sock\"));\n+ });\n }\n \n #[test]\n",
"summary": {
"files_changed": 8,
"additions": 888,
"deletions": 12
}
}
},
{
"seq": 0,
"checkpoint": {
"timestamp": "2026-05-23T20:23:53.080105Z",
"current_node": "simplify_opus",
"completed_nodes": [
"start",
"toolchain",
"preflight_compile",
"preflight_lint",
"implement",
"simplify_opus"
],
"node_retries": {},
"context_values": {
"outcome": "succeeded",
"internal.work_dir": "/home/daytona/workspace/fabro",
"last_response": "Cut 60 lines off the migration module while fixing a real bug. Summary of fixes from the review:\n\n**Fixes applied:**\n1. **Correctness bug** (Agent 2 #1): `skip_clone = false` (the default) was wrongly",
"thread.start.current_node": "toolchain",
"internal.thread_id": "implement",
"response.simplify_opus": "Cut 60 lines off the migration module while fixing a real bug. Summary of fixes from the review:\n\n**Fixes applied:**\n1. **Correctness bug** (Agent 2 #1): `skip_clone = false` (the default) was wrongly rejected as unsupported. Now only non-bool values fail. Added test `explicit_skip_clone_false_is_accepted_as_default`.\n2. **Code reuse** (Agent 1 #1, #2): Removed custom `is_table_like` / `copy_table` branching; now uses toml_edit's built-in `Item::is_table_like()` and `Item::as_table_like()` + `TableLike` trait.\n3. **Duplicate helpers** (Agent 1 #3): Collapsed `path_table` and `path_table_in_table` into a single `ensure_table` that operates on `&mut Table`; callers use `doc.as_table_mut()`.\n4. **Stringly-typed** (Agent 2 #3): Replaced raw `\"daytona\"` / `\"docker\"` matching with `EnvironmentProvider::from_str` + `IntoStaticStr`; eliminated the awkward `migrate_skip_clone` + `reject_provider_table` mirror-dispatch.\n5. **Trivial wrappers** (Agent 1 #9, Agent 2 smaller): Dropped `set_value` and `set_item`; callers use `table[key] = …` directly.\n6. **Efficiency** (Agent 3 main finding): `migrate_settings_path` now returns the already-parsed `SettingsLayer` instead of returning a string for the caller to re-parse — eliminates a redundant serde pass on the migration path.\n7. **Double-report bug** (Agent 2 smaller): `item_path_keys` now stops after reporting an empty array-of-tables instead of re-pushing per element.\n8. **Dead-code cleanup** (Agent 1 #4): Trimmed `unwrap_or(\"settings.toml\")` dead fallback and computed `file_name` once before the loop in `next_backup_path`.\n9. **Dead-code warning**: Made `backup_path` a `#[cfg(test)]` field since it's only used in tests, avoiding a `dead_code` warning in non-test builds without sprinkling `#[allow]`.\n\n**Skipped (deliberate):**\n- Adding a dedicated `Error::WriteFile` variant and converting `MigrationFailure` into an Error variant (Agent 1 #5, #6) — out of scope for a soon-to-be-removed module.\n- Promoting `next_backup_path` to `fabro-util` (Agent 1 #4, #7) — this file is going away pre-v1.0.\n- `user.rs` test fix concerns (Agent 2 #5) — works correctly, leave alone.\n- Test fixture builder consolidation — legacy TOML shape is the point of the tests.\n\n**Verification:** `cargo nextest run -p fabro-config` (216 pass), `cargo +nightly-2026-04-14 fmt --check --all` (clean), `cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings` (clean).",
"internal.retry_count.preflight_compile": 0,
"internal.retry_count.preflight_lint": 0,
"failure_class": "",
"thread.toolchain.current_node": "preflight_compile",
"failure_signature": "",
"thread.implement.current_node": "simplify_opus",
"internal.retry_count.simplify_opus": 0,
"graph.model_stylesheet": "\n * { model: claude-opus-4-7; }\n ",
"internal.fidelity": "compact",
"thread.preflight_compile.current_node": "preflight_lint",
"internal.retry_count.implement": 0,
"graph.rankdir": "LR",
"internal.run_id": "01KSB6HFNMJ802AXGBAV5JP7ZS",
"last_stage": "simplify_opus",
"current_node": "simplify_opus",
"command.output": "blob://sha256/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126",
"graph.goal": "# Legacy Sandbox Config Auto-Migration Implementation Plan\n\n> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.\n\n**Goal:** Automatically rewrite confidently migratable legacy `[run.sandbox]` config files to the named-environments syntax during startup.\n\n**Architecture:** Keep legacy behavior isolated in a removable `fabro-config` module. The normal settings schema stays strict; only file-based loads get a temporary parse-failure recovery path that rewrites the file, writes a backup, warns, and then resumes normal parsing.\n\n**Tech Stack:** Rust, `toml_edit`, existing `fabro-config` settings builders, `tracing`, `tempfile` tests, public docs under `docs/public`.\n\n---\n\n## File Structure\n\n- Create `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n - Owns detection, TOML rewriting, backup naming/writing, unsupported-key diagnostics, and tests for legacy mappings.\n- Modify `lib/crates/fabro-config/src/lib.rs`\n - Register the module privately.\n- Modify `lib/crates/fabro-config/Cargo.toml`\n - Add the existing workspace `toml_edit` dependency; current main does not depend on it from `fabro-config`.\n- Modify `lib/crates/fabro-config/src/load.rs`\n - Add a small parse-failure hook that delegates to the migration module, then returns to normal parsing.\n- Modify docs:\n - `docs/public/execution/environments.mdx`\n - Create `docs/public/changelog/2026-05-23.mdx` because current main's latest public changelog is `2026-05-22.mdx`.\n\n## Migration Contract\n\nOnly migrate when all of these are true:\n\n- The file is valid TOML as a document.\n- `[run.sandbox]` exists.\n- `[run.environment]` does not exist.\n- `[environments.default]` does not exist.\n- Every legacy sandbox key is in the supported mapping below.\n- The migrated content parses successfully as `SettingsLayer`.\n\nThis is intentionally a file-load migration only. Current in-memory parsing behavior, including `legacy_run_sandbox_is_rejected` in `lib/crates/fabro-config/src/tests/resolve_run.rs`, should remain strict and unchanged.\n\nSupported mappings:\n\n| Legacy key | New key |\n|---|---|\n| `run.sandbox.provider` | `run.environment.id = \"default\"` and `environments.default.provider` |\n| `run.sandbox.preserve` | `environments.default.lifecycle.preserve` |\n| `run.sandbox.env` | `environments.default.env` |\n| `run.sandbox.daytona.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.docker.skip_clone = true` | `run.clone.enabled = false` |\n| `run.sandbox.daytona.auto_stop_interval = N` | `environments.default.lifecycle.auto_stop = \"{N}m\"` |\n| `run.sandbox.daytona.labels` | `environments.default.labels` |\n| `run.sandbox.daytona.snapshot.name` | `environments.default.image.ref` |\n| `run.sandbox.daytona.snapshot.cpu` | `environments.default.resources.cpu` |\n| `run.sandbox.daytona.snapshot.memory` | `environments.default.resources.memory` |\n| `run.sandbox.daytona.snapshot.disk` | `environments.default.resources.disk` |\n| `run.sandbox.daytona.snapshot.dockerfile` | `environments.default.image.dockerfile` |\n| `run.sandbox.daytona.volumes[].volume_id` | `environments.default.volumes[].id` |\n| `run.sandbox.daytona.volumes[].mount_path` | `environments.default.volumes[].mount_path` |\n| `run.sandbox.daytona.volumes[].subpath` | `environments.default.volumes[].subpath` |\n| `run.sandbox.docker.image` | `environments.default.image.ref` |\n| `run.sandbox.docker.memory_limit` | `environments.default.resources.memory` |\n| `run.sandbox.docker.cpu_quota` | `environments.default.resources.cpu` when divisible by `100000` |\n\nUnsupported or ambiguous cases fail with a message shaped like:\n\n```text\nLegacy [run.sandbox] settings in <path> could not be auto-migrated.\n\nUnsupported keys:\n - run.sandbox.daytona.foo\n - run.sandbox.docker.cpu_quota\n\nRename legacy sandbox configuration to [run.environment] and [environments.<slug>].\nSee docs/public/execution/environments.mdx.\n```\n\nSuccessful migration writes a backup next to the original file:\n\n```text\nsettings.toml.legacy-sandbox-migration.bak\nsettings.toml.legacy-sandbox-migration.1.bak\nsettings.toml.legacy-sandbox-migration.2.bak\n```\n\nSuccessful migration emits:\n\n```text\nMigrated legacy [run.sandbox] settings in <path> to [run.environment] and [environments.default]. Backup written to <backup>. This temporary compatibility migration will be removed before v1.0.\n```\n\n## Task 1: Add the Migration Module Skeleton\n\n**Files:**\n- Create: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n- Modify: `lib/crates/fabro-config/src/lib.rs`\n- Modify: `lib/crates/fabro-config/Cargo.toml`\n\n- [ ] **Step 1: Add the `toml_edit` dependency**\n\nAdd this to `[dependencies]` in `lib/crates/fabro-config/Cargo.toml`:\n\n```toml\ntoml_edit.workspace = true\n```\n\n- [ ] **Step 2: Register the module privately**\n\nAdd this beside the other private modules in `lib/crates/fabro-config/src/lib.rs`:\n\n```rust\nmod legacy_sandbox_migration;\n```\n\n- [ ] **Step 3: Create the module API**\n\nCreate `lib/crates/fabro-config/src/legacy_sandbox_migration.rs` with this starting shape:\n\n```rust\n#![expect(\n clippy::disallowed_methods,\n reason = \"temporary startup config migration uses synchronous file I/O before config is loaded\"\n)]\n\nuse std::fmt;\nuse std::path::{Path, PathBuf};\n\nuse toml_edit::{DocumentMut, Item, Table, Value};\n\nuse crate::{Error, Result, SettingsLayer};\n\npub(crate) const REMOVAL_NOTE: &str =\n \"This temporary compatibility migration will be removed before v1.0.\";\n\n#[derive(Debug, Clone, PartialEq, Eq)]\npub(crate) struct LegacySandboxMigrationReport {\n pub(crate) contents: String,\n pub(crate) backup_path: PathBuf,\n pub(crate) warning: String,\n}\n\n#[derive(Debug, Clone, PartialEq, Eq)]\nstruct MigrationFailure {\n unsupported_keys: Vec<String>,\n}\n\nimpl fmt::Display for MigrationFailure {\n fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {\n writeln!(f, \"Legacy [run.sandbox] settings could not be auto-migrated.\")?;\n writeln!(f)?;\n writeln!(f, \"Unsupported keys:\")?;\n for key in &self.unsupported_keys {\n writeln!(f, \" - {key}\")?;\n }\n writeln!(f)?;\n write!(\n f,\n \"Rename legacy sandbox configuration to [run.environment] and [environments.<slug>]. See docs/public/execution/environments.mdx.\"\n )\n }\n}\n\npub(crate) fn migrate_settings_path(\n path: &Path,\n original_contents: &str,\n) -> Result<Option<LegacySandboxMigrationReport>> {\n let Some(next_contents) = migrate_contents(original_contents, path)? else {\n return Ok(None);\n };\n\n next_contents\n .parse::<SettingsLayer>()\n .map_err(|err| Error::parse_file(\"Migrated settings file is invalid\", path, err))?;\n\n let backup_path = next_backup_path(path);\n std::fs::write(&backup_path, original_contents).map_err(|source| {\n Error::other(format!(\n \"writing legacy sandbox migration backup {}: {source}\",\n backup_path.display()\n ))\n })?;\n std::fs::write(path, &next_contents).map_err(|source| {\n Error::other(format!(\n \"writing migrated settings file {}: {source}\",\n path.display()\n ))\n })?;\n\n let warning = format!(\n \"Migrated legacy [run.sandbox] settings in {} to [run.environment] and [environments.default]. Backup written to {}. {REMOVAL_NOTE}\",\n path.display(),\n backup_path.display()\n );\n\n Ok(Some(LegacySandboxMigrationReport {\n contents: next_contents,\n backup_path,\n warning,\n }))\n}\n\nfn migrate_contents(original_contents: &str, path: &Path) -> Result<Option<String>> {\n let mut doc = match original_contents.parse::<DocumentMut>() {\n Ok(doc) => doc,\n Err(_) => return Ok(None),\n };\n\n if !has_legacy_run_sandbox(&doc) {\n return Ok(None);\n }\n if has_new_environment_config(&doc) {\n return Err(Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated because the file already contains [run.environment] or [environments.default]. Remove one config style and retry.\",\n path.display()\n )));\n }\n\n migrate_document(&mut doc).map_err(|failure| {\n Error::other(format!(\n \"Legacy [run.sandbox] settings in {} could not be auto-migrated.\\n\\n{}\",\n path.display(),\n failure\n ))\n })?;\n\n Ok(Some(doc.to_string()))\n}\n\nfn has_legacy_run_sandbox(doc: &DocumentMut) -> bool {\n doc.get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n .is_some()\n}\n\nfn has_new_environment_config(doc: &DocumentMut) -> bool {\n let has_run_environment = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"environment\"))\n .is_some();\n let has_default_environment = doc\n .get(\"environments\")\n .and_then(Item::as_table)\n .and_then(|envs| envs.get(\"default\"))\n .is_some();\n has_run_environment || has_default_environment\n}\n\nfn next_backup_path(path: &Path) -> PathBuf {\n let base = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !base.exists() {\n return base;\n }\n\n for index in 1.. {\n let candidate = path.with_file_name(format!(\n \"{}.legacy-sandbox-migration.{index}.bak\",\n path.file_name()\n .and_then(|name| name.to_str())\n .unwrap_or(\"settings.toml\")\n ));\n if !candidate.exists() {\n return candidate;\n }\n }\n unreachable!(\"unbounded backup suffix search should return\")\n}\n```\n\n- [ ] **Step 4: Add placeholder-free private stubs that compile**\n\nAdd private helpers with `unimplemented!()` only inside tests disabled by `#[cfg(test)]` is not allowed. Instead, make `migrate_document` return the one known unsupported failure until Task 2 fills it:\n\n```rust\nfn migrate_document(_doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n })\n}\n```\n\n- [ ] **Step 5: Run the focused compile check**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: compiles; there may be zero tests in this module at this point.\n\n## Task 2: Implement Provider-Only Migration\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for provider-only migration**\n\nAdd these tests inside `legacy_sandbox_migration.rs`:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n fn migrate(source: &str) -> String {\n migrate_contents(source, Path::new(\"settings.toml\"))\n .expect(\"migration should not error\")\n .expect(\"legacy sandbox should migrate\")\n }\n\n #[test]\n fn provider_only_daytona_config_migrates_to_default_environment() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n );\n\n let settings = migrated\n .parse::<SettingsLayer>()\n .expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.id, \"default\");\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(migrated.contains(\"[run.environment]\"));\n assert!(migrated.contains(\"[environments.default]\"));\n assert!(!migrated.contains(\"[run.sandbox]\"));\n }\n\n #[test]\n fn non_legacy_config_is_not_migrated() {\n let migrated = migrate_contents(\"_version = 1\\n\", Path::new(\"settings.toml\"))\n .expect(\"non-legacy TOML should not error\");\n\n assert!(migrated.is_none());\n }\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config provider_only_daytona_config_migrates_to_default_environment --quiet\n```\n\nExpected: FAIL because `migrate_document` still returns unsupported `run.sandbox`.\n\n- [ ] **Step 3: Replace `migrate_document` with provider migration**\n\nImplement the initial migration:\n\n```rust\nfn migrate_document(doc: &mut DocumentMut) -> std::result::Result<(), MigrationFailure> {\n let Some(sandbox_item) = doc\n .get(\"run\")\n .and_then(Item::as_table)\n .and_then(|run| run.get(\"sandbox\"))\n else {\n return Ok(());\n };\n let Some(sandbox) = sandbox_item.as_table().cloned() else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox\".to_string()],\n });\n };\n\n let mut unsupported = Vec::new();\n for (key, _) in sandbox.iter() {\n if key != \"provider\" {\n unsupported.push(format!(\"run.sandbox.{key}\"));\n }\n }\n if !unsupported.is_empty() {\n return Err(MigrationFailure {\n unsupported_keys: unsupported,\n });\n }\n\n let Some(provider) = sandbox.get(\"provider\").and_then(Item::as_str) else {\n return Err(MigrationFailure {\n unsupported_keys: vec![\"run.sandbox.provider\".to_string()],\n });\n };\n\n set_value(path_table(doc, &[\"run\", \"environment\"]), \"id\", Value::from(\"default\"));\n set_value(\n path_table(doc, &[\"environments\", \"default\"]),\n \"provider\",\n Value::from(provider),\n );\n\n remove_run_sandbox(doc);\n Ok(())\n}\n\nfn path_table<'a>(doc: &'a mut DocumentMut, path: &[&str]) -> &'a mut Table {\n let mut item = doc.as_item_mut();\n for segment in path {\n item = &mut item[segment];\n if !item.is_table() {\n *item = Item::Table(Table::new());\n }\n }\n item.as_table_mut().expect(\"path item should be a table\")\n}\n\nfn set_value(table: &mut Table, key: &str, value: Value) {\n table[key] = Item::Value(value);\n}\n\nfn remove_run_sandbox(doc: &mut DocumentMut) {\n if let Some(run) = doc.get_mut(\"run\").and_then(Item::as_table_mut) {\n run.remove(\"sandbox\");\n }\n}\n```\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 3: Add Daytona and Docker Field Mappings\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add tests for direct legacy field mappings**\n\nAdd tests that assert resolved behavior, not only string contents:\n\n```rust\n#[test]\nfn daytona_snapshot_labels_lifecycle_and_volumes_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\npreserve = true\n\n[run.sandbox.env]\nNODE_ENV = \"development\"\n\n[run.sandbox.daytona]\nauto_stop_interval = 30\n\n[run.sandbox.daytona.labels]\nrepo = \"fabro-sh/fabro\"\n\n[run.sandbox.daytona.snapshot]\nname = \"fabro-v11\"\ncpu = 8\nmemory = \"16GB\"\ndisk = \"20GB\"\ndockerfile = { path = \"Dockerfile\" }\n\n[[run.sandbox.daytona.volumes]]\nvolume_id = \"vol_auth\"\nmount_path = \"/home/daytona/.config\"\nsubpath = \"agents\"\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.image.reference.as_deref(), Some(\"fabro-v11\"));\n assert_eq!(resolved.resources.cpu, Some(8));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(16_000_000_000));\n assert_eq!(resolved.resources.disk.map(|size| size.as_bytes()), Some(20_000_000_000));\n assert!(resolved.lifecycle.preserve);\n assert_eq!(resolved.lifecycle.auto_stop.map(|duration| duration.as_std().as_secs()), Some(1800));\n assert_eq!(resolved.labels.get(\"repo\").map(String::as_str), Some(\"fabro-sh/fabro\"));\n assert_eq!(resolved.env.get(\"NODE_ENV\").map(|value| value.as_source()).as_deref(), Some(\"development\"));\n assert_eq!(resolved.volumes.len(), 1);\n assert_eq!(resolved.volumes[0].id, \"vol_auth\");\n assert_eq!(resolved.volumes[0].mount_path, \"/home/daytona/.config\");\n assert_eq!(resolved.volumes[0].subpath.as_deref(), Some(\"agents\"));\n}\n\n#[test]\nfn docker_image_memory_and_cpu_quota_migrate() {\n let migrated = migrate(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\nimage = \"buildpack-deps:noble\"\nmemory_limit = \"4GB\"\ncpu_quota = 200000\n\"#,\n );\n\n let settings = migrated.parse::<SettingsLayer>().expect(\"migrated TOML should parse\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&settings)\n .expect(\"migrated settings should resolve\")\n .run\n .environment;\n\n assert_eq!(resolved.provider, EnvironmentProvider::Docker);\n assert_eq!(resolved.image.reference.as_deref(), Some(\"buildpack-deps:noble\"));\n assert_eq!(resolved.resources.cpu, Some(2));\n assert_eq!(resolved.resources.memory.map(|size| size.as_bytes()), Some(4_000_000_000));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm failure**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: FAIL because the two new nested-mapping tests are not implemented yet.\n\n- [ ] **Step 3: Implement table copying and value transforms**\n\nExtend `migrate_document` so it:\n\n- Allows top-level legacy keys `provider`, `preserve`, `env`, `daytona`, and `docker`.\n- Copies `run.sandbox.env` into `environments.default.env`.\n- Sets `environments.default.lifecycle.preserve` from `run.sandbox.preserve`.\n- Handles provider-specific nested mappings only for the selected provider.\n- Removes `run.sandbox` after successful migration.\n\nUse helper functions with these signatures:\n\n```rust\nfn migrate_daytona(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn migrate_docker(sandbox: &Table, env: &mut Table, unsupported: &mut Vec<String>);\nfn copy_table(source: &Item, target: &mut Table);\nfn copy_array_of_tables_with_volume_id(source: &Item, target: &mut Table, unsupported: &mut Vec<String>);\nfn item_path_keys(prefix: &str, item: &Item, out: &mut Vec<String>);\n```\n\nImplementation rules:\n\n- `auto_stop_interval` must be an integer. Store `format!(\"{minutes}m\")`.\n- `docker.cpu_quota` must be an integer divisible by `100000`; otherwise add `run.sandbox.docker.cpu_quota` to unsupported keys.\n- For Daytona volumes, each array entry may contain only `volume_id`, `mount_path`, and `subpath`; rename `volume_id` to `id`.\n- `daytona.snapshot.dockerfile` must be copied as the existing TOML value, preserving inline string or `{ path = \"...\" }`.\n- When collecting unsupported nested keys, report full paths such as `run.sandbox.daytona.snapshot.foo`.\n\n- [ ] **Step 4: Run focused tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 4: Add File Rewrite and Loader Hook\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/load.rs`\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add file rewrite tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn migrate_settings_path_writes_backup_and_rewrites_original() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n let original = r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#;\n std::fs::write(&path, original).expect(\"write fixture\");\n\n let report = migrate_settings_path(&path, original)\n .expect(\"migration should succeed\")\n .expect(\"legacy config should migrate\");\n\n let rewritten = std::fs::read_to_string(&path).expect(\"read rewritten settings\");\n let backup = std::fs::read_to_string(&report.backup_path).expect(\"read backup\");\n\n assert_eq!(backup, original);\n assert!(rewritten.contains(\"[run.environment]\"));\n assert!(rewritten.contains(\"[environments.default]\"));\n assert!(report.warning.contains(\"temporary compatibility migration\"));\n}\n\n#[test]\nfn existing_backup_uses_numbered_suffix() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(path.with_file_name(\"settings.toml.legacy-sandbox-migration.bak\"), \"old\")\n .expect(\"write existing backup\");\n\n let next = next_backup_path(&path);\n\n assert!(next.ends_with(\"settings.toml.legacy-sandbox-migration.1.bak\"));\n}\n```\n\n- [ ] **Step 2: Run tests and confirm current state**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS if Task 1 file-writing code compiled; otherwise fix only the migration module.\n\n- [ ] **Step 3: Hook migration into file loading**\n\nChange `load_settings_path` in `lib/crates/fabro-config/src/load.rs` to this shape:\n\n```rust\npub(crate) fn load_settings_path(path: &Path) -> Result<SettingsLayer> {\n let content = std::fs::read_to_string(path).map_err(|source| Error::read_file(path, source))?;\n let mut layer = match content.parse::<SettingsLayer>() {\n Ok(layer) => layer,\n Err(err) => match crate::legacy_sandbox_migration::migrate_settings_path(path, &content)? {\n Some(report) => {\n tracing::warn!(\"{}\", report.warning);\n eprintln!(\"{}\", report.warning);\n report.contents.parse::<SettingsLayer>().map_err(|err| {\n Error::parse_file(\"Migrated settings file is invalid\", path, err)\n })?\n }\n None => return Err(Error::parse_file(\"Failed to parse settings file\", path, err)),\n },\n };\n let base_dir = path.parent().unwrap_or_else(|| Path::new(\".\"));\n resolve_goal_file_paths(&mut layer, base_dir);\n Ok(layer)\n}\n```\n\n- [ ] **Step 4: Run loader-level verification**\n\nAdd a test in `load.rs` under `#[cfg(test)]` if the file does not already have a test module:\n\n```rust\n#[cfg(test)]\nmod tests {\n use super::*;\n use fabro_types::settings::run::EnvironmentProvider;\n\n #[test]\n fn load_settings_path_auto_migrates_legacy_sandbox_file() {\n let dir = tempfile::tempdir().expect(\"temp dir\");\n let path = dir.path().join(\"settings.toml\");\n std::fs::write(\n &path,\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n )\n .expect(\"write legacy settings\");\n\n let layer = load_settings_path(&path).expect(\"legacy settings should auto-migrate\");\n let resolved = crate::WorkflowSettingsBuilder::from_layer(&layer)\n .expect(\"migrated settings should resolve\")\n .run;\n\n assert_eq!(resolved.environment.provider, EnvironmentProvider::Daytona);\n assert!(std::fs::read_to_string(&path)\n .expect(\"read rewritten settings\")\n .contains(\"[run.environment]\"));\n }\n}\n```\n\nRun:\n\n```bash\ncargo test -p fabro-config load_settings_path_auto_migrates_legacy_sandbox_file --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 5: Verify in-memory TOML parsing remains strict**\n\nRun the existing current-main rejection test:\n\n```bash\ncargo test -p fabro-config legacy_run_sandbox_is_rejected --quiet\n```\n\nExpected: PASS. Do not weaken `SettingsLayer` deserialization to accept `run.sandbox`; only `load_settings_path` should rewrite files from disk.\n\n## Task 5: Unsupported and Ambiguous Cases\n\n**Files:**\n- Modify: `lib/crates/fabro-config/src/legacy_sandbox_migration.rs`\n\n- [ ] **Step 1: Add failure tests**\n\nAdd tests:\n\n```rust\n#[test]\nfn existing_new_environment_config_is_ambiguous() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.environment]\nid = \"default\"\n\n[run.sandbox]\nprovider = \"daytona\"\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"mixed old and new config should fail\");\n\n assert!(err.to_string().contains(\"already contains [run.environment]\"));\n}\n\n#[test]\nfn unsupported_keys_are_reported_with_full_paths() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"daytona\"\n\n[run.sandbox.daytona]\nunknown = true\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"unsupported keys should fail migration\");\n\n let rendered = err.to_string();\n assert!(rendered.contains(\"run.sandbox.daytona.unknown\"));\n assert!(rendered.contains(\"docs/public/execution/environments.mdx\"));\n}\n\n#[test]\nfn unsupported_docker_cpu_quota_is_reported() {\n let err = migrate_contents(\n r#\"\n_version = 1\n\n[run.sandbox]\nprovider = \"docker\"\n\n[run.sandbox.docker]\ncpu_quota = 250000\n\"#,\n Path::new(\"settings.toml\"),\n )\n .expect_err(\"non-divisible cpu quota should fail migration\");\n\n assert!(err.to_string().contains(\"run.sandbox.docker.cpu_quota\"));\n}\n```\n\n- [ ] **Step 2: Run failure tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config legacy_sandbox_migration --quiet\n```\n\nExpected: PASS.\n\n## Task 6: Documentation\n\n**Files:**\n- Modify: `docs/public/execution/environments.mdx`\n- Create: `docs/public/changelog/2026-05-23.mdx`\n\n- [ ] **Step 1: Document temporary auto-migration**\n\nAdd this note near the top of `docs/public/execution/environments.mdx`, after the initial environment/sandbox distinction:\n\n```mdx\n<Warning>\nOlder pre-v1.0 config files that still use `[run.sandbox]` are temporarily auto-migrated when Fabro loads them from disk. Fabro writes a sibling `*.legacy-sandbox-migration.bak` file, rewrites the config to `[run.environment]` plus `[environments.default]`, and then continues startup.\n\nThis compatibility rewrite only handles direct field mappings. Unsupported legacy fields fail with a migration message that lists the keys to edit manually. The rewrite path will be removed before v1.0.\n</Warning>\n```\n\n- [ ] **Step 2: Add a changelog note**\n\nCreate `docs/public/changelog/2026-05-23.mdx`:\n\n```mdx\n---\ntitle: \"Legacy sandbox config migration\"\ndate: \"2026-05-23\"\n---\n\n## Legacy sandbox config auto-migration\n\nFabro now temporarily rewrites confidently migratable pre-v1.0 `[run.sandbox]` config files to the named environment syntax. A backup is written next to the original file before rewriting. Ambiguous or unsupported legacy keys fail with a targeted migration message instead of the generic TOML unknown-field error.\n```\n\n- [ ] **Step 3: Check docs references**\n\nRun:\n\n```bash\nrg -n \"\\\\[run\\\\.sandbox\\\\]|legacy-sandbox-migration|run\\\\.environment\" docs/public/execution docs/public/changelog\n```\n\nExpected: remaining `[run.sandbox]` references are either historical changelog entries or explicit migration warnings.\n\n## Task 7: Full Verification\n\n**Files:**\n- All files touched above.\n\n- [ ] **Step 1: Run config crate tests**\n\nRun:\n\n```bash\ncargo test -p fabro-config --quiet\n```\n\nExpected: PASS.\n\n- [ ] **Step 2: Run formatting check**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 fmt --check --all\n```\n\nExpected: PASS.\n\n- [ ] **Step 3: Optional workspace lint if formatting and tests pass**\n\nRun:\n\n```bash\ncargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings\n```\n\nExpected: PASS. If this is slow, record that it was not run and include the reason in the handoff.\n\n## Acceptance Criteria\n\n- Boot-time config loading rewrites simple legacy `[run.sandbox]` files without user action.\n- The rewritten file uses `[run.environment] id = \"default\"` and `[environments.default]`.\n- The original file is preserved in a sibling backup before rewrite.\n- Unsupported legacy keys fail with a targeted migration message listing exact keys.\n- Normal strict schema behavior remains unchanged for in-memory `from_toml` calls.\n- All legacy migration code is isolated in `legacy_sandbox_migration.rs` and removable before v1.0.\n",
"internal.node_visit_count": 1,
"internal.retry_count.start": 0,
"response.implement": "Implemented the legacy `[run.sandbox]` auto-migration.\n\nSummary:\n- Added isolated `fabro-config` migration module:\n - Detects legacy `[run.sandbox]`\n - Rewrites to `[run.environment] id = \"default\"` plus `[environments.default]`\n - Supports Daytona/Docker field mappings, `preserve`, `env`, `skip_clone = true`, labels, snapshots, volumes, Docker image/memory/cpu quota\n - Writes numbered sibling backups\n - Reports unsupported/ambiguous keys with full paths\n- Hooked migration only into file loading via `load_settings_path`; in-memory parsing remains strict.\n- Added migration tests, loader test, backup tests, failure diagnostics tests, and `skip_clone` coverage.\n- Added docs warning and new changelog entry.\n- Added a small existing test isolation fix in `fabro-config/src/user.rs` to prevent `FABRO_HOME` races during full crate tests.\n\nVerification run:\n- `cargo test -p fabro-config --quiet` ✅\n- `cargo +nightly-2026-04-14 fmt --check --all` ✅\n- `cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings` ✅\n- `cargo test -p fabro-config legacy_run_sandbox_is_rejected --quiet` ✅\n- Loader migration focused test ✅\n\nDocs reference check:\n- Requested `rg ...` command could not run because `rg` is not installed in the environment.\n- Used an equivalent `grep -R -n -E ...` check instead; remaining `[run.sandbox]` references are migration/removal notes or historical changelog entries.",
"internal.retry_count.toolchain": 0,
"thread.preflight_lint.current_node": "implement"
},
"node_outcomes": {
"simplify_opus": {
"status": "succeeded",
"context_updates": {
"last_stage": "simplify_opus",
"last_response": "Cut 60 lines off the migration module while fixing a real bug. Summary of fixes from the review:\n\n**Fixes applied:**\n1. **Correctness bug** (Agent 2 #1): `skip_clone = false` (the default) was wrongly",
"response.simplify_opus": "Cut 60 lines off the migration module while fixing a real bug. Summary of fixes from the review:\n\n**Fixes applied:**\n1. **Correctness bug** (Agent 2 #1): `skip_clone = false` (the default) was wrongly rejected as unsupported. Now only non-bool values fail. Added test `explicit_skip_clone_false_is_accepted_as_default`.\n2. **Code reuse** (Agent 1 #1, #2): Removed custom `is_table_like` / `copy_table` branching; now uses toml_edit's built-in `Item::is_table_like()` and `Item::as_table_like()` + `TableLike` trait.\n3. **Duplicate helpers** (Agent 1 #3): Collapsed `path_table` and `path_table_in_table` into a single `ensure_table` that operates on `&mut Table`; callers use `doc.as_table_mut()`.\n4. **Stringly-typed** (Agent 2 #3): Replaced raw `\"daytona\"` / `\"docker\"` matching with `EnvironmentProvider::from_str` + `IntoStaticStr`; eliminated the awkward `migrate_skip_clone` + `reject_provider_table` mirror-dispatch.\n5. **Trivial wrappers** (Agent 1 #9, Agent 2 smaller): Dropped `set_value` and `set_item`; callers use `table[key] = …` directly.\n6. **Efficiency** (Agent 3 main finding): `migrate_settings_path` now returns the already-parsed `SettingsLayer` instead of returning a string for the caller to re-parse — eliminates a redundant serde pass on the migration path.\n7. **Double-report bug** (Agent 2 smaller): `item_path_keys` now stops after reporting an empty array-of-tables instead of re-pushing per element.\n8. **Dead-code cleanup** (Agent 1 #4): Trimmed `unwrap_or(\"settings.toml\")` dead fallback and computed `file_name` once before the loop in `next_backup_path`.\n9. **Dead-code warning**: Made `backup_path` a `#[cfg(test)]` field since it's only used in tests, avoiding a `dead_code` warning in non-test builds without sprinkling `#[allow]`.\n\n**Skipped (deliberate):**\n- Adding a dedicated `Error::WriteFile` variant and converting `MigrationFailure` into an Error variant (Agent 1 #5, #6) — out of scope for a soon-to-be-removed module.\n- Promoting `next_backup_path` to `fabro-util` (Agent 1 #4, #7) — this file is going away pre-v1.0.\n- `user.rs` test fix concerns (Agent 2 #5) — works correctly, leave alone.\n- Test fixture builder consolidation — legacy TOML shape is the point of the tests.\n\n**Verification:** `cargo nextest run -p fabro-config` (216 pass), `cargo +nightly-2026-04-14 fmt --check --all` (clean), `cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings` (clean)."
},
"notes": "Stage completed: simplify_opus",
"usage": {
"input": {
"usage": {
"model": {
"provider": "anthropic",
"model_id": "claude-opus-4-7"
},
"tokens": {
"input_tokens": 86218,
"output_tokens": 29230,
"reasoning_tokens": 0,
"cache_read_tokens": 3120558,
"cache_write_tokens": 305320
}
},
"facts": {
"algorithm": "anthropic",
"cache_write_5m_tokens": 305320,
"cache_write_1h_tokens": 0
}
},
"total_usd_micros": 4630369
},
"files_touched": [
"/home/daytona/workspace/fabro/lib/crates/fabro-config/src/legacy_sandbox_migration.rs",
"/home/daytona/workspace/fabro/lib/crates/fabro-config/src/load.rs"
]
},
"preflight_lint": {
"status": "succeeded",
"context_updates": {
"command.output": "blob://sha256/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126"
},
"notes": "Script completed: cargo +nightly-2026-04-14 clippy -q --workspace --all-targets -- -D warnings 2>&1",
"usage": null
},
"implement": {
"status": "succeeded",
"context_updates": {
"response.implement": "Implemented the legacy `[run.sandbox]` auto-migration.\n\nSummary:\n- Added isolated `fabro-config` migration module:\n - Detects legacy `[run.sandbox]`\n - Rewrites to `[run.environment] id = \"default\"` plus `[environments.default]`\n - Supports Daytona/Docker field mappings, `preserve`, `env`, `skip_clone = true`, labels, snapshots, volumes, Docker image/memory/cpu quota\n - Writes numbered sibling backups\n - Reports unsupported/ambiguous keys with full paths\n- Hooked migration only into file loading via `load_settings_path`; in-memory parsing remains strict.\n- Added migration tests, loader test, backup tests, failure diagnostics tests, and `skip_clone` coverage.\n- Added docs warning and new changelog entry.\n- Added a small existing test isolation fix in `fabro-config/src/user.rs` to prevent `FABRO_HOME` races during full crate tests.\n\nVerification run:\n- `cargo test -p fabro-config --quiet` ✅\n- `cargo +nightly-2026-04-14 fmt --check --all` ✅\n- `cargo +nightly-2026-04-14 clippy --workspace --all-targets -- -D warnings` ✅\n- `cargo test -p fabro-config legacy_run_sandbox_is_rejected --quiet` ✅\n- Loader migration focused test ✅\n\nDocs reference check:\n- Requested `rg ...` command could not run because `rg` is not installed in the environment.\n- Used an equivalent `grep -R -n -E ...` check instead; remaining `[run.sandbox]` references are migration/removal notes or historical changelog entries.",
"last_stage": "implement",
"last_response": "Implemented the legacy `[run.sandbox]` auto-migration.\n\nSummary:\n- Added isolated `fabro-config` migration module:\n - Detects legacy `[run.sandbox]`\n - Rewrites to `[run.environment] id = \"default\"`"
},
"notes": "Stage completed: implement",
"usage": {
"input": {
"usage": {
"model": {
"provider": "openai",
"model_id": "gpt-5.5"
},
"tokens": {
"input_tokens": 148246,
"output_tokens": 18262,
"reasoning_tokens": 13644,
"cache_read_tokens": 8010240,
"cache_write_tokens": 0
}
},
"facts": {
"algorithm": "openai"
}
},
"total_usd_micros": 5703530
}
},
"preflight_compile": {
"status": "succeeded",
"context_updates": {
"command.output": "blob://sha256/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126"
},
"notes": "Script completed: cargo check -q --workspace 2>&1",
"usage": null
},
"start": {
"status": "succeeded",
"usage": null
},
"toolchain": {
"status": "succeeded",
"context_updates": {
"command.output": "blob://sha256/fc14b2ba2d770e5cd3169df7a29525c962adfc4cfa3097b9098c63ebd61a748c"
},
"notes": "Script completed: command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1",
"usage": null
}
},
"next_node_id": "simplify_gpt",
"node_visits": {
"preflight_lint": 1,
"toolchain": 1,
"simplify_opus": 1,
"preflight_compile": 1,
"implement": 1,
"start": 1
}
},
"diff": {}
}
],
"conclusion": null,
"sandbox": {
"provider": "daytona",
"snapshot": "fabro-v11",
"runtime": {
"id": "fabro-01KSB6HFNMJ802AXGBAV5JP7ZS",
"working_directory": "/home/daytona/workspace/fabro",
"repo_cloned": true,
"clone_origin_url": "https://github.com/fabro-sh/fabro",
"clone_branch": "main",
"workspace_root": "/home/daytona/workspace",
"repos_root": "/home/daytona/repos",
"primary_repo_path": "/home/daytona/repos/fabro-sh/fabro",
"primary_repo_link": "/home/daytona/workspace/fabro"
}
},
"pull_request": null,
"superseded_by": null,
"pending_interviews": {},
"stages": {
"preflight_lint@1": {
"first_event_seq": 42,
"prompt": null,
"response": null,
"completion": {
"outcome": "succeeded",
"notes": "Script completed: cargo +nightly-2026-04-14 clippy -q --workspace --all-targets -- -D warnings 2>&1",
"failure_reason": null,
"timestamp": "2026-05-23T20:00:54.468215Z"
},
"provider_used": null,
"diff": null,
"script_invocation": {
"script": "cargo +nightly-2026-04-14 clippy -q --workspace --all-targets -- -D warnings 2>&1",
"command": "exec 2>&1\ncargo +nightly-2026-04-14 clippy -q --workspace --all-targets -- -D warnings 2>&1",
"language": "shell"
},
"script_timing": {
"output": "blob://sha256/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126",
"exit_code": 0,
"duration_ms": 137092,
"termination": "exited",
"output_bytes": 0,
"live_streaming": false
},
"parallel_results": null,
"output": null,
"output_bytes": 0,
"live_streaming": false,
"termination": "exited",
"started_at": "2026-05-23T19:58:37.365631Z",
"handler": "command",
"timing": {
"wall_time_ms": 137099,
"inference_time_ms": 0,
"tool_time_ms": 0,
"active_time_ms": 0
},
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"total_tokens": 0,
"reasoning_tokens": 0,
"cache_read_tokens": 0,
"cache_write_tokens": 0
},
"state": "succeeded"
},
"simplify_opus@1": {
"first_event_seq": 510,
"prompt": null,
"response": null,
"completion": null,
"provider_used": {
"mode": "agent",
"provider": "anthropic",
"model": "claude-opus-4-7"
},
"diff": null,
"script_invocation": null,
"script_timing": null,
"parallel_results": null,
"output": null,
"started_at": "2026-05-23T20:13:19.149546Z",
"handler": "agent",
"usage": {
"input_tokens": 86218,
"output_tokens": 29230,
"total_tokens": 3541326,
"reasoning_tokens": 0,
"cache_read_tokens": 3120558,
"cache_write_tokens": 305320,
"total_usd_micros": 4630369
},
"model": {
"provider": "anthropic",
"model_id": "claude-opus-4-7"
},
"todos": {
"kind": "anthropic_tasks",
"list_id": "anthropic_tasks:85b59e83-ec8f-427b-b898-0a85ea9eb03a",
"items": [
{
"id": "1",
"status": "completed",
"order": 0,
"subject": "Fix: skip_clone = false wrongly rejected as unsupported",
"description": "When legacy [run.sandbox.daytona] or [run.sandbox.docker] explicitly sets skip_clone = false (the default), migration currently rejects it. Treat Some(false) as no-op; only reject non-bool.",
"active_form": "Fixing skip_clone=false rejection bug"
},
{
"id": "2",
"status": "completed",
"order": 1,
"subject": "Replace is_table_like/copy_table with toml_edit built-ins",
"description": "Use Item::is_table_like() and Item::as_table_like() + TableLike iter to remove the custom helper and collapse copy_table.",
"active_form": "Using toml_edit TableLike abstractions"
},
{
"id": "3",
"status": "completed",
"order": 2,
"subject": "Collapse path_table into path_table_in_table",
"description": "Use DocumentMut::as_table_mut() to delete duplicate path_table function.",
"active_form": "Consolidating path_table helpers"
},
{
"id": "4",
"status": "completed",
"order": 3,
"subject": "Replace stringly-typed \"daytona\"/\"docker\" with EnvironmentProvider enum",
"description": "Use EnvironmentProvider::from_str + IntoStaticStr to handle provider keys.",
"active_form": "Replacing provider strings with enum"
},
{
"id": "5",
"status": "completed",
"order": 4,
"subject": "Drop trivial set_value/set_item wrappers",
"description": "Inline table[key] = value assignments; remove one-line wrappers.",
"active_form": "Inlining set_value/set_item wrappers"
},
{
"id": "6",
"status": "completed",
"order": 5,
"subject": "Avoid double SettingsLayer parse on migration path",
"description": "Return the parsed SettingsLayer from migrate_settings_path instead of re-parsing in load_settings_path.",
"active_form": "Removing double SettingsLayer parse"
},
{
"id": "7",
"status": "completed",
"order": 6,
"subject": "Fix double-report of empty arrays in item_path_keys",
"description": "When array_of_tables is non-empty but each contained table is empty, prefix is reported multiple times. Pick one level.",
"active_form": "Fixing item_path_keys double-report"
},
{
"id": "8",
"status": "completed",
"order": 7,
"subject": "Trim dead unwrap_or fallback in next_backup_path",
"description": "Remove dead \"settings.toml\" fallback; bind file_name once before loop.",
"active_form": "Cleaning up next_backup_path"
}
]
},
"subagents": [
{
"agent_id": "736f97fd",
"depth": 1,
"task": "You are doing a code reuse review on a Rust change. The diff is at /tmp/changes.diff. The new code is at lib/crates/fabro-config/src/legacy_sandbox_migration.rs and the loader changes are at lib/crates/fabro-config/src/load.rs.\n\nYour job: For each new helper, function, or pattern introduced, search the codebase (especially lib/crates/fabro-config/, lib/crates/fabro-util/, and lib/crates/fabro-types/) for existing utilities that could replace it. Use Grep extensively.\n\nSpecifically check:\n1. Is there an existing toml_edit helper for \"ensure path exists as a table\" / `path_table`?\n2. Is there an existing helper for finding the next non-existent backup filename?\n3. Is there an existing helper for \"copy table contents\"?\n4. Is there an existing error type/constructor better than `Error::other` for migration errors?\n5. Is the redundant `path_table` (operating on DocumentMut) vs `path_table_in_table` (operating on Table) duplication necessary, or could one wrap the other?\n6. Is there a shared error display pattern (anyhow/thiserror context) that fits better than the custom MigrationFailure Display impl with manual ordered listing?\n7. Is `with_file_name(format!(\"{}.suffix\", file_name))` available as a helper anywhere?\n8. The `is_table_like` and `copy_table` patterns for both Table and InlineTable — does toml_edit have a unified abstraction?\n\nRead the diff carefully. Return concrete findings as: location → suggested replacement → rationale. Skip false positives. Be terse.",
"status": {
"kind": "completed",
"success": true,
"turns_used": 58
}
},
{
"agent_id": "3acd2b78",
"depth": 1,
"task": "You are doing a code quality review on a Rust change. The diff is at /tmp/changes.diff. The new code is at lib/crates/fabro-config/src/legacy_sandbox_migration.rs and the loader changes are at lib/crates/fabro-config/src/load.rs.\n\nLook for:\n1. Redundant state or repeated calls (e.g. is `path_table(doc, &[\"environments\", \"default\"])` called twice? could the result be cached in a variable?)\n2. Parameter sprawl: are `unsupported: &mut Vec<String>` threaded through many functions in a way that suggests a builder/context object?\n3. Copy-paste with slight variation: migrate_daytona vs migrate_docker — what's actually shared and what's different? Could a small dispatch table or a `ProviderMigration` trait/struct unify them? Also `migrate_skip_clone` is called twice with the rejection of the *other* provider — is this dispatch awkward?\n4. Leaky abstractions: does the migration module reach into too many internals? Does `next_backup_path` belong in a generic path util?\n5. Stringly-typed: provider keys \"daytona\" / \"docker\" appear as raw strings in many places. Is there a `Provider` enum/strum in fabro-types that could be used?\n6. The `item_path_keys` recursion is reasonable but is the \"if table is empty, push prefix\" branch dead in practice (called only on non-empty tables)?\n7. The unsupported-vs-skip_clone logic: when skip_clone is `false`, it's silently dropped (the rules above say `skip_clone = true` maps to clone.enabled=false). Verify nothing in legacy permitted explicit `skip_clone = false`.\n8. The dance with `set_value` vs `set_item` — is one wrapper unnecessary?\n9. Is there test fixture duplication that could use a builder?\n10. The `user.rs` change uses temp_env::with_var — is that necessary or was it just to fix flakiness from FABRO_HOME being set during tests? Note this looks unrelated to the main feature.\n\nRead the diff. Return concrete findings: file:line → issue → suggested fix. Be terse and prioritize the top 5 most impactful issues.",
"status": {
"kind": "completed",
"success": true,
"turns_used": 12
}
},
{
"agent_id": "23de00dc",
"depth": 1,
"task": "You are doing an efficiency review on a Rust change. The diff is at /tmp/changes.diff. The new code is at lib/crates/fabro-config/src/legacy_sandbox_migration.rs and the loader changes are at lib/crates/fabro-config/src/load.rs.\n\nLook for:\n1. Unnecessary work: e.g. `sandbox_item.as_table().cloned()` — the whole sandbox table is cloned at the start. Is this needed, or could we operate on the reference?\n2. Repeated parsing: the migrated content is parsed twice (once in migrate_settings_path verification, once in load_settings_path after migration). Can we avoid double-parsing?\n3. Repeated file operations: `next_backup_path` calls `.exists()` in a loop — TOCTOU but also wasteful. Is the loop bound (`for index in 1..`) reasonable?\n4. Hot path: `load_settings_path` is called at startup. Failure case (no legacy sandbox) requires parsing TOML twice — once as SettingsLayer (fails), once attempted as DocumentMut. Is this acceptable?\n5. The unsupported-key recursion `item_path_keys` walks entire subtrees of unknown items — fine but verify it's bounded.\n6. The `next_backup_path` has `with_file_name(format!(...))` allocating per iteration — minor.\n7. Verify `set_value`/`set_item` don't break TOML formatting in a way that forces full re-serialization (toml_edit normally preserves formatting).\n8. Cloning of items: `item.clone()` is called often when copying — necessary for toml_edit?\n\nRead the diff. Return concrete findings: file:line → issue → suggested fix. Skip cosmetic perf issues; focus on anything that could cause user-visible slowness or wasted work. Be terse.",
"status": {
"kind": "completed",
"success": true,
"turns_used": 4
}
}
],
"state": "running"
},
"toolchain@1": {
"first_event_seq": 22,
"prompt": null,
"response": null,
"completion": {
"outcome": "succeeded",
"notes": "Script completed: command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1",
"failure_reason": null,
"timestamp": "2026-05-23T19:56:24.907697Z"
},
"provider_used": null,
"diff": null,
"script_invocation": {
"script": "command -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1",
"command": "exec 2>&1\ncommand -v cargo >/dev/null || { curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && sudo ln -sf $HOME/.cargo/bin/* /usr/local/bin/; }; cargo --version 2>&1",
"language": "shell"
},
"script_timing": {
"output": "blob://sha256/fc14b2ba2d770e5cd3169df7a29525c962adfc4cfa3097b9098c63ebd61a748c",
"exit_code": 0,
"duration_ms": 1412,
"termination": "exited",
"output_bytes": 36,
"live_streaming": true
},
"parallel_results": null,
"output": null,
"output_bytes": 36,
"live_streaming": true,
"termination": "exited",
"started_at": "2026-05-23T19:56:23.484931Z",
"handler": "command",
"timing": {
"wall_time_ms": 1422,
"inference_time_ms": 0,
"tool_time_ms": 0,
"active_time_ms": 0
},
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"total_tokens": 0,
"reasoning_tokens": 0,
"cache_read_tokens": 0,
"cache_write_tokens": 0
},
"state": "succeeded"
},
"start@1": {
"first_event_seq": 18,
"prompt": null,
"response": null,
"completion": {
"outcome": "succeeded",
"notes": null,
"failure_reason": null,
"timestamp": "2026-05-23T19:56:23.484428Z"
},
"provider_used": null,
"diff": null,
"script_invocation": null,
"script_timing": null,
"parallel_results": null,
"output": null,
"started_at": "2026-05-23T19:56:23.483860Z",
"handler": "start",
"timing": {
"wall_time_ms": 0,
"inference_time_ms": 0,
"tool_time_ms": 0,
"active_time_ms": 0
},
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"total_tokens": 0,
"reasoning_tokens": 0,
"cache_read_tokens": 0,
"cache_write_tokens": 0
},
"state": "succeeded"
},
"implement@1": {
"first_event_seq": 87,
"prompt": null,
"response": null,
"completion": {
"outcome": "succeeded",
"notes": "Stage completed: implement",
"failure_reason": null,
"timestamp": "2026-05-23T20:13:15.232065Z"
},
"provider_used": {
"mode": "agent",
"provider": "openai",
"model": "gpt-5.5",
"reasoning_effort": "xhigh"
},
"diff": null,
"script_invocation": null,
"script_timing": null,
"parallel_results": null,
"output": null,
"started_at": "2026-05-23T20:00:58.522143Z",
"handler": "agent",
"timing": {
"wall_time_ms": 736701,
"inference_time_ms": 0,
"tool_time_ms": 0,
"active_time_ms": 0
},
"usage": {
"input_tokens": 148246,
"output_tokens": 18262,
"total_tokens": 8190392,
"reasoning_tokens": 13644,
"cache_read_tokens": 8010240,
"cache_write_tokens": 0,
"total_usd_micros": 5703530
},
"model": {
"provider": "openai",
"model_id": "gpt-5.5"
},
"todos": {
"kind": "openai_plan",
"list_id": "openai_plan:1312fe4b-1d22-48c9-a2d1-a58e76efad48",
"items": [
{
"id": "92f75efb3bbbccb9",
"status": "completed",
"order": 0,
"subject": "Add migration module skeleton, dependency, and private module registration"
},
{
"id": "7d127b36f10bd32d",
"status": "completed",
"order": 1,
"subject": "Add provider-only migration tests, observe red, implement provider-only green"
},
{
"id": "e1e316fcb0fd07e7",
"status": "completed",
"order": 2,
"subject": "Add Daytona/Docker mapping tests, observe red, implement full field mappings"
},
{
"id": "dc5d43e55fee5017",
"status": "completed",
"order": 3,
"subject": "Add file rewrite tests and hook migration into load_settings_path"
},
{
"id": "d5fe5c5da0108814",
"status": "completed",
"order": 4,
"subject": "Add unsupported/ambiguous case tests and targeted diagnostics"
},
{
"id": "be0ebc957d6875e8",
"status": "completed",
"order": 5,
"subject": "Update public docs and changelog"
},
{
"id": "2813aa9c2ea530d5",
"status": "completed",
"order": 6,
"subject": "Run config tests, formatting, and optional clippy verification"
}
]
},
"subagents": [
{
"agent_id": "f6ca500f",
"depth": 1,
"task": "Inspect the fabro-config crate for the legacy sandbox/environment settings schema, load_settings_path implementation, tests, and type shapes needed for implementing a temporary legacy [run.sandbox] file auto-migration. Do not modify files. Return concise findings, including any pitfalls around toml_edit APIs or expected parsed types.",
"status": {
"kind": "completed",
"success": true,
"turns_used": 9
}
}
],
"state": "succeeded"
},
"preflight_compile@1": {
"first_event_seq": 32,
"prompt": null,
"response": null,
"completion": {
"outcome": "succeeded",
"notes": "Script completed: cargo check -q --workspace 2>&1",
"failure_reason": null,
"timestamp": "2026-05-23T19:58:33.797369Z"
},
"provider_used": null,
"diff": null,
"script_invocation": {
"script": "cargo check -q --workspace 2>&1",
"command": "exec 2>&1\ncargo check -q --workspace 2>&1",
"language": "shell"
},
"script_timing": {
"output": "blob://sha256/12ae32cb1ec02d01eda3581b127c1fee3b0dc53572ed6baf239721a03d82e126",
"exit_code": 0,
"duration_ms": 125170,
"termination": "exited",
"output_bytes": 0,
"live_streaming": false
},
"parallel_results": null,
"output": null,
"output_bytes": 0,
"live_streaming": false,
"termination": "exited",
"started_at": "2026-05-23T19:56:28.620390Z",
"handler": "command",
"timing": {
"wall_time_ms": 125176,
"inference_time_ms": 0,
"tool_time_ms": 0,
"active_time_ms": 0
},
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"total_tokens": 0,
"reasoning_tokens": 0,
"cache_read_tokens": 0,
"cache_write_tokens": 0
},
"state": "succeeded"
}
}
}