Skip to content

feat: add --keep-workspace flag for debugging #123#217

Merged
spboyer merged 3 commits into
mainfrom
squad/123-debug-workspace
Apr 22, 2026
Merged

feat: add --keep-workspace flag for debugging #123#217
spboyer merged 3 commits into
mainfrom
squad/123-debug-workspace

Conversation

@spboyer

@spboyer spboyer commented Apr 21, 2026

Copy link
Copy Markdown
Member

Summary

Adds a --keep-workspace flag to waza run that preserves temp workspaces after execution, allowing users to inspect fixture files and agent modifications for debugging.

Closes #123

Working as Linus (Backend Developer)

Changes

Core

  • WorkspaceKeeper interface (internal/execution/engine.go): Optional interface with SetKeepWorkspace(bool) — avoids breaking the AgentEngine interface contract
  • CopilotEngine (internal/execution/copilot.go): Skips os.RemoveAll when keepWorkspace is true; prints Workspace preserved: <path> to stderr
  • MockEngine (internal/execution/mock.go): Same pattern for test engine

Model & Orchestration

  • RunResult.WorkspaceDir (internal/models/outcome.go): New field (omitempty for JSON compat)
  • Runner (internal/orchestration/runner.go): Propagates WorkspaceDir from execution response; adds workspace_dir to RunComplete progress event

CLI

  • --keep-workspace flag (cmd/waza/cmd_run.go): Registered as bool flag, wired to engine via type assertion
  • Verbose output: Shows workspace path per-run when flag is active
  • Test globals (cmd/waza/cmd_run_test.go): Reset keepWorkspace = false

Tests (4 new)

  • TestMockEngine_KeepWorkspace_PreservesDir — workspace survives shutdown
  • TestMockEngine_DefaultBehavior_CleansUpDir — regression: default still cleans up
  • TestCopilotEngine_KeepWorkspace_PreservesDir — copilot engine workspace survives
  • TestCopilotEngine_KeepWorkspace_PrintsPath — stderr message verification
  • Interface compliance checks for WorkspaceKeeper

Docs

  • README.md: Added flag to run command flags table
  • site/src/content/docs/reference/cli.mdx: Added flag to table + example

Usage

# Run eval and keep workspaces for inspection
waza run eval.yaml --keep-workspace -v

# Workspaces printed to stderr on shutdown:
# Workspace preserved: /var/folders/.../waza-abc123

Testing

  • All 4 new tests pass
  • Full go test ./internal/... passes
  • go vet clean
  • Site builds successfully

@spboyer spboyer added the squad:linus Assigned to Linus (Backend Developer) label Apr 21, 2026
@github-actions github-actions Bot enabled auto-merge (squash) April 21, 2026 22:00
Copilot AI added 2 commits April 21, 2026 18:05
Add --keep-workspace flag to 'waza run' that preserves temp workspaces
after execution, allowing users to inspect fixture files and agent
modifications for debugging.

Changes:
- Add WorkspaceKeeper interface (optional, avoids breaking AgentEngine)
- CopilotEngine/MockEngine: skip os.RemoveAll when keepWorkspace is set
- Print 'Workspace preserved: <path>' to stderr on shutdown
- Show workspace path in verbose progress output per-run
- Add WorkspaceDir to RunResult model (omitempty for JSON compat)
- Propagate workspace_dir in RunComplete progress event
- Add 4 dedicated tests (preserve, cleanup, copilot, stderr message)
- Update CLI reference docs and README

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add 3 integration tests in cmd_run_shutdown_test.go:
- TestRunSingleModel_KeepWorkspaceFlag: verifies flag works and stderr shows preserved path
- TestRunSingleModel_KeepWorkspaceVerbose: verifies --keep-workspace + --verbose combo
- TestRunSingleModel_DefaultCleansWorkspace: verifies default behavior has no preservation message

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@spboyer spboyer force-pushed the squad/123-debug-workspace branch from a0622aa to 4c03466 Compare April 21, 2026 22:06
- Fix gofmt alignment in CopilotEngine struct fields (copilot.go)
- Handle w.Close() error returns in shutdown tests (errcheck)
- Handle os.RemoveAll() error return in engine shutdown test (errcheck)
- Wrap os.WriteFile() calls with error checking in spec_test.go (errcheck)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@spboyer spboyer merged commit efdac71 into main Apr 22, 2026
6 checks passed
@spboyer spboyer deleted the squad/123-debug-workspace branch April 22, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

squad:linus Assigned to Linus (Backend Developer)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a way for users to debug/view into the temp workspace we setup

2 participants