Code fixes:
- Add Locale.ROOT to all toLowerCase()/toUpperCase() calls (DM_CONVERT_CASE)
- Remove unused variable in ServiceReloadCommand (DLS_DEAD_LOCAL_STORE)
- Combine duplicate switch cases in ConfigShowCommand, ServiceStatusCommand
SpotBugs exclusions (false positives only):
- COMMAND_INJECTION: CLI commands use hardcoded paths, not user input
- CRLF_INJECTION_LOGS: We log internal identifiers like job IDs
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When the barn service is terminated unexpectedly (crash, SIGKILL), jobs
that were running are now marked as KILLED instead of FAILED. This
distinguishes between jobs that failed due to their own errors vs jobs
that were killed due to external factors.
Key changes:
- Add KILLED state to JobState enum
- Update JobStateMachine with KILLED transitions (RUNNING→KILLED, KILLED→QUEUED)
- CrashRecovery now marks orphaned jobs as KILLED and auto-retries them
- Add markKilled() method to JobRepository
- Add killed count to service status output
- Update HumanFormatter to display KILLED state in red
The auto-retry behavior uses exponential backoff (configurable) and
respects the maxRetries limit. Retry history is recorded in the
retry_history file.
Closes#25
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Windows 10 1803+ supports Unix domain sockets but requires a regular
file path, not the named pipe format (\\.\pipe\...). Changed the
Windows IPC socket default from named pipe to file path in %TEMP%.
This fixes "Network is down: bind" error when starting the service
on Windows.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
In GraalVM native images, java.home and java.class.path are null.
When starting the daemon process, detect if running as native image
using org.graalvm.nativeimage.imagecode property. If so, re-exec the
current executable instead of trying to spawn a JVM.
Fixes NullPointerException on Windows when running `barn service start`.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
IPC communication was failing in native binary because Jackson
couldn't deserialize IpcMessage and related classes without
reflection configuration.
Added reflect-config.json with all IPC classes.
Bumped version to 0.1.2.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The native binary was crashing on startup because picocli's reflection
metadata wasn't being generated for GraalVM native-image.
Added picocli-codegen annotation processor to generate the required
reflect-config.json at compile time.
Bumped version to 0.1.1.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When a job fails to start (e.g., command not found), the error is now
written to stderr.log so it appears in `barn describe --logs` output.
Previously, the log files were empty for jobs that failed before the
process could start, making it hard to diagnose the issue.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Jobs can fail before they start running (e.g., command not found,
permission denied). Previously, the state machine only allowed
QUEUED -> RUNNING or CANCELED, so jobs that failed to start would
stay stuck in QUEUED state with the scheduler retrying endlessly.
Now jobs can transition directly from QUEUED to FAILED, properly
recording the error message for commands that cannot be executed.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement proper CLI-to-service communication via Unix domain sockets,
fixing issue where CLI commands couldn't see jobs managed by the service.
Key changes:
- Add IPC client/server for CLI-service communication
- Fix directory mismatch (CLI used java.io.tmpdir, service used /tmp/barn)
- Add service management commands (start, stop, restart, reload, logs)
- Add service installation for macOS (launchd), Linux (systemd), Windows
- Add process usage monitoring (barn usage command)
- Add job state breakdown in service status (succeeded, failed, canceled)
- Add output formatters (human, JSON, XML)
- Add crash recovery and heartbeat checking
- Add structured logging with MDC context
The CLI commands now properly communicate with the running service
via IPC, ensuring consistent job state visibility.
Fixes#24
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add process execution infrastructure:
- ProcessUtils for cross-platform process management (isAlive, killTree)
- ProcessExecutor for command execution with output capture to log files
- ProcessMonitor for asynchronous process monitoring with events
- JobRunner for orchestrating job execution with state management
Features:
- Cross-platform support (Windows, macOS, Linux)
- Real-time stdout/stderr capture to log files
- Heartbeat monitoring during execution
- Graceful and forceful process termination
Includes 54 new tests for comprehensive coverage.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add core job management infrastructure:
- Job record with lifecycle methods (createQueued, withStarted,
withCompleted, withRetry, withCanceled)
- JobIdGenerator for unique job identifiers (job-XXXXXXXX format)
- JobManifest for immutable job configuration with retry settings
- JobStateMachine for validating state transitions
- JobRepository for filesystem persistence using atomic operations
State transitions: QUEUED → RUNNING → SUCCEEDED/FAILED/CANCELED
Failed jobs can transition back to QUEUED for retry.
Includes 87 tests covering all components with comprehensive edge
case coverage.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create Main.java with picocli integration and testable run() method
- Create BarnCommand as root command with all subcommands registered
- Add placeholder subcommands: run, status, describe, kill, clean, service, config
- Update package structure from org.media.samson to com.samsonmedia.barn
- Configure checkstyle to allow underscores in test method names
- Add comprehensive tests for all CLI commands (26 tests, 80%+ coverage)
Closes#1
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>