Repository navigation
fix(flow): stable --key help so the CLI snapshot does not depend on HOME - #2572
Conversation
Since #2561, `openadapt-flow exceptions answer --key` put the expanded home directory into its help text each time the parser is built. The CLI snapshot test formats help first and replaces the home with <HOME> after, so argparse wrapped the line by the length of whatever HOME was current. Flow tests that point HOME at a long temporary directory (txplan, hooks, sealed-at-rest) made the snapshot pass or fail by test order on CI. The help now says `~/.openadapt/approver/desktop-approver.pem`, like `--key-dir` already does. The default itself is still computed when the command runs (`_key_default()`), so #2561's behaviour is unchanged. The snapshot is regenerated (only that help string changes), and a new test builds the parser under a long HOME and asserts no scrubbed help or argument changes.
Independent adversarial review: APPROVEFrom: Claude A fresh Claude reviewer looked at the diff and the test, not at the author's conclusions.
|
|
From: Claude Author declaration: Claude authored this PR. It touches no path in .github/agent-safety-manifest.json. |
Independent adversarial review: APPROVEFrom: Grok Head confirmed open and unchanged versus this SHA. Three files: This is the right fix for the latent The snapshot change is isolated to that one help string (including the expected wrap at I am approving at this head. I am not merging. |
Since #2561,
openadapt-flow exceptions answer --keywrites the expanded home directory into its help text each time the parser is built.packages/flow/tests/test_cli_surface.pyformats the help first and only then replaces the home with<HOME>, so argparse wraps the line by the length of whatever HOME is set at that moment.Several Flow tests point HOME at a long temporary directory (test_txplan, test_hooks_e2e, test_sealed_at_rest). So the snapshot passes or fails depending on test order and on the machine. On CI it fails (flow core unit, e.g. on #2540). Regenerating the snapshot can't fix this: it just records one machine's HOME.
Change
--keyhelp is now a fixed string,(default: ~/.openadapt/approver/desktop-approver.pem), the same way--key-dirshows~/.openadapt/jit._key_default(), computed when the command runs, so fix(flow): compute exceptions --key default from Path.home() at use time #2561's fix stands.packages/flow/tests/fixtures/cli_surface.jsonis regenerated (OPENADAPT_WRITE_CLI_SURFACE=1 pytest tests/test_cli_surface.py, Python 3.12). Only that help string changes.test_help_does_not_depend_on_home: it builds the parser under a long temporary HOME and asserts that every scrubbed help text and every argument is unchanged.Checks
tests/test_cli_surface.py: 5 passed, run once during regeneration.ruff checkandruff format --checkpass on the changed files.