docs(agents): 5 new avoided patterns + planner self-audit step#8377
Merged
HydraOps-T-rav merged 2 commits intomainfrom Apr 21, 2026
Merged
docs(agents): 5 new avoided patterns + planner self-audit step#8377HydraOps-T-rav merged 2 commits intomainfrom
HydraOps-T-rav merged 2 commits intomainfrom
Conversation
added 2 commits
April 21, 2026 15:05
Retrospective of PR #8374/#8375 surfaced five recurring anti-patterns that the plan review caught repeatedly. Document each in the canonical `docs/agents/avoided-patterns.md` (the sensor enricher and audit agents already read this file) and add a Planning-Steps self-audit reference so the planner phase catches them BEFORE emitting a plan. New patterns: - Underscore-prefixed names imported across modules - Writing a new test helper without checking conftest - logger.error(value) without a format string - Hardcoded path lists that duplicate filesystem state - _name for unused loop variables (prefer bare _) Catching these at plan-writing time prevents the agent-review-fix loop cost observed in PR #8374 (8 fix commits beyond the initial 8 task commits).
…teps block Adding the new step 8 (self-audit against avoided-patterns.md) grew the planner prompt baseline by ~650 chars. The truncation test's `< 10_000` sanity bound was tight; bump to 11_000. Semantic is unchanged — "…(truncated)" marker assertion still verifies body truncation works and the prompt remains well under the original 20k body size.
2 tasks
HydraOps-T-rav
added a commit
that referenced
this pull request
Apr 21, 2026
…8378) * feat(audit): propagate 5 new avoided patterns to sensor rules + audit 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 * fix(audit): add phase_skills to audit_prompts fake config 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. --------- Co-authored-by: T-rav-Hydra-Ops <t@koderex.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #8374 / #8375. Translates the session-level retrospective insights into the factory's persistent workflow.
Why
PR #8374 went through 8 task commits + 8 fix commits (review→fix→re-review). Most fix commits addressed the same class of issues that `docs/agents/avoided-patterns.md` already documents — private symbols crossing modules, missing conftest reuse, unsafe logger formatting, etc. Writing these into the canonical pattern doc means the planner phase (and any sensor/audit agent reading the doc) catches them at plan-writing time instead of in code-review-fix loops.
Changes
`docs/agents/avoided-patterns.md` — 5 new sections in the same Wrong / Right / Why / How-to-check format as existing entries:
`src/planner.py` — add Step 8 to the planner's Planning Steps section, instructing it to self-audit the plan against `avoided-patterns.md` BEFORE emitting. Catching these in a plan is orders of magnitude cheaper than catching them in agent code review.
`tests/test_planner.py` — bump `test_build_prompt_truncates_long_body` threshold from `< 10_000` to `< 11_000`. The new Step 8 grew the planner prompt baseline by ~650 chars; the truncation semantic ("…(truncated)" marker + body dramatically smaller than original 20k) is unchanged.
Test plan
Follow-ups (not in this PR)
Per `avoided-patterns.md`'s own "Adding a new avoided pattern" guidance, consider:
Both are separate concerns — doing them requires understanding those subsystems in depth. Filed as mental follow-ups; happy to do either as a separate PR if desired.
🤖 Generated with Claude Code