Skip to content

feat(audit): propagate 5 avoided patterns to sensor rules + Agent 5#8378

Merged
HydraOps-T-rav merged 3 commits intomainfrom
pattern-propagation
Apr 21, 2026
Merged

feat(audit): propagate 5 avoided patterns to sensor rules + Agent 5#8378
HydraOps-T-rav merged 3 commits intomainfrom
pattern-propagation

Conversation

@HydraOps-T-rav
Copy link
Copy Markdown
Collaborator

Follow-up to #8377. That PR added 5 new entries to `docs/agents/avoided-patterns.md` and a planner Step 8 self-audit. Per the doc's own "Adding a new avoided pattern" section, the remaining surfaces to wire are:

  • `src/sensor_rules.py` (runtime hints on failures)
  • `.claude/commands/hf.audit-code.md` Agent 5 (convention-drift sweeps)

This PR does both.

Changes

`src/sensor_rules.py` — 3 new `Rule` entries

id trigger fires when
`private-symbol-cross-module` ErrorPattern(`"_X" is not accessed`, `reportPrivateUsage`) pyright complains about a private-by-convention name
`logger-format-typeerror` ErrorPattern(`TypeError: not enough arguments for format string`, etc.) runtime TypeError from `logger.error(value)` without a format string
`dockerfile-python-constant-drift` FileChanged(`Dockerfile*`) any Dockerfile edit — reminds about mirrored Python constants

Skipped for the two patterns that don't map cleanly to error/file triggers:

  • "test helper duplicating conftest" — requires diff analysis the sensor runtime doesn't do
  • "hardcoded path list mirroring fs state" — same reason

Those remain covered by `avoided-patterns.md` + the planner Step 8 audit + Agent 5 sweep below.

`.claude/commands/hf.audit-code.md` Phase 2 — 5 new detection bullets

Each bullet includes a concrete `rg` heuristic so the audit agent can reliably scan:

  • `rg -n "from [a-z_]+ import[^#]*\b_[a-zA-Z]"` → cross-module private imports
  • Cross-reference conftest defs vs test-file defs → test-helper duplication
  • `rg -n "logger\.(error|warning|info|debug)\(\w+\)"` → logger bare-variable first-arg
  • Grep tuple/list literals of paths sharing a parent → hardcoded path drift
  • `rg -n "for _[a-z]"` → `_name` loop vars

Test plan

  • `make quality` green: 11,038 passed, 0 failures, exit 0.
  • 31 existing sensor_enricher tests still pass (rule-count ≥ 5 assertion now sees 8; id-uniqueness holds; every new rule has a `docs/agents/` reference).

🤖 Generated with Claude Code

T-rav-Hydra-Ops added 3 commits April 21, 2026 16:56
… Agent 5

Follow-up to #8377. The 5 new avoided-patterns entries need matching hooks
in the two automated surfaces that consume the doc.

Sensor enricher (src/sensor_rules.py) — 3 new Rule entries:
- private-symbol-cross-module: pyright "_name is not accessed" trigger
- logger-format-typeerror: TypeError on malformed format strings
- dockerfile-python-constant-drift: Dockerfile* file-changed trigger

(Skipped sensor rules for the two patterns that don't map cleanly to
error/file triggers: "test helper duplicating conftest" and "hardcoded
path list mirroring fs state" rely on diff analysis the sensor runtime
doesn't do. Those remain covered by avoided-patterns.md + Agent 5 sweep.)

Audit Agent 5 (.claude/commands/hf.audit-code.md) Phase 2 — 5 new
detection bullets with concrete rg heuristics:
- Underscore-prefixed names imported across modules
- Test helpers duplicating conftest fixtures
- logger.error(value) without format string
- Hardcoded path lists mirroring filesystem state
- _name for unused loop variables
PR #8374 added `phase_skills: dict[str, list[str]]` to HydraFlowConfig and
each factory runner now reads `self._config.phase_skills` during prompt
construction. PR #8376's prompt-audit harness uses a fake config object
that raises AttributeError on unknown attributes; `phase_skills` wasn't
added to it, so every audit_prompts fixture that invokes a runner's
prompt builder failed with `AttributeError: phase_skills` under CI's
full test run (the failures didn't surface in `make quality` because
that target deselects some tests).

Mirror the existing `required_plugins: list[str] = []` convention — both
are allowlist fields that default to empty in the audit harness.
@HydraOps-T-rav HydraOps-T-rav merged commit 332565f into main Apr 21, 2026
20 checks passed
@HydraOps-T-rav HydraOps-T-rav deleted the pattern-propagation branch April 21, 2026 23:41
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.

1 participant