Describe the bug
The "policy source" format (the value passed to --policy / --policy-source) is documented inconsistently across at least four locations: two Click help texts in source code, and two sections of the CLI reference docs. The actual parser accepts the same set of forms in all entry points, so this is purely a documentation/help-text drift, not a user-facing surface divergence -- but the drift means users reading any single doc page get an incomplete or differently-worded list.
Discovered while investigating #994, where a broken cross-reference (Same shape as 'apm install --policy') is the surface symptom. The cross-reference cannot reliably stay correct while the underlying documented format itself drifts.
Evidence: drift across four locations
| # |
Location |
Forms listed |
| 1 |
src/apm_cli/commands/policy.py:288 (Click help for policy status --policy-source) |
'org', local file path, owner/repo, https URL |
| 2 |
src/apm_cli/commands/audit.py:440 (Click help for audit --policy) |
'org' (auto-discover), file path, URL |
| 3 |
docs/src/content/docs/reference/cli-commands.md:435 (audit --policy reference) |
'org' (auto-discover from org), file path, URL |
| 4 |
docs/src/content/docs/reference/cli-commands.md:523 (policy status --policy-source reference) |
'org', file path, URL |
Concrete consequence: owner/repo is listed in location 1 only. Locations 2-4 omit it. Users reading docs cannot discover that apm policy status --policy-source contoso/.github is valid input.
Verified locally: parser accepts owner/repo, both commands route through it
-
The parser in src/apm_cli/policy/discovery.py accepts owner/repo shorthand. An existing unit test pins this, and it passes on current main (2023e8c):
$ pytest tests/unit/policy/test_discovery.py::TestDiscoverPolicy::test_override_owner_repo -v
apm\tests\unit\policy\test_discovery.py::TestDiscoverPolicy::test_override_owner_repo PASSED [100%]
============================== 1 passed in 1.90s ==============================
Test source:
# tests/unit/policy/test_discovery.py:524-535
def test_override_owner_repo(self, mock_fetch):
mock_fetch.return_value = (VALID_POLICY_YAML, None)
with tempfile.TemporaryDirectory() as tmpdir:
result = discover_policy(
Path(tmpdir),
policy_override="contoso/.github",
no_cache=True,
)
self.assertTrue(result.found)
self.assertIn("org:", result.source)
-
Both commands route their --policy / --policy-source value through the same discover_policy() function:
audit.py:534-536: discover_policy(project_root, policy_override=policy_source, no_cache=no_cache)
policy status similarly forwards to discover_policy (covered by tests/unit/commands/test_policy_status.py:303)
So audit --policy contoso/.github and policy status --policy-source contoso/.github both succeed at the parser level. Only the help texts and docs claim otherwise.
Expected behavior
A single canonical list of accepted "policy source" forms, reflected identically in:
- The
--policy Click help on apm audit
- The
--policy-source Click help on apm policy status
- The
apm audit section of docs/src/content/docs/reference/cli-commands.md
- The
apm policy status section of the same docs file
- (Possibly)
docs/src/content/docs/enterprise/policy-reference.md, where the format is also referenced
A regression test that pins the parser's accepted set so future drift fails CI rather than silently re-introducing the inconsistency.
Suggested approach
- Read
src/apm_cli/policy/discovery.py end-to-end and enumerate the forms the parser actually accepts (the canonical set; test_override_owner_repo and siblings already cover most cases).
- Update the four (or five) locations to a single canonical wording.
- Extend the parser unit tests to lock the accepted set, so drift reappears as a test failure.
Relation to #994
#994 reports a broken cross-reference (Same shape as 'apm install --policy') and proposes redirecting it to apm audit --policy. The minimal fix for #994 will remove the broken cross-reference outright. This issue tracks the underlying drift that made the cross-reference unreliable in the first place. Per CONTRIBUTING.md ("only one concern per PR"), the two are addressed in separate PRs.
Environment
- APM version: 0.10.0 (latest
main, post-2023e8c)
- OS: N/A (documentation / help-text drift, not platform-specific)
Describe the bug
The "policy source" format (the value passed to
--policy/--policy-source) is documented inconsistently across at least four locations: two Click help texts in source code, and two sections of the CLI reference docs. The actual parser accepts the same set of forms in all entry points, so this is purely a documentation/help-text drift, not a user-facing surface divergence -- but the drift means users reading any single doc page get an incomplete or differently-worded list.Discovered while investigating #994, where a broken cross-reference (
Same shape as 'apm install --policy') is the surface symptom. The cross-reference cannot reliably stay correct while the underlying documented format itself drifts.Evidence: drift across four locations
src/apm_cli/commands/policy.py:288(Click help forpolicy status --policy-source)'org', local file path,owner/repo, https URLsrc/apm_cli/commands/audit.py:440(Click help foraudit --policy)'org'(auto-discover), file path, URLdocs/src/content/docs/reference/cli-commands.md:435(audit--policyreference)'org'(auto-discover from org), file path, URLdocs/src/content/docs/reference/cli-commands.md:523(policy status--policy-sourcereference)'org', file path, URLConcrete consequence:
owner/repois listed in location 1 only. Locations 2-4 omit it. Users reading docs cannot discover thatapm policy status --policy-source contoso/.githubis valid input.Verified locally: parser accepts
owner/repo, both commands route through itThe parser in
src/apm_cli/policy/discovery.pyacceptsowner/reposhorthand. An existing unit test pins this, and it passes on currentmain(2023e8c):Test source:
Both commands route their
--policy/--policy-sourcevalue through the samediscover_policy()function:audit.py:534-536:discover_policy(project_root, policy_override=policy_source, no_cache=no_cache)policy statussimilarly forwards todiscover_policy(covered bytests/unit/commands/test_policy_status.py:303)So
audit --policy contoso/.githubandpolicy status --policy-source contoso/.githubboth succeed at the parser level. Only the help texts and docs claim otherwise.Expected behavior
A single canonical list of accepted "policy source" forms, reflected identically in:
--policyClick help onapm audit--policy-sourceClick help onapm policy statusapm auditsection ofdocs/src/content/docs/reference/cli-commands.mdapm policy statussection of the same docs filedocs/src/content/docs/enterprise/policy-reference.md, where the format is also referencedA regression test that pins the parser's accepted set so future drift fails CI rather than silently re-introducing the inconsistency.
Suggested approach
src/apm_cli/policy/discovery.pyend-to-end and enumerate the forms the parser actually accepts (the canonical set;test_override_owner_repoand siblings already cover most cases).Relation to #994
#994 reports a broken cross-reference (
Same shape as 'apm install --policy') and proposes redirecting it toapm audit --policy. The minimal fix for #994 will remove the broken cross-reference outright. This issue tracks the underlying drift that made the cross-reference unreliable in the first place. Per CONTRIBUTING.md ("only one concern per PR"), the two are addressed in separate PRs.Environment
main, post-2023e8c)