From 29f824d85805a3308f436aa0cf30ce215518572c Mon Sep 17 00:00:00 2001 From: AgentLab <326739730+agenticsymphony-tech@users.noreply.github.com> Date: Sat, 24 Oct 2026 03:39:18 +0000 Subject: [PATCH] Fix #2: CLI: hide the internal crash worker from public help Closes #2. Prepared by AgentLab (an AI agent system) and reviewed by its operator. --- src/commitlatch/cli.py | 5 +++-- tests/test_http_demo.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/commitlatch/cli.py b/src/commitlatch/cli.py index efbae67..63ced2f 100644 --- a/src/commitlatch/cli.py +++ b/src/commitlatch/cli.py @@ -12,7 +12,8 @@ def main(argv=None): parser = argparse.ArgumentParser(description="Explicit recovery contracts for agent actions") from . import __version__ parser.add_argument("--version", action="version", version="CommitLatch " + __version__) - commands = parser.add_subparsers(dest="command", required=True) + commands = parser.add_subparsers(dest="command", required=True, + metavar="{demo,http-demo,inspect,replay,reconcile-demo}") demo = commands.add_parser("demo", help="Run three real process-crash scenarios with test data") demo.add_argument("--directory", help="New or empty output directory") http_demo = commands.add_parser("http-demo", help="Compare recovery over loopback HTTP with a dropped response") @@ -27,7 +28,7 @@ def main(argv=None): if name == "reconcile-demo": command.add_argument("--provider-db", required=True) command.add_argument("--opaque", action="store_true") - internal = commands.add_parser("_worker", help=argparse.SUPPRESS) + internal = commands.add_parser("_worker") internal.add_argument("directory") internal.add_argument("scenario", choices=("naive", "reconciled", "opaque")) args = parser.parse_args(argv) diff --git a/tests/test_http_demo.py b/tests/test_http_demo.py index aec3f2c..e7b6f81 100644 --- a/tests/test_http_demo.py +++ b/tests/test_http_demo.py @@ -1,11 +1,14 @@ +import io import json import tempfile import unittest from concurrent.futures import ThreadPoolExecutor +from contextlib import redirect_stdout from http.client import HTTPException from pathlib import Path from urllib.error import HTTPError, URLError +from commitlatch.cli import main from commitlatch.http_demo import DemoHTTPAdapter, HTTPFixture, run_http_demo @@ -65,5 +68,15 @@ def send(_): self.assertEqual(provider.snapshot()["native_replays"], 5) +class CLIHelpTests(unittest.TestCase): + def test_help_hides_internal_worker(self): + output = io.StringIO() + with redirect_stdout(output), self.assertRaises(SystemExit): + main(["--help"]) + self.assertIn("http-demo", output.getvalue()) + self.assertNotIn("_worker", output.getvalue()) + self.assertNotIn("==SUPPRESS==", output.getvalue()) + + if __name__ == "__main__": unittest.main()