Skip to content

feat: support boolean values for retry configuration#170

Merged
jdx merged 3 commits intomainfrom
feat/retry-bool
Jan 19, 2026
Merged

feat: support boolean values for retry configuration#170
jdx merged 3 commits intomainfrom
feat/retry-bool

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Jan 19, 2026

Summary

  • Allows retry = true for infinite retries (u32::MAX) in pitchfork.toml
  • Allows retry = false for no retries (0)
  • Numeric values continue to work as before
  • Display trait shows "infinite" for infinite retries in TUI

Example Config

[daemons.api]
run = "npm start"
retry = true  # Retry forever on failure

[daemons.once]
run = "echo done"
retry = false  # Never retry

Changes

  • Added Retry struct with custom serde to accept bool or u32
  • Updated all usages across CLI, TUI, web routes, and supervisor
  • Added comprehensive tests for boolean retry values

Test plan

  • cargo nextest run - All 77 tests pass
  • cargo clippy --all-targets --all-features -- -D warnings - No warnings
  • Added test_retry_boolean_values test for boolean retry deserialization/serialization

🤖 Generated with Claude Code


Note

Adds flexible retry configuration and propagates it across the stack.

  • Introduces Retry type in pitchfork_toml with custom serde: accepts boolean or integer (true = infinite, false/0 = none); implements count(), is_infinite(), and Display (shows "infinite")
  • Replaces numeric retry usages with retry.count() in CLI (start, restart, config add), TUI, web routes, and supervisor; uses saturating_add(1) for attempt calculation when infinite
  • Updates docs (docs/guides/auto-restart.md, docs/reference/configuration.md) and JSON Schema (docs/public/schema.json) to define Retry and document boolean support
  • Adds tests including test_retry_boolean_values and updates existing tests to use Retry

Written by Cursor Bugbot for commit e7f6176. This will update automatically on new commits. Configure here.

Allows `retry = true` for infinite retries and `retry = false` for no
retries, in addition to numeric values.

- Added `Retry` struct with custom serde to accept bool or u32
- `true` = u32::MAX (infinite retries), `false` = 0 (no retries)
- Display trait shows "infinite" for infinite retries
- Added `is_infinite()` and `count()` methods
- Updated all usages across CLI, TUI, web routes, and supervisor

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 19, 2026 16:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for boolean values in retry configuration, allowing users to specify retry = true for infinite retries or retry = false for no retries, in addition to numeric values. The implementation introduces a Retry wrapper struct with custom serialization/deserialization logic and updates all usages across the codebase to use the new .count() accessor method.

Changes:

  • Introduced Retry struct with serde support for boolean and numeric values
  • Updated all retry field accesses to use .count() method
  • Added Display trait showing "infinite" for infinite retries in TUI

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/pitchfork_toml.rs Introduced Retry struct with custom serde implementation to accept bool or u32
tests/test_pitchfork_toml.rs Updated existing tests to use .count() accessor and added comprehensive boolean retry tests
src/tui/ui.rs Updated TUI display to show "infinite" for infinite retries and use .count() accessor
src/tui/app.rs Updated retry field access to use .count() method
src/web/routes/daemons.rs Updated retry field access to use .count() method
src/supervisor.rs Updated retry field access to use .count() method
src/cli/start.rs Updated retry field access to use .count() method
src/cli/restart.rs Updated retry field access to use .count() method
src/cli/config/add.rs Updated daemon creation to use Retry::default()
src/deps.rs Updated test daemon creation to use Retry::default()
docs/public/schema.json Updated JSON schema to reference new Retry type definition

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +168 to +170
"type": "integer",
"format": "uint32",
"minimum": 0
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSON schema for Retry only declares it as an integer type, but the description indicates it should also accept boolean values. The schema should use oneOf to allow both boolean and integer types to accurately reflect the serde implementation.

Suggested change
"type": "integer",
"format": "uint32",
"minimum": 0
"oneOf": [
{
"type": "boolean"
},
{
"type": "integer",
"format": "uint32",
"minimum": 0
}
]

Copilot uses AI. Check for mistakes.
Comment on lines +625 to +626
raw.contains("retry = 0") || raw.contains("retry = false"),
"zero retry should serialize as 0 or false"
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test accepts both 'retry = 0' and 'retry = false' as valid serialization for zero retries, but based on the Serialize implementation (line 218 in pitchfork_toml.rs), false serializes as 0, not as 'false'. This assertion should only check for 'retry = 0' to match the actual implementation behavior.

Suggested change
raw.contains("retry = 0") || raw.contains("retry = false"),
"zero retry should serialize as 0 or false"
raw.contains("retry = 0"),
"zero retry should serialize as 0"

Copilot uses AI. Check for mistakes.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Use saturating_add(1) instead of + 1 when calculating max_attempts.
When retry = true (u32::MAX), adding 1 would overflow. saturating_add
caps at u32::MAX, effectively allowing infinite retries.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jdx jdx merged commit af7085e into main Jan 19, 2026
4 checks passed
@jdx jdx deleted the feat/retry-bool branch January 19, 2026 16:47
@jdx jdx mentioned this pull request Jan 19, 2026
jdx added a commit that referenced this pull request Jan 19, 2026
## 🤖 New release

* `pitchfork-cli`: 1.0.2 -> 1.1.0

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [1.1.0](v1.0.2...v1.1.0) -
2026-01-19

### Added

- add file watching to auto-restart daemons
([#165](#165))
- support boolean values for retry configuration
([#170](#170))
- disable web UI by default
([#172](#172))
- auto-generate JSON schema from Rust types
([#167](#167))

### Fixed

- improve cron watcher granularity for sub-minute schedules
([#163](#163))
- improve log file position tracking accuracy
([#164](#164))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Releases `pitchfork-cli` v1.1.0 and syncs version across `Cargo.toml`,
`Cargo.lock`, `docs/cli/*`, and `pitchfork.usage.kdl`.
> 
> - **Added**: file watching to auto-restart daemons; boolean support
for retry config; web UI disabled by default; JSON schema generation
from Rust types
> - **Fixed**: improved cron watcher granularity (sub-minute); more
accurate log file position tracking
> - Updated `CHANGELOG.md` with 1.1.0 notes
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
2e6d4c6. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants