Skip to content

Add units to reachability timeout/memory-limit flags#236

Open
Martin Torp (mtorp) wants to merge 1 commit into
mainfrom
martin/cli-reachability-units
Open

Add units to reachability timeout/memory-limit flags#236
Martin Torp (mtorp) wants to merge 1 commit into
mainfrom
martin/cli-reachability-units

Conversation

@mtorp

Copy link
Copy Markdown
Contributor

What

Adds optional units to the reachability resource flags. The reachability engine (@coana-tech/cli) owns the unit grammar, parsing, and validation; the Python CLI passes the value through verbatim, so there is a single source of truth.

  • --reach-analysis-timeout (alias --reach-timeout): optional duration unit s / m / h — e.g. 90s, 10m, 1h.
  • --reach-analysis-memory-limit (alias --reach-memory-limit): optional size unit MB / GB, case-insensitive — e.g. 512MB, 8GB.
  • --reach-concurrency is unchanged (unitless, >= 1).

How

  • Drop type=int on the four flags → accept raw strings; dataclass fields reach_analysis_timeout / reach_analysis_memory_limit become Optional[str]. Values forward verbatim to coana --analysis-timeout / --memory-limit.
  • A defensive str() is kept at the coana forward point: config-file values bypass argparse's type= converter via set_defaults, so a JSON number can arrive as an int; str() is idempotent for unit strings ("10m""10m") and just guarantees subprocess receives a string. This is not unit parsing.
  • The forward guard uses if x is not None (instead of truthiness) so an explicit empty string flows through and triggers coana's own error, rather than being silently dropped.
  • Bump pinned DEFAULT_COANA_CLI_VERSION 15.3.2415.5.0, which ships the unit parser.

Backward compatibility

Bare numbers still work exactly as before — seconds for the timeout, MB for the memory limit. This legacy form is no longer documented but continues to function.

Docs / tests

  • docs/cli-reference.md table rows updated (units + new pin); help text mirrors coana's wording.
  • CHANGELOG.md entry added.
  • Unit tests cover unit-bearing values, bare-int back-compat, and int→str coercion. Full unit suite green (341 passed).

Part of the cross-repo "CLI reachability units" effort, aligned with the Coana CLI (which shipped the parser in @coana-tech/cli 15.5.0) and socket-cli.

--reach-analysis-timeout now accepts an optional duration unit (s/m/h, e.g.
90s, 10m, 1h) and --reach-analysis-memory-limit an optional size unit (MB/GB,
case-insensitive, e.g. 512MB, 8GB). Values are forwarded verbatim to the
reachability engine (@coana-tech/cli), which owns parsing and validation, so
the unit grammar and error messages live in a single source of truth.

To pass values through unchanged, the four flags (incl. the hidden
--reach-timeout/--reach-memory-limit aliases) drop type=int and accept raw
strings; the dataclass fields become Optional[str]. A defensive str() is kept
at the coana forward point so config-file JSON numbers (which bypass argparse's
type converter via set_defaults) still reach subprocess as strings, and the
guard uses `is not None` so an explicit empty string flows through and triggers
coana's own error rather than being silently dropped.

Bare numbers remain accepted for backward compatibility (seconds for the
timeout, MB for the memory limit) but are no longer documented. Bumped the
pinned @coana-tech/cli version to 15.5.0, which ships the unit parser.

Docs (cli-reference) and CHANGELOG updated; unit tests cover unit-bearing
values, bare-int back-compat, and int coercion.
@mtorp Martin Torp (mtorp) requested a review from a team as a code owner June 18, 2026 11:26
@mtorp Martin Torp (mtorp) deployed to socket-firewall June 18, 2026 11:27 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown

🚀 Preview package published!

Install with:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple socketsecurity==2.4.11.dev1

Docker image: socketdev/cli:pr-236

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