Commit Graph
45 Commits
Author SHA1 Message Date
Daniel SamsonandClaude Opus 4.5 a8cc1ffd2c fix(ci): add SpotBugs exclusions for false positives
Exclude the following false positive patterns:
- CRLF_INJECTION_LOGS: Log values are internal, not user-controlled
- COMMAND_INJECTION: Platform service managers need to run commands
- VA_FORMAT_STRING_USES_NEWLINE: Config file generators need \n
- DM_CONVERT_CASE: Internal identifiers don't need locale
- IMPROPER_UNICODE: Simple parsing doesn't need Unicode handling
- EI_EXPOSE_REP: BarnService intentionally exposes components

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 01:51:23 +00:00
Daniel SamsonandClaude Opus 4.5 f66f914169 docs: add JSON output examples to README
Add examples showing JSON output format for:
- barn service status
- barn run
- barn status
- barn describe

Also fixed typos in command examples and removed duplicate sections.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 01:49:43 +00:00
Daniel Samson 9b729ad427 Fix command examples in README.md 2026-01-22 01:45:21 +00:00
Daniel SamsonandClaude Opus 4.5 8ded382831 feat: add cross-platform installer scripts
- Add install.sh for Linux/macOS (curl installer)
  - Detects OS and architecture
  - Sets up systemd service on Linux
  - Sets up launchd agent on macOS
  - Auto-starts service on boot

- Add install.ps1 for Windows (PowerShell installer)
  - Installs Windows Service (admin) or Scheduled Task (user)
  - Adds to PATH automatically

- Add installer/barn.iss (Inno Setup script)
  - Generates setup-barn-vX.X.X-windows-x64.exe
  - Full Windows installer with uninstaller

- Update release workflow to include installers
- Update README with quick install instructions

Closes #26, #27, #29

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
v0.1.2
2026-01-22 01:41:01 +00:00
Daniel SamsonandClaude Opus 4.5 f916fc2f8b feat(jobs): add KILLED state for orphaned jobs with auto-retry
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>
v0.1.2-rc4
2026-01-22 01:08:05 +00:00
Daniel SamsonandClaude Opus 4.5 27648a03a8 fix(windows): use file path for Unix domain socket on Windows
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>
v0.1.2-rc3
2026-01-22 00:35:04 +00:00
Daniel SamsonandClaude Opus 4.5 ccabf9d4c1 docs: add pre-release testing checklist to CLAUDE.md
Added mandatory checklist for testing ALL subcommands with the native
binary before creating any release tag. Includes:

- Prerequisites for building native image
- Tests for all basic commands (help, version)
- Tests for all service commands (start, stop, restart, reload, status, logs)
- Tests for all job commands (run, status, describe, usage, kill, clean)
- Tests for config and autocompletion commands
- Copyable checklist summary

This ensures we never release a broken native binary again.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 00:31:30 +00:00
Daniel SamsonandClaude Opus 4.5 7b45fce813 fix(native): handle native image in service start/restart
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>
v0.1.2-rc2
2026-01-22 00:21:26 +00:00
Daniel SamsonandClaude Opus 4.5 461ebe44ab fix(native): add -march=compatibility for broader CPU support
Windows binary was crashing with STATUS_ILLEGAL_INSTRUCTION on x64
emulated environments (like Parallels on ARM Macs). GraalVM native-image
by default uses CPU features detected at build time.

Adding -march=compatibility ensures the binary uses only baseline
x86-64 instructions that work across all x64 CPUs and emulators.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
v0.1.2-rc1
2026-01-22 00:10:28 +00:00
Daniel SamsonandClaude Opus 4.5 116f1fbb59 fix(native): add Job and Config classes to reflection config
Jackson deserialization in native binary fails when processing job
status responses. Added missing classes to reflect-config.json:
- Job, JobManifest, JobState, ResourceUsage
- Config, ServiceConfig, StorageConfig, JobsConfig, CleanupConfig
- Collection types for IPC payloads

Tested locally with native binary:
- barn run, status, describe, usage, kill, clean
- barn service status, config show, autocompletion

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 00:04:03 +00:00
Daniel SamsonandClaude Opus 4.5 53f0991f6f fix: add Jackson reflection config for native-image
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>
2026-01-21 23:46:34 +00:00
Daniel SamsonandClaude Opus 4.5 05fb4c412b test: fix version tests to accept any semver
Changed hardcoded version checks to regex pattern matching
so tests don't break on version bumps.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
v0.1.1
2026-01-21 23:34:41 +00:00
Daniel SamsonandClaude Opus 4.5 d6a27aab3b fix: add picocli-codegen for GraalVM native-image support
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>
2026-01-21 23:28:36 +00:00
Daniel SamsonandClaude Opus 4.5 13655f5a54 docs: fix Windows install path
Use %LOCALAPPDATA%\Programs\barn instead of System32.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 23:26:07 +00:00
Daniel SamsonandClaude Opus 4.5 165e363084 docs: add installation instructions to README
Added installation instructions for:
- macOS (Homebrew and manual download)
- Linux (x64 and ARM64)
- Windows (PowerShell download)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 23:22:32 +00:00
Daniel SamsonandClaude Opus 4.5 167292165a ci: simplify build workflow
Build workflow now:
- Triggers on PRs and pushes to main
- Runs on single OS (ubuntu-latest)
- Just verifies code compiles and tests pass

Release workflow (on tags) still builds for all platforms.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 23:16:42 +00:00
Daniel SamsonandClaude Opus 4.5 436d8ee840 ci: simplify build workflow to PRs only
- Build workflow now only triggers on pull requests
- Removed native image builds from build workflow
- Native builds are only done in release workflow on tag push

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 23:14:03 +00:00
Daniel SamsonandClaude Opus 4.5 d97ee5b2b6 fix(ci): use PowerShell for Windows builds
The cmd.exe batch script wasn't executing the move command correctly.
Switch to PowerShell for more reliable file operations on Windows.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
v0.1.0
2026-01-21 23:08:41 +00:00
Daniel SamsonandClaude Opus 4.5 045f196552 fix(ci): use Oracle GraalVM and remove Windows ARM64
- Switch from graalvm-community to graalvm (Oracle GraalVM)
- Remove Windows ARM64 from matrix (no GraalVM support available)
- Add fail-fast: false to prevent one failure from cancelling others

Native builds now target 4 platforms:
- Linux x64
- Linux ARM64
- macOS ARM64
- Windows x64

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 23:00:20 +00:00
Daniel SamsonandClaude Opus 4.5 cbd58f9857 fix(ci): add Windows ARM64 support
Add windows-11-arm runner to build matrix for ARM64 Windows builds.
Now building for 5 platforms:
- Linux x64 (ubuntu-latest)
- Linux ARM64 (ubuntu-24.04-arm)
- macOS ARM64 (macos-latest)
- Windows x64 (windows-latest)
- Windows ARM64 (windows-11-arm)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 22:57:23 +00:00
Daniel SamsonandClaude Opus 4.5 276480c3ab fix(ci): fix Windows build and update macOS runner
- Use cmd shell on Windows to avoid PowerShell argument parsing issues
- Update macOS Intel runner from macos-13 to macos-15-large

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 22:53:53 +00:00
Daniel Samson 1c5555e2d8 Release v0.1.0 2026-01-21 22:52:00 +00:00
Daniel SamsonandClaude Opus 4.5 20fb09ffca chore: add MIT license
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 22:48:56 +00:00
Daniel SamsonandClaude Opus 4.5 1ec8120ecb chore: update homebrew tap to samson-media/homebrew-tap
Changes tap repo from homebrew-barn to homebrew-tap for cleaner
install command: brew install samson-media/tap/barn

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 22:47:38 +00:00
Daniel SamsonandClaude Opus 4.5 92c586152b docs: update CI/CD and releasing docs for Maven build system
Updates documentation to reflect the actual Maven-based build:
- pom.xml instead of gradle.properties for version
- mvn commands instead of gradlew
- Updated build workflow examples

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 22:35:28 +00:00
Daniel SamsonandClaude Opus 4.5 767a941ac3 feat(ci): add GitHub Actions workflows for CI/CD
Adds automated build, test, and release pipelines:
- build.yml: Run tests and build native images on push/PR
- release.yml: Build and publish releases on tag push
- update-homebrew.yml: Auto-update Homebrew formula on release

Also adds CHANGELOG.md for tracking releases.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 22:32:22 +00:00
Daniel SamsonandClaude Opus 4.5 3f046bfd48 chore: rename run.sh to barn for convenience
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 22:24:29 +00:00
Daniel SamsonandClaude Opus 4.5 028770a2da feat(cli): add autocompletion command for shell completion scripts
Adds `barn autocompletion` command to generate shell completion scripts:
- `barn autocompletion --bash` generates bash completion
- `barn autocompletion --zsh` generates zsh completion (using bashcompinit)

Usage:
  barn autocompletion --bash > /usr/local/etc/bash_completion.d/barn
  barn autocompletion --zsh > ~/.zsh/completions/_barn

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 22:22:03 +00:00
Daniel SamsonandClaude Opus 4.5 e8ea91268a fix(jobs): write startup errors to stderr.log
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>
2026-01-21 22:15:07 +00:00
Daniel SamsonandClaude Opus 4.5 555879be60 fix(jobs): allow QUEUED -> FAILED state transition
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>
2026-01-21 22:11:53 +00:00
Daniel SamsonandClaude Opus 4.5 5d45b53abe chore: add run.sh convenience script
Shortens the command to run the JAR during development.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 22:05:39 +00:00
Daniel SamsonandClaude Opus 4.5 da43488024 fix(logging): use consistent /tmp/barn/logs path for service logs
The previous configuration used ${java.io.tmpdir} which resolves to
/var/folders/... on macOS, while the data directory uses /tmp/barn.
This caused a mismatch where logs and data were in different locations.

Changed to use explicit /tmp/barn/logs as default for both FILE and
JSON appenders to match the ConfigDefaults.getDefaultBaseDir() path.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 22:02:28 +00:00
Daniel SamsonandClaude Opus 4.5 1ce74e0bc8 fix(logging): suppress logback status messages in CLI output
- Add NopStatusListener to suppress logback initialization messages
- Remove console appender from default root logger (file only)
- CLI commands now show clean output without logging noise

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 21:48:45 +00:00
Daniel SamsonandClaude Opus 4.5 92810cabee feat(service): add IPC communication and service management
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>
2026-01-21 21:41:02 +00:00
Daniel SamsonandClaude Opus 4.5 818c45de0a feat(execution): implement process execution engine (#5)
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>
2026-01-21 13:19:54 +00:00
Daniel SamsonandClaude Opus 4.5 c6e26bbedb feat(jobs): implement job model and state machine (#4)
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>
2026-01-21 13:15:19 +00:00
Daniel SamsonandClaude Opus 4.5 647e602fe9 feat(state): implement filesystem state management system (#3)
- Add AtomicFiles utility for atomic file operations (write-to-tmp-then-rename)
- Add JobState enum (queued, running, succeeded, failed, canceled)
- Create BarnDirectories for managing directory structure:
  - jobs/, locks/, logs/ top-level directories
  - Per-job: work/input/, work/output/, logs/ subdirectories
  - Lock files for scheduler and individual jobs
- Implement StateFiles for reading/writing job metadata:
  - State, tag, timestamps (created_at, started_at, finished_at, heartbeat)
  - Exit codes (integer and symbolic), error messages
  - PID, retry count, retry history, stage
  - All timestamps in ISO-8601 format
- Add FileLock for cross-process file locking using FileChannel.tryLock()
- Handle OverlappingFileLockException for same-JVM lock attempts
- Add comprehensive tests (92 new tests, 211 total)

Closes #3

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 13:04:01 +00:00
Daniel SamsonandClaude Opus 4.5 79f89be47c feat(config): implement configuration system with TOML parser (#2)
- Add LogLevel enum with case-insensitive parsing
- Add OperatingSystem enum with platform detection
- Create config records: Config, ServiceConfig, JobsConfig, CleanupConfig, StorageConfig
- Add ConfigDefaults for platform-specific paths (Unix/Windows)
- Implement TomlParser supporting sections, strings, integers, floats, booleans, arrays
- Create ConfigLoader with:
  - File loading from search paths (system/user config)
  - Environment variable overrides (BARN_SECTION_KEY pattern)
  - Validation of all config values
  - Defaults for missing values
- Add comprehensive tests (93 new tests, 119 total)

Closes #2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 12:59:15 +00:00
Daniel SamsonandClaude Opus 4.5 05937b1f7e feat(cli): set up project structure and main entry point (#1)
- 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>
2026-01-21 12:53:54 +00:00
Daniel SamsonandClaude e861e12058 docs: add comprehensive ticket implementation process to CLAUDE.md
Adds a 6-phase mandatory workflow for implementing GitHub tickets:
- Phase 1: READ - Fetch ticket, check dependencies, read docs
- Phase 2: PLAN - List deliverables and test cases
- Phase 3: TEST - Write all tests first (TDD)
- Phase 4: IMPLEMENT - Code to pass tests
- Phase 5: VERIFY - Run mvn verify, check acceptance criteria
- Phase 6: COMPLETE - Commit and close ticket

Also adds:
- Ticket process checklist template
- GitHub issue workflow commands
- Dependency graph visualization
- Emergency procedures for common issues
- Ticket template reference

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-21 12:45:22 +00:00
Daniel SamsonandClaude Opus 4.5 4bd4cb1fa4 Strengthen CLAUDE.md with mandatory testing requirements
- Emphasize reading docs first (mandatory)
- Add "ALWAYS Write Tests First" requirement
- Add "ALWAYS Validate with Tests" requirement (mvn verify)
- Add detailed testing requirements section:
  - Coverage requirements (80% line, 70% branch, 100% new code)
  - Test naming conventions
  - AAA pattern examples
  - What to test for every class
- Add step-by-step workflow for code changes (TDD approach)
- Add commit checklist
- Add "What NOT to Do" section emphasizing test requirements

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 12:26:48 +00:00
Daniel SamsonandClaude Opus 4.5 3c09ea978d Add coding standards and quality enforcement tooling
- docs/coding-standards.md: Comprehensive Java coding standards
- CLAUDE.md: AI assistant instructions for the project
- .editorconfig: Editor configuration for consistent formatting
- pom.xml: Updated with quality plugins (Checkstyle, SpotBugs, PMD, JaCoCo)
- config/checkstyle/: Checkstyle configuration (Google Java Style based)
- config/spotbugs/: SpotBugs exclusions
- config/pmd/: PMD ruleset
- .githooks/pre-commit: Pre-commit hook for local quality checks
- .github/workflows/lint.yml: CI workflow for automated quality checks
- docs/development.md: Updated for Java/Maven toolchain

Quality enforcement:
- Checkstyle runs on validate phase
- SpotBugs and PMD run on verify phase
- JaCoCo enforces 80% line coverage, 70% branch coverage
- Pre-commit hook runs all checks before allowing commits
- CI runs all checks on push and PR

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 12:22:06 +00:00
Daniel SamsonandClaude Opus 4.5 cf750b6eb5 Add comprehensive project documentation
- docs/config.md: Configuration options, retry behavior, cleanup policies
- docs/development.md: Local dev setup, building from source
- docs/releasing.md: Version management, release process, AUR/Homebrew automation
- docs/ci-cd.md: GitHub Actions workflows for build, release, AUR, Homebrew
- docs/distribution.md: Package manager setup (WinGet, apt, AUR, Homebrew)
- docs/auto-update.md: Built-in barn update command
- docs/testing-automated.md: Test suite, running tests, CI integration
- docs/testing-manual.md: Step-by-step manual test procedures
- docs/jobs.md: Added retry-related state files
- README.md: Updated documentation links

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 12:12:16 +00:00
Daniel Samson 822086b39d Add initial files 2026-01-21 11:49:12 +00:00
Daniel Samson 12ad2e7ebf Add README.md 2026-01-21 10:36:04 +00:00