Skip to content

[BUG] Policy source format documented inconsistently across CLI help and docs #998

@edenfunf

Description

@edenfunf

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

  1. 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)
  2. 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

  1. 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).
  2. Update the four (or five) locations to a single canonical wording.
  3. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliCLI command surface, flags, help text (cross-cutting).area/docs-sitedocs/src/content (Starlight), README, doc generation.good first issueGood for newcomerspriority/lowAccepted but not time-sensitivestatus/acceptedDirection approved, safe to start work.status/triagedInitial agentic triage complete; pending maintainer ratification (silence = approval).type/docsDocumentation change (prose, examples, generated reference).

    Type

    No type

    Projects

    Status

    In Progress

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions