Commit graph

29 commits

Author SHA1 Message Date
Jeremie Fraeys
b2eba75f09
feat: CLI shell completion for new commands
Update bash and zsh completion scripts to include:
- compare, find, export, outcome commands
- privacy command and subcommands
- All new narrative field flags (--hypothesis, --context, etc.)
- Sandboxing options (--network, --read-only, --secret)
2026-02-18 21:27:38 -05:00
Jeremie Fraeys
aaeef69bab
feat: Privacy and PII detection
Add privacy protection features to prevent accidental PII leakage:
- PII detection engine supporting emails, phone numbers, SSNs, credit cards
- CLI privacy command for scanning files and text
- Privacy middleware for API request/response filtering
- Suggestion utility for privacy-preserving alternatives

Integrates PII scanning into manifest validation for narrative fields.
2026-02-18 21:27:23 -05:00
Jeremie Fraeys
260e18499e
feat: Research features - narrative fields and outcome tracking
Add comprehensive research context tracking to jobs:
- Narrative fields: hypothesis, context, intent, expected_outcome
- Experiment groups and tags for organization
- Run comparison (compare command) for diff analysis
- Run search (find command) with criteria filtering
- Run export (export command) for data portability
- Outcome setting (outcome command) for experiment validation

Update queue and requeue commands to support narrative fields.
Add narrative validation to manifest validator.
Add WebSocket handlers for compare, find, export, and outcome operations.

Includes E2E tests for phase 2 features.
2026-02-18 21:27:05 -05:00
Jeremie Fraeys
a64233d4f6
fix: CLI now properly rejects unknown commands
Some checks failed
Checkout test / test (push) Successful in 6s
CI with Native Libraries / Check Build Environment (push) Successful in 11s
CI/CD Pipeline / Test (push) Failing after 5m5s
CI/CD Pipeline / Dev Compose Smoke Test (push) Has been skipped
CI/CD Pipeline / Build (push) Has been skipped
CI/CD Pipeline / Test Scripts (push) Has been skipped
CI/CD Pipeline / Security Scan (push) Failing after 4m49s
Documentation / build-and-publish (push) Failing after 24s
CI with Native Libraries / Build and Test Native Libraries (push) Failing after 14m40s
CI with Native Libraries / Build Release Libraries (push) Has been skipped
CI/CD Pipeline / Docker Build (push) Has been skipped
- Add handleUnknownCommand() helper function
- Add else clauses to 'i' and 's' switch cases
- Commands like 'invalid_command', 'infoooo', 'syncccc' now properly rejected
- Prevents silent acceptance of invalid commands
- Test TestCLICommandsE2E/CLIErrorHandling now passes
2026-02-18 16:04:37 -05:00
Jeremie Fraeys
cd2908181c
refactor(cli): reduce code duplication in WebSocket client
Add MessageBuilder struct and validation helpers to reduce duplication:

- MessageBuilder: Helper for constructing binary WebSocket messages
  - writeOpcode, writeBytes, writeU8/16/32/64
  - writeStringU8, writeStringU16 for length-prefixed strings

- Validation helpers: validateApiKeyHash, validateCommitId, validateJobName
- getStream(): Extracted common stream check pattern

Refactored 4 representative send methods to use new helpers:
- sendValidateRequestCommit, sendListJupyterPackages
- sendCancelJob, sendStatusRequest

Consolidated disconnect/close: close() now calls disconnect()

Updated response handlers to use packet.deinit():
- receiveAndHandleResponse
- receiveAndHandleDatasetResponse

Reduces ~100 lines of boilerplate duplication.
Build verified: zig build --release=fast
2026-02-18 13:56:30 -05:00
Jeremie Fraeys
14eba436bf
feat(cli): include command name in error messages and crash reports
Implement TODO in handleCommandError:
- Log command name with error for crash report context
- Display 'Error in \'{s}': {s}' instead of generic 'Error: {s}'
- Helps users identify which command failed

Build verified: zig build --release=fast
2026-02-18 13:51:13 -05:00
Jeremie Fraeys
32e65545ae
feat(cli): implement proper JSON parsing for sync progress
Use utils/json.zig helpers to parse sync progress messages:
- Add json module import
- Rename json variable to json_mode to avoid shadowing
- Parse status, progress, total fields from JSON response
- Show percentage completion for in-progress syncs
- Handle 'complete' and 'error' status codes

Build verified: zig build --release=fast
2026-02-18 13:49:01 -05:00
Jeremie Fraeys
55b4b23645
feat(cli): integrate embedded rsync for remote sync
Replace local file copy with embedded rsync binary for actual remote
synchronization to the server. The embedded rsync is extracted from
assets/ at runtime - no external dependencies required.

Changes:
- Re-add rsync_embedded.zig import
- Replace manual file copying with rsync.sync() call
- Construct remote path as api_key@host:worker_base/commit_id/files/
- Update JSON output to include commit_id

Build verified: zig build --release=fast
2026-02-18 13:45:50 -05:00
Jeremie Fraeys
c31055be30
refactor(cli): remove unused imports from sync.zig
Remove unused imports:
- rsync (commented as 'Use embedded rsync' but never used)
- storage (never referenced)

Build verified: zig build --release=fast
2026-02-18 13:39:16 -05:00
Jeremie Fraeys
999af75f39
refactor(cli): use config.getWebSocketUrl() in jupyter.zig
Replace 6 instances of inline WebSocket URL construction with the
config.getWebSocketUrl() helper method. This ensures consistent URL
formatting and reduces code duplication.

Functions updated:
- startJupyter
- stopJupyter
- removeJupyter
- listServices
- packageCommands

Build verified: zig build --release=fast
2026-02-18 13:36:03 -05:00
Jeremie Fraeys
f2f645fe21
refactor(cli): use packet.deinit() in remaining command files
Replace manual defer blocks with packet.deinit() for consistent cleanup:
- jupyter.zig: 5 locations updated (restoreJupyter, startJupyter, stopJupyter, removeJupyter, listServices, packageCommands)
- experiment.zig: 3 locations updated (executeLog, executeShow, executeDelete)
- queue.zig: 1 location updated (queueSingleJob)
- logs.zig: 1 location updated (run)

Eliminates 44 manual cleanup blocks across 4 files.
Build verified: zig build --release=fast
2026-02-18 13:33:10 -05:00
Jeremie Fraeys
29d130dcdb
refactor(cli): standardize error handling and use packet.deinit()
- Replace std.process.exit(1) with error.InvalidArgs in sync command
- Replace std.process.exit(1) with error.ValidationFailed in validate command
- Update validate.zig to use protocol.ResponsePacket.deinit() for cleanup
- Build verified: zig build --release=fast
2026-02-18 13:29:53 -05:00
Jeremie Fraeys
9517271bbb
fix(cli): remove unreachable code and unused Command enum
- Fix duplicate 'i' case in Command.fromString that was unreachable
- Remove unused Command enum entirely (dispatch uses inline comparisons)
- Build verified: zig build --release=fast
2026-02-18 13:26:18 -05:00
Jeremie Fraeys
1597c20b73
refactor(cli): consolidate shared utilities and remove code duplication
Extract common helper functions from multiple command files into shared
utility modules:

- Create cli/src/utils/json.zig with json.getString(), getInt(), getFloat(), getBool()
- Create cli/src/utils/manifest.zig with readFileAlloc(), resolvePathWithBase(),
  resolvePathById(), readJobNameFromManifest()
- Add ResponsePacket.deinit() method to net/protocol.zig for consistent cleanup
- Update info.zig, annotate.zig, narrative.zig, requeue.zig to use shared utilities
- Update utils.zig exports for new modules

Eliminates duplicate implementations of:
- jsonGetString() and jsonGetInt() in 4 files
- readFileAlloc() in 4 files
- resolveManifestPath*() functions in 4 files
- ResponsePacket cleanup defer blocks (replaced with .deinit())

Builds cleanly with zig build --release=fast
2026-02-18 13:19:40 -05:00
Jeremie Fraeys
34186675dc
refactor(cli): use config.getWebSocketUrl() helper across all commands
Replace inline WebSocket URL construction with Config.getWebSocketUrl()
helper method in all command files. This eliminates code duplication
and ensures consistent URL formatting across the CLI.

Files updated:
- annotate.zig, dataset.zig, experiment.zig, logs.zig
- narrative.zig, prune.zig, queue.zig, requeue.zig
- sync.zig, validate.zig, watch.zig

The helper properly handles ws:// vs wss:// based on port (443).
2026-02-18 13:05:43 -05:00
Jeremie Fraeys
c85575048f
refactor(cli): consolidate shared types and reduce code duplication
Extract common UserContext and authentication logic from cancel.zig and
status.zig into new utils/auth.zig module. Add CommonFlags struct to
utils/flags.zig for shared CLI flags. Add getWebSocketUrl() helper to
Config to eliminate URL construction duplication.

Changes:
- Create cli/src/utils/auth.zig with UserContext and authenticateUser()
- Create cli/src/utils/flags.zig with CommonFlags struct
- Update cancel.zig and status.zig to use shared modules
- Add getWebSocketUrl() helper to config.zig
- Export new modules from utils.zig

Reduces code duplication and improves separation of concerns in the
Zig CLI codebase.
2026-02-18 13:00:48 -05:00
Jeremie Fraeys
f9bba8a0fc
refactor(cli): reorganize queue commands and add logs test
- Reorganize queue command handlers
- Remove debug logs test file
- Add proper logs command test
2026-02-18 12:45:54 -05:00
Jeremie Fraeys
fb4c91f4c5
chore: add review workflow and test updates
- Add Windsurf review workflow configuration
- Add logs debug test for CLI
- Update main test file
2026-02-16 20:39:09 -05:00
Jeremie Fraeys
1147958e15
feat: enhance CLI with improved commands and WebSocket handling
- Refactor command structure for better organization
- Improve WebSocket client frame handling
- Add response handler improvements
- Update queue, requeue, and status commands
- Add security module for CLI authentication
2026-02-16 20:38:08 -05:00
Jeremie Fraeys
8e3fa94322
feat(cli): enhance Zig CLI with new commands and improved networking
- Add new commands: annotate, narrative, requeue
- Refactor WebSocket client into modular components (net/ws/)
- Add rsync embedded binary support
- Improve error handling and response packet processing
- Update build.zig and completions
2026-02-12 12:05:10 -05:00
Jeremie Fraeys
5ef24e4c6d feat(cli): add validate/info commands and improve protocol handling 2026-01-05 12:31:20 -05:00
Jeremie Fraeys
cd5640ebd2 Slim and secure: move scripts, clean configs, remove secrets
- Move ci-test.sh and setup.sh to scripts/
- Trim docs/src/zig-cli.md to current structure
- Replace hardcoded secrets with placeholders in configs
- Update .gitignore to block .env*, secrets/, keys, build artifacts
- Slim README.md to reflect current CLI/TUI split
- Add cleanup trap to ci-test.sh
- Ensure no secrets are committed
2025-12-07 13:57:51 -05:00
Jeremie Fraeys
b75bd24bba Add CLI jupyter command for transparent Jupyter management
- Add jupyter.zig command with start/stop/status actions
- Update main.zig to include jupyter command in CLI
- CLI now handles all Jupyter setup transparently
- Data scientists only need: ml jupyter start
- Auto-detects container runtime (Podman/Docker)
- Manages container lifecycle automatically
- Provides clear status and error messages
2025-12-06 16:07:09 -05:00
Jeremie Fraeys
83ba2f3415 Fix multi-user authentication and WebSocket issues
- Fix CLI WebSocket port (9101 vs 9103) in both status and authenticateUser
- Add researcher_user and analyst_user to server config with proper permissions
- Fix API key hashes for all users (complete 64-char SHA256)
- Enable IP whitelist with localhost and private network ranges
- Fix memory leaks in WebSocket handshake (proper key cleanup)
- Fix binary character display in server responses
- All authentication tests now pass: admin, researcher, analyst

Status: Multi-user authentication fully functional
2025-12-06 13:38:08 -05:00
Jeremie Fraeys
96dcfe6458 Add WebSocket handshake delay to fix timing issue
- Add 10ms delay after successful WebSocket handshake
- Use std.posix.nanosleep for proper timing
- This should prevent 'client sent data before handshake complete' error
- CLI WebSocket implementation improved but needs server testing

Status: WebSocket handshake timing improved, ready for testing
2025-12-06 13:24:20 -05:00
Jeremie Fraeys
4ca747bae3 Improve WebSocket handshake reading
- Fix WebSocket handshake response reading to wait for complete headers
- Increase buffer size for handshake response
- Add proper HTTP header completion detection
- Server still reports handshake issues but CLI connection improved

Status: Partial WebSocket implementation, needs further debugging
2025-12-06 13:19:53 -05:00
Jeremie Fraeys
7125dc3ab8 Partially fix API server and CLI connection
- Add Redis configuration to local config
- Fix API key format (api_keys vs apikeys)
- Update CLI to use port 9101
- Disable IP whitelist for testing
- Server now connects to Redis and authenticates
- WebSocket connection reaches server but handshake fails
- CLI needs WebSocket protocol implementation fix

Status: Server running, auth working, WebSocket handshake needs debugging
2025-12-06 13:19:07 -05:00
Jeremie Fraeys
ea15af1833 Fix multi-user authentication and clean up debug code
- Fix YAML tags in auth config struct (json -> yaml)
- Update CLI configs to use pre-hashed API keys
- Remove double hashing in WebSocket client
- Fix port mapping (9102 -> 9103) in CLI commands
- Update permission keys to use jobs:read, jobs:create, etc.
- Clean up all debug logging from CLI and server
- All user roles now authenticate correctly:
  * Admin: Can queue jobs and see all jobs
  * Researcher: Can queue jobs and see own jobs
  * Analyst: Can see status (read-only access)

Multi-user authentication is now fully functional.
2025-12-06 12:35:32 -05:00
Jeremie Fraeys
d225ea1f00 feat: implement Zig CLI with comprehensive ML experiment management
- Add modern CLI interface built with Zig for performance
- Include TUI (Terminal User Interface) with bubbletea-like features
- Implement ML experiment commands (run, status, manage)
- Add configuration management and validation
- Include shell completion scripts for bash and zsh
- Add comprehensive CLI testing framework
- Support for multiple ML frameworks and project types

CLI provides fast, efficient interface for ML experiment management
with modern terminal UI and comprehensive feature set.
2025-12-04 16:53:58 -05:00