using System;using System.IO;using System.Linq;using System.Text;namespace Lilith.Agent.SelfImprovement;internal static class SandboxVerificationService{ public static string VerifyTool(SelfImprovementPaths paths, string toolName) { if (string.IsNullOrWhiteSpace(toolName)) throw new ArgumentException("tool_name is required."); var sb = new StringBuilder(); sb.AppendLine(SandboxBuildService.BuildSandboxConsole(paths)); sb.AppendLine(); bool foundInSource = Directory.EnumerateFiles(paths.Sandbox, "*.cs", SearchOption.AllDirectories) .Any(f => File.ReadAllText(f).Contains($"\"{toolName}\"", StringComparison.OrdinalIgnoreCase) || File.ReadAllText(f).Contains($"Name = \"{toolName}\"", StringComparison.OrdinalIgnoreCase)); sb.AppendLine(foundInSource ? $"Source check: tool '{toolName}' appears in sandbox source." : $"Source check: tool '{toolName}' was NOT found in sandbox .cs files."); string testOutput = SandboxBuildService.RunDesignTests(paths, "FullyQualifiedName~ToolCalling"); sb.AppendLine(); sb.AppendLine(testOutput); bool buildOk = sb.ToString().Contains("Build succeeded", StringComparison.OrdinalIgnoreCase) || sb.ToString().Contains("0 Error(s)", StringComparison.OrdinalIgnoreCase); bool testsOk = testOutput.Contains("Passed!", StringComparison.OrdinalIgnoreCase) || testOutput.StartsWith("Skipped", StringComparison.OrdinalIgnoreCase); sb.AppendLine(); sb.AppendLine(buildOk && foundInSource && testsOk ? $"VERIFICATION PASSED for '{toolName}'. You may call self_improve_promote_sandbox." : $"VERIFICATION FAILED for '{toolName}'. Fix sandbox, rebuild, and verify again before promote."); return sb.ToString().TrimEnd(); }}
Documentation
Lilith self-improvement (Version 7+)
Lilith can extend herself only by creating tools in three categories:
| Category | Location | Examples | |----------|----------|----------| | Core | Agent-Core | Memory, time (rare; system-level) | | Addon | Agent-Addons | Weather, C# projects, apps | | Self | Lilith | Workspace files, self-improvement |
Layout
ShippedSource/— copy ofsrc/Version7next to the built app (MSBuildCopyShippedSource){workspace}/output/self-improvement/live— current editable source{workspace}/output/self-improvement/sandbox— clone for edits and builds{workspace}/output/self-improvement/backups/{timestamp}— backups before promote
Tools
1. self_improve_get_source_layout 2. self_improve_generate_tool 3. self_improve_backup_live 4. self_improve_create_sandbox 5. self_improve_build_sandbox 6. self_improve_verify_sandbox_tool 7. self_improve_promote_sandbox — copies sandbox → live, builds, restarts
Set GENESIS_REPO_ROOT to the repo root when developing from source instead of ShippedSource.