feat: accept the full compose-go duration grammar for healthcheck interval#68
Merged
Conversation
…green " 1h " never demonstrated the old .strip()-based interval_seconds defect -- the old parser had no h unit, so it rejected " 1h " regardless of stripping. " 5s " is the genuine demonstrator: the old parser stripped it to "5s" and silently accepted it, while Docker refuses any whitespace in a duration.
_INTERVAL_DURATION's trailing $ matched before a trailing newline in Python's non-MULTILINE mode, so a YAML block scalar like `interval: |\n 5s\n` was wrongly accepted as 5s even though `docker compose config` rejects "5s\n" outright. Switch to \Z, which anchors only at the true end of the string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rewrites
healthcheck.interval_secondsto parse the full compose-go duration grammar the waydocker compose configv5.1.2 does — closing the compound/hour healthcheck-duration over-reject — and closes two hard-rule false greens found along the way.Design and rationale:
planning/changes/2026-07-16.03-healthcheck-duration-grammar.md.What changed
interval_secondsnow parses the complete compose-go duration grammar → whole seconds: all units incl.d(days) andw(weeks), compound (1h30m), fractional (1.5d), and sign (-1h).intervalpaces compose2pod's ownwait_healthyloop and never reaches podman, so it can honor the full set.timeout/start_period(emitted verbatim to podman's Go-parser--health-*, nod/w) are unchanged — a legitimate refusal under rule two..strip(). Padded durations (interval: " 5s ") were accepted while Docker rejects all whitespace — a hard-rule violation the flat matrix never probed (interval is nested). Guarded by aboth-rejectconformance corpus doc using a genuine demonstrator (a value the old strip-parser accepted).$, which in Python matches before a trailing\n, sointerval: |block scalars ("5s\n") slipped through. Switched to\Z; guarded by a block-scalar corpus doc.math.isfinitebeforeint()), so a giant duration raises cleanly.Verification
just lint-ci,just check-planningclean.healthcheck_compound_duration/healthcheck_hour_durationflip over-reject → conformant (with dedicatedboth-acceptassertions); the two new false-green guards areboth-reject. Over-rejection count 6 → 4.Follow-up (separate change)
The trailing-
\n$-vs-\Zflaw is systemic across the other regex-anchoredvalues.pygrammars (_SIZE,_DURATION,_PORT,_STRICT_INT_STRING—mem_limit,ports,timeout, etc.), all pre-existing. Scoped out of this PR by design; a dedicated change will close the class.🤖 Generated with Claude Code