job need bool field "isprocess" #22

Closed
opened 2026-03-21 16:21:41 +00:00 by despiegk · 3 comments
Owner

once and when exit 0 its ok

we should have this bookean and hero_proc needs to be adjusted like this

also all UI

this is a big change plan carefully

Check all result codes

fix openrpc spec

fix UI
fix client cli

when we run something ling term it needs to be active the hero_proc can check for that, if its nto running then its in erroro and should reflect as such

once and when exit 0 its ok we should have this bookean and hero_proc needs to be adjusted like this also all UI this is a big change plan carefully Check all result codes fix openrpc spec fix UI fix client cli when we run something ling term it needs to be active the hero_proc can check for that, if its nto running then its in erroro and should reflect as such
Author
Owner

Implementation Spec for Issue #22is_process Boolean Field

Objective

Add an is_process boolean field to jobs that distinguishes between one-shot jobs (run once, exit 0 = success) and long-running process jobs (should stay running; if not running, it is an error).

Requirements

  • Add is_process: bool field to Job struct (default: false)
  • Add is_process to JobSummary for list views
  • Add is_process to ActionSpec so it can be set at the action level
  • SQLite schema migration for existing databases
  • Update OpenRPC spec with the new field
  • Supervisor: process jobs that exit (even code 0) → Failed
  • Supervisor: liveness check for process jobs in poll loop
  • Service status: account for process vs one-shot semantics
  • UI: show type badge, add toggle to creation form
  • CLI: add --process flag to job create

Files to Modify

File Description
crates/hero_proc_lib/src/db/jobs/model.rs Job/JobSummary structs, SQLite schema, CRUD
crates/hero_proc_lib/src/db/actions/model.rs ActionSpec struct
crates/hero_proc_server/openrpc.json API specification
crates/hero_proc_server/openrpc.client.generated.rs Regenerated client
crates/hero_proc_server/src/supervisor/executor.rs Exit code handling
crates/hero_proc_server/src/supervisor/mod.rs Liveness check in poll loop
crates/hero_proc_server/src/rpc/job.rs RPC handlers
crates/hero_proc_server/src/rpc/service.rs Service handlers
crates/hero_proc_ui/static/js/dashboard.js UI rendering
crates/hero_proc_ui/templates/index.html Table headers
crates/hero_proc/src/cli/args.rs CLI arguments
crates/hero_proc/src/cli/commands.rs CLI commands

Implementation Plan (10 Steps)

Step 1: Add is_process to ActionSpec

  • File: actions/model.rs
  • Dependencies: none

Step 2: Add is_process to Job struct + SQLite persistence

  • File: jobs/model.rs
  • Dependencies: none

Step 3: Update supervisor executor for process job semantics

  • File: supervisor/executor.rs
  • Dependencies: Steps 1-2

Step 4: Add liveness check in supervisor poll loop

  • File: supervisor/mod.rs
  • Dependencies: Steps 1-2

Step 5: Update RPC handlers

  • Files: rpc/job.rs, rpc/service.rs
  • Dependencies: Steps 1-2

Step 6: Update OpenRPC specification

  • File: openrpc.json
  • Dependencies: none

Step 7: Regenerate client code

  • Dependencies: Step 6

Step 8: Update CLI

  • Files: cli/args.rs, cli/commands.rs
  • Dependencies: Step 6-7

Step 9: Update UI

  • Files: dashboard.js, index.html
  • Dependencies: Step 6

Step 10: Add tests

  • Dependencies: Steps 1-2

Acceptance Criteria

  • Job struct has is_process: bool defaulting to false
  • JobSummary and ActionSpec include is_process
  • SQLite migration for existing databases
  • Process jobs that exit (even code 0) → Failed
  • Liveness check detects dead process jobs
  • OpenRPC spec updated
  • UI shows type badge and creation toggle
  • CLI --process flag works
  • All existing tests pass

Notes

  • Backward compatible: existing jobs default to is_process=false
  • Retry policy still applies to process jobs
  • Generated client updated automatically via openrpc_client! macro
## Implementation Spec for Issue #22 — `is_process` Boolean Field ### Objective Add an `is_process` boolean field to jobs that distinguishes between **one-shot jobs** (run once, exit 0 = success) and **long-running process jobs** (should stay running; if not running, it is an error). ### Requirements - Add `is_process: bool` field to `Job` struct (default: `false`) - Add `is_process` to `JobSummary` for list views - Add `is_process` to `ActionSpec` so it can be set at the action level - SQLite schema migration for existing databases - Update OpenRPC spec with the new field - **Supervisor**: process jobs that exit (even code 0) → `Failed` - **Supervisor**: liveness check for process jobs in poll loop - **Service status**: account for process vs one-shot semantics - **UI**: show type badge, add toggle to creation form - **CLI**: add `--process` flag to `job create` ### Files to Modify | File | Description | |------|-------------| | `crates/hero_proc_lib/src/db/jobs/model.rs` | Job/JobSummary structs, SQLite schema, CRUD | | `crates/hero_proc_lib/src/db/actions/model.rs` | ActionSpec struct | | `crates/hero_proc_server/openrpc.json` | API specification | | `crates/hero_proc_server/openrpc.client.generated.rs` | Regenerated client | | `crates/hero_proc_server/src/supervisor/executor.rs` | Exit code handling | | `crates/hero_proc_server/src/supervisor/mod.rs` | Liveness check in poll loop | | `crates/hero_proc_server/src/rpc/job.rs` | RPC handlers | | `crates/hero_proc_server/src/rpc/service.rs` | Service handlers | | `crates/hero_proc_ui/static/js/dashboard.js` | UI rendering | | `crates/hero_proc_ui/templates/index.html` | Table headers | | `crates/hero_proc/src/cli/args.rs` | CLI arguments | | `crates/hero_proc/src/cli/commands.rs` | CLI commands | ### Implementation Plan (10 Steps) #### Step 1: Add `is_process` to ActionSpec - File: `actions/model.rs` - Dependencies: none #### Step 2: Add `is_process` to Job struct + SQLite persistence - File: `jobs/model.rs` - Dependencies: none #### Step 3: Update supervisor executor for process job semantics - File: `supervisor/executor.rs` - Dependencies: Steps 1-2 #### Step 4: Add liveness check in supervisor poll loop - File: `supervisor/mod.rs` - Dependencies: Steps 1-2 #### Step 5: Update RPC handlers - Files: `rpc/job.rs`, `rpc/service.rs` - Dependencies: Steps 1-2 #### Step 6: Update OpenRPC specification - File: `openrpc.json` - Dependencies: none #### Step 7: Regenerate client code - Dependencies: Step 6 #### Step 8: Update CLI - Files: `cli/args.rs`, `cli/commands.rs` - Dependencies: Step 6-7 #### Step 9: Update UI - Files: `dashboard.js`, `index.html` - Dependencies: Step 6 #### Step 10: Add tests - Dependencies: Steps 1-2 ### Acceptance Criteria - [ ] `Job` struct has `is_process: bool` defaulting to `false` - [ ] `JobSummary` and `ActionSpec` include `is_process` - [ ] SQLite migration for existing databases - [ ] Process jobs that exit (even code 0) → `Failed` - [ ] Liveness check detects dead process jobs - [ ] OpenRPC spec updated - [ ] UI shows type badge and creation toggle - [ ] CLI `--process` flag works - [ ] All existing tests pass ### Notes - Backward compatible: existing jobs default to `is_process=false` - Retry policy still applies to process jobs - Generated client updated automatically via `openrpc_client!` macro
Author
Owner

Implementation Complete

Changes Made

Core Model (hero_proc_lib)

  • Added is_process: bool field to Job, JobSummary, and ActionSpec structs
  • SQLite schema updated with is_process INTEGER NOT NULL DEFAULT 0 column + migration
  • All CRUD operations (insert, update, get, list, row_to_job) updated

Supervisor (hero_proc_server)

  • Executor: Process jobs that exit with code 0 are now marked Failed ("process exited unexpectedly") instead of Succeeded
  • Liveness check: New check_process_liveness() runs every tick — detects dead process jobs and marks them Failed
  • Recovery: recover_running_jobs() uses descriptive error for process jobs on restart

RPC Handlers

  • job.create: Propagates is_process from ActionSpec to Job
  • job.retry: Preserves is_process from original job
  • service.start / service.start_all: Propagates is_process from action spec

OpenRPC Spec

  • Added is_process boolean to Job, JobSummary, and ActionSpec schemas
  • Generated client updated

CLI

  • Added --process flag to job create and add job commands

UI

  • Jobs table: New "Type" column with process (blue) / oneshot (gray) badges
  • Job detail panel: Shows type badge
  • Job creation form: "Long-running process" checkbox

Test Results

  • 394 passed, 0 failed, 16 ignored
  • All existing tests continue to pass
  • Backward compatible: existing jobs default to is_process=false
## Implementation Complete ### Changes Made **Core Model (`hero_proc_lib`)** - Added `is_process: bool` field to `Job`, `JobSummary`, and `ActionSpec` structs - SQLite schema updated with `is_process INTEGER NOT NULL DEFAULT 0` column + migration - All CRUD operations (insert, update, get, list, row_to_job) updated **Supervisor (`hero_proc_server`)** - **Executor**: Process jobs that exit with code 0 are now marked `Failed` ("process exited unexpectedly") instead of `Succeeded` - **Liveness check**: New `check_process_liveness()` runs every tick — detects dead process jobs and marks them `Failed` - **Recovery**: `recover_running_jobs()` uses descriptive error for process jobs on restart **RPC Handlers** - `job.create`: Propagates `is_process` from ActionSpec to Job - `job.retry`: Preserves `is_process` from original job - `service.start` / `service.start_all`: Propagates `is_process` from action spec **OpenRPC Spec** - Added `is_process` boolean to `Job`, `JobSummary`, and `ActionSpec` schemas - Generated client updated **CLI** - Added `--process` flag to `job create` and `add job` commands **UI** - Jobs table: New "Type" column with `process` (blue) / `oneshot` (gray) badges - Job detail panel: Shows type badge - Job creation form: "Long-running process" checkbox ### Test Results - **394 passed, 0 failed**, 16 ignored - All existing tests continue to pass - Backward compatible: existing jobs default to `is_process=false`
Author
Owner

Implementation committed: 8dd033c

Browse: 8dd033c

Implementation committed: `8dd033c` Browse: https://forge.ourworld.tf/lhumina_code/hero_proc/commit/8dd033c
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_proc#22
No description provided.