# BobNet OS Implementation Slices And Testing Loops Use these slices when rebuilding from scratch or hardening a partial implementation. Each slice has an implementation goal, a test loop, and a stop condition. ## Standard Loop For Every Slice 1. Inspect existing code and tests. 2. Add or update narrow tests first when possible. 3. Implement the smallest useful surface. 4. Run targeted tests. 5. Run full build. 6. Update docs/smoke notes if behavior changed. 7. Do not move to the next slice with unexplained failing tests. Commands: ```powershell dotnet build BobNetOS.sln -c Release dotnet test BobNetOS.sln -c Release --no-build ``` ## Slice 0 - Shell, Branding, And Project Shape Goal: - Create WinForms project. - Publish as `BobNetOS.exe`. - Use BobNet OS in visible UI. - Add test project. - Add release/smoke scripts. Expected files: ```text BobNetOS.sln BrianCodexHarness/BrianCodexHarness.csproj BrianCodexHarness/Form1.cs BrianCodexHarness.Tests/BrianCodexHarness.Tests.csproj scripts/build-bobnetos-release.ps1 scripts/smoke-bobnetos.ps1 ``` Test loop: ```powershell dotnet new sln -n BobNetOS dotnet build BobNetOS.sln -c Release dotnet test BobNetOS.sln -c Release --no-build dotnet publish BrianCodexHarness\BrianCodexHarness.csproj -c Release -r win-x64 --self-contained false ``` Stop condition: - App launches. - Window title says BobNet OS. - Published executable is `BobNetOS.exe`. ## Slice 1 - SQLite Durable Kernel Goal: - Add SQLite package. - Create schema/migrations. - Build a service layer for boards/cards/events. - Make SQLite default. - Keep legacy JSON only as explicit compatibility path. Suggested folders: ```text Services/Storage/ Services/Kernel/ Domain/ ``` Core service shape: ```csharp public interface IBoardStore { IReadOnlyList ListBoards(bool includeArchived); BoardRecord CreateBoard(string name, string workspacePath, string goal); BoardRecord? GetBoard(string boardId); CardRecord CreateCard(string boardId, CardCreateRequest request); IReadOnlyList ListCards(string boardId, bool includeArchived); void UpdateCard(CardRecord card); void ArchiveCard(string boardId, string cardId); } ``` Test loop: ```powershell dotnet test BobNetOS.sln --filter "FullyQualifiedName~Sqlite" dotnet test BobNetOS.sln --filter "FullyQualifiedName~BoardStore" ``` Acceptance: - Temporary data root creates `bobnetos.db`. - Board/card CRUD works. - Events are written for create/update/archive. - No normal launch auto-imports legacy data. ## Slice 2 - Dependencies, Comments, Runs, Events Goal: - Add card links. - Add comments. - Add run history. - Add full event trail. Required rules: - Reject self dependency. - Reject dependency cycles. - Children wait until parents are Done. - Comments append only. - Runs are immutable records except status/completion fields. Test examples: ```csharp [Fact] public void CannotLinkCardToItself() { var store = CreateStore(); var board = store.CreateBoard("Test", TempDir(), ""); var card = store.CreateCard(board.Id, new CardCreateRequest("A")); var result = store.TryLinkCards(board.Id, card.Id, card.Id); Assert.False(result.Succeeded); } ``` Test loop: ```powershell dotnet test BobNetOS.sln --filter "FullyQualifiedName~Dependency" dotnet test BobNetOS.sln --filter "FullyQualifiedName~Run" dotnet test BobNetOS.sln --filter "FullyQualifiedName~Event" ``` ## Slice 3 - Worker Result Protocol Goal: - Generate `BOBNETOS_CARD_CONTEXT.md`. - Instruct Codex worker to write `BOBNETOS_RESULT.json`. - Parse result file. - Map status to card/run state. Parser behavior: ```csharp public sealed record WorkerResult( int SchemaVersion, string CardId, string RunId, string Status, string Summary, IReadOnlyList ChangedFiles, IReadOnlyList Verification, IReadOnlyList ResidualRisk, string? BlockedReason); ``` Test loop: ```powershell dotnet test BobNetOS.sln --filter "FullyQualifiedName~WorkerResult" dotnet test BobNetOS.sln --filter "FullyQualifiedName~PromptBuilder" ``` Acceptance: - Valid completed result updates run/card correctly. - Blocked result creates blocked event and reason. - Invalid JSON is visible in run error. - Missing result file is visible and does not masquerade as success. ## Slice 4 - Manual Codex Execution Goal: - Select a card. - Choose agent/profile. - Choose workspace mode and sandbox. - Click Run with Codex. - App creates run folder, launches worker, parses result, updates UI. Run command route must be wrapped behind an interface: ```csharp public interface IProcessRunner { Task RunAsync(ProcessStartRequest request, CancellationToken cancellationToken); } ``` Test loop: ```powershell dotnet test BobNetOS.sln --filter "FullyQualifiedName~CodexExecution" ``` Manual smoke: 1. Create disposable board. 2. Create Ready card. 3. Assign agent. 4. Run card. 5. Confirm run row and event rows. 6. Confirm result JSON path is shown. ## Slice 5 - Dispatcher MVP Goal: - Dispatch Once claims one eligible Ready card. - Dispatcher loop runs periodically. - Claims are atomic. - Repeated spawn failures block the card. Core service shape: ```csharp public sealed class DispatcherService { public Task DispatchOnceAsync(string boardId, CancellationToken ct); public Task RunLoopAsync(string boardId, DispatcherSettings settings, CancellationToken ct); } ``` Test loop: ```powershell dotnet test BobNetOS.sln --filter "FullyQualifiedName~Dispatcher" ``` Acceptance: - Ready card claimed once. - Two dispatcher calls cannot claim the same card. - Backlog child promotes only after parent Done. - Spawn failures trip blocked state with useful error. ## Slice 6 - Review Workflow And Evidence UI Goal: - Review column exists. - Worker completion can land in Review. - Approve moves to Done. - Request Changes moves to Ready/Blocked with comment. - Evidence paths and verification show clearly. Test loop: ```powershell dotnet test BobNetOS.sln --filter "FullyQualifiedName~Review" dotnet test BobNetOS.sln --filter "FullyQualifiedName~Evidence" ``` Manual smoke: 1. Put card in Review. 2. Open card editor. 3. View result/evidence. 4. Approve. 5. Confirm Done event. ## Slice 7 - Profiles And Agent Floor Goal: - Markdown/file-backed profiles under data root. - Card assignee dropdown uses profiles. - Agent floor shows agents and current work. - Empty chair opens new profile editor. - Clicking agent opens edit profile. Profile shape: ```markdown # Coder ## Role Implementation worker. ## Prompt You are a careful coding agent. Read the card, inspect the repo, implement narrowly, verify, and write BOBNETOS_RESULT.json. ``` Test loop: ```powershell dotnet test BobNetOS.sln --filter "FullyQualifiedName~AgentProfile" dotnet test BobNetOS.sln --filter "FullyQualifiedName~AgentRoster" ``` ## Slice 8 - Workspace Modes And Cleanup Goal: - Direct, Scratch, and Worktree modes. - Scratch creates run-scoped folder. - Worktree creates git worktree. - Cleanup previews and removes only generated paths. Test loop: ```powershell dotnet test BobNetOS.sln --filter "FullyQualifiedName~Workspace" dotnet test BobNetOS.sln --filter "FullyQualifiedName~Git" ``` Acceptance: - Non-git workspace rejects Worktree mode with clear message. - Scratch folder has BobNet OS ownership marker. - Cleanup never deletes arbitrary user paths. ## Slice 9 - CLI, API, MCP Goal: - Add command-line management for boards/cards/runs/events. - Add local API for automation. - Add MCP stdio server with BobNet OS tool names. Test loop: ```powershell dotnet test BobNetOS.sln --filter "FullyQualifiedName~Cli" dotnet test BobNetOS.sln --filter "FullyQualifiedName~Api" dotnet test BobNetOS.sln --filter "FullyQualifiedName~Mcp" ``` Smoke examples: ```powershell dotnet BrianCodexHarness\bin\Release\net8.0-windows\win-x64\publish\BobNetOS.dll cli boards list --sqlite-store --data-dir "$env:TEMP\BobNetOS-CliSmoke" dotnet BrianCodexHarness\bin\Release\net8.0-windows\win-x64\publish\BobNetOS.dll cli mcp serve --sqlite-store --data-dir "$env:TEMP\BobNetOS-CliSmoke" ``` ## Slice 10 - Chat Planner Harness Goal: - Main Chat tab exists. - Local model can propose structured board/card actions. - Host validates and previews. - Confirm applies. - Activity indicator shows work in progress. Read `04-CHAT-ORCHESTRATOR-HARNESS.md` before implementing. ## Slice 11 - Automation, Hooks, Notifications Goal: - Automation rules can trigger cards/dispatch. - Notifications persist. - Hook definitions can run on events. - Failures are logged, not swallowed. Test loop: ```powershell dotnet test BobNetOS.sln --filter "FullyQualifiedName~Automation" dotnet test BobNetOS.sln --filter "FullyQualifiedName~Notification" dotnet test BobNetOS.sln --filter "FullyQualifiedName~Hook" ``` ## Slice 12 - Release And Hosted Bootstrap Goal: - Build script publishes `BobNetOS.exe`. - Smoke script verifies source and published output. - Bootstrap docs describe both compile-existing and rebuild-from-zero paths. - Zip package is regenerated. Release loop: ```powershell powershell -ExecutionPolicy Bypass -File scripts\build-bobnetos-release.ps1 powershell -ExecutionPolicy Bypass -File scripts\smoke-bobnetos.ps1 Compress-Archive -Path codex-bootstrap\* -DestinationPath codex-bootstrap\bobnet-os-codex-bootstrap-docs.zip -Force ```