Skip to content

feat(rules): add enterprise-patterns rule covering Fowler PEAA (#1753)#1762

Merged
rjmurillo-bot merged 1 commit into
mainfrom
feat/1753-autonomous
Apr 25, 2026
Merged

feat(rules): add enterprise-patterns rule covering Fowler PEAA (#1753)#1762
rjmurillo-bot merged 1 commit into
mainfrom
feat/1753-autonomous

Conversation

@rjmurillo-bot

Copy link
Copy Markdown
Collaborator

Pull Request

Summary

Adds .claude/rules/enterprise-patterns.md (~11KB) covering five patterns from Martin Fowler's Patterns of Enterprise Application Architecture (PEAA) that recur in this codebase: Repository, Unit of Work, Data Mapper, Service Layer, and Identity Map. The rule reinforces patterns the codebase already uses implicitly so workers extend existing seams rather than introduce competing abstractions.

Specification References

Type Reference Description
Issue Closes #1753 Add Claude rules: enterprise-patterns (repository, unit-of-work, service layer)

Changes

  • Add .claude/rules/enterprise-patterns.md with frontmatter (description, alwaysApply: false) and sections: Core Vocabulary, Repository, Unit of Work, Data Mapper, Service Layer, Identity Map, Pattern Selection, Anti-Patterns, Boundaries with Existing Codebase, Quick Self-Review.
  • Cover all five patterns from the issue spec; trim DTO assembly, remote facade, transaction script (covered in unified rules) per issue note.
  • Tie the rule to ai-agents seams: orchestrator as Service Layer, session management as Repository for session state, memory systems as repositories of long-lived knowledge.
  • Anti-Patterns section captures Anemic Domain Model, Smart UI/Skill, Repository-as-DAO, ambient transactions, cross-aggregate transactions, pattern stacking.
  • Add session log .agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json per ADR-007 / SESSION-PROTOCOL.

alwaysApply: false is intentional. Unlike code-quality (everyday fundamentals applied on every edit), enterprise patterns are situational. The description lets agents pull the rule when persistence, transactional, or orchestration code changes.

Type of Change

  • New feature (non-breaking change adding functionality)
  • Documentation update

Testing

  • No testing required (rules markdown only)
  • markdownlint-cli2 .claude/rules/enterprise-patterns.md reports zero new errors. The 21 errors reported by repo-wide lint are pre-existing in unrelated agent template files.
  • JSON session log validates with python3 -c "import json; json.load(open(...))".

Agent Review

Security Review

  • No security-critical changes in this PR

Other Agent Reviews

  • N/A — content-only rule file. Issue body served as the full spec.

Checklist

  • Code follows project style guidelines (markdownlint-cli2)
  • Self-review completed
  • Comments added for complex logic (N/A; pure markdown)
  • Documentation updated (this PR is the doc)
  • No new warnings introduced

Related Issues

Fixes #1753

Add `.claude/rules/enterprise-patterns.md` (~11KB) covering Repository,
Unit of Work, Data Mapper, Service Layer, and Identity Map patterns from
Martin Fowler's Patterns of Enterprise Application Architecture.

The rule reinforces patterns the codebase already uses implicitly so
workers extend existing seams (orchestrator, session management, memory
systems) rather than introduce competing abstractions. Frontmatter sets
alwaysApply false; the rule is agent-requestable when persistence,
transactional, or orchestration code changes.

Add session log per ADR-007 / SESSION-PROTOCOL.

Fixes #1753

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the enhancement New feature or request label Apr 25, 2026
@rjmurillo-bot rjmurillo-bot enabled auto-merge (squash) April 25, 2026 12:24
@github-actions

Copy link
Copy Markdown
Contributor

PR Validation Report

Tip

Status: PASS

Description Validation

Check Status
Description matches diff PASS

PR Standards

Check Status
Issue linking keywords PASS
Template compliance PASS

QA Validation

Check Status
Code changes detected False
QA report exists N/A

Powered by PR Validation workflow

@github-actions

Copy link
Copy Markdown
Contributor

Session Protocol Compliance Report

Tip

Overall Verdict: PASS

All session protocol requirements satisfied.

What is Session Protocol?

Session logs document agent work sessions and must comply with RFC 2119 requirements:

  • MUST: Required for compliance (blocking failures)
  • SHOULD: Recommended practices (warnings)
  • MAY: Optional enhancements

See .agents/SESSION-PROTOCOL.md for full specification.

Compliance Summary

Session File Verdict MUST Failures
sessions-2026-04-25-session-1753-enterprise-patterns-rules.md ✅ COMPLIANT 0

Detailed Validation Results

Click each session to see the complete validation report with specific requirement failures.

📄 sessions-2026-04-25-session-1753-enterprise-patterns-rules

=== Session Validation ===
File: /home/runner/work/ai-agents/ai-agents/.agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json

[PASS] Session log is valid


✨ Zero-Token Validation

This validation uses deterministic script analysis instead of AI:

  • Zero tokens consumed (previously 300K-900K per debug cycle)
  • Instant feedback - see exact failures in this summary
  • No artifact downloads needed to diagnose issues
  • 10x-100x faster debugging

Powered by validate_session_json.py

📊 Run Details
Property Value
Run ID 24930837285
Files Checked 1
Validation Method Deterministic script analysis

Powered by Session Protocol Validator workflow

@coderabbitai coderabbitai Bot added documentation Improvements or additions to documentation agent-orchestrator Task coordination agent agent-memory Context persistence agent labels Apr 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AI Quality Gate Review

Warning

⚠️ Final Verdict: WARN

Walkthrough

This PR was reviewed by six AI agents in parallel, analyzing different aspects of the changes:

  • Security Agent: Scans for vulnerabilities, secrets exposure, and security anti-patterns
  • QA Agent: Evaluates test coverage, error handling, and code quality
  • Analyst Agent: Assesses code quality, impact analysis, and maintainability
  • Architect Agent: Reviews design patterns, system boundaries, and architectural concerns
  • DevOps Agent: Evaluates CI/CD, build pipelines, and infrastructure changes
  • Roadmap Agent: Assesses strategic alignment, feature scope, and user value

Review Summary

Agent Verdict Category Status
Security PASS N/A
QA WARN N/A ⚠️
Analyst WARN N/A ⚠️
Architect WARN N/A ⚠️
DevOps PASS N/A
Roadmap PASS N/A

💡 Quick Access: Click on individual agent jobs (e.g., "🔒 security Review", "🧪 qa Review") in the workflow run to see detailed findings and step summaries.

Security Review Details

Security Review: PR #1762

PR Type Classification

File Category Security Scrutiny
.agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json CONFIG Schema only
.claude/rules/enterprise-patterns.md DOCS None required

This is a DOCS + CONFIG PR containing architectural documentation and a session log.

Findings

Severity Category Finding Location CWE
- - No security issues identified - -

Analysis

  1. Secret Detection: No hardcoded credentials, API keys, tokens, or passwords found in either file.

  2. Session Log Review: The JSON file contains only session metadata (dates, branch names, protocol compliance flags, work log entries). No sensitive data exposed.

  3. Rules Markdown Review: Contains architectural pattern guidance (Repository, Unit of Work, Data Mapper, Service Layer, Identity Map). Pure documentation with no executable code.

  4. Sensitive Data Exposure: Neither file exposes internal URLs, endpoints, or implementation details that could aid attackers.

Recommendations

None required.

Verdict

VERDICT: PASS
MESSAGE: Documentation-only PR adding enterprise architecture patterns guidance. No security-relevant code or sensitive data.
{
  "verdict": "PASS",
  "message": "Documentation-only PR adding enterprise architecture patterns guidance. No security-relevant code or sensitive data.",
  "agent": "security",
  "timestamp": "2026-04-25T12:25:16.093Z",
  "findings": []
}
QA Review Details

Now I have all the information needed to complete the QA review.


QA Review: PR #1762

PR Type Classification

PR TYPE: MIXED (DOCS + CONFIG)
FILES:
  - DOCS: .claude/rules/enterprise-patterns.md (169 lines, rules markdown)
  - CONFIG: .agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json (session log)

Test Coverage Assessment

N/A - This PR contains only documentation (markdown rule file) and configuration (session log JSON). No executable code is added or modified.

Pre-executed pytest results confirm: 7098 passed, 3 skipped. No test regressions from this PR.

Quality Concerns

Severity Issue Location Evidence Required Fix
MEDIUM Session log endingCommit field contains "pending" .agents/sessions/...json:147 "endingCommit": "pending" violates schema pattern ^([0-9a-f]{7,40})?$ Update to empty string or actual commit SHA before merge
MEDIUM Session log prUrl field contains "pending" .agents/sessions/...json:148 "prUrl": "pending" - should be actual URL or removed Update to actual PR URL
LOW Missing schemaVersion field .agents/sessions/...json Schema recommends schemaVersion for new sessions Add "schemaVersion": "1.0"

Regression Risk Assessment

  • Risk Level: Low - Pure documentation addition with no code changes
  • Affected Components: None (new rule file, session log)
  • Breaking Changes: None
  • Required Testing: N/A (no executable code)

Documentation Quality

The markdown rule file is well-structured:

No broken links detected. No syntax errors in content.


VERDICT: WARN

MESSAGE: Documentation PR is sound but session log contains invalid placeholder values that violate JSON schema.

PR TYPE: MIXED (DOCS + CONFIG)

EVIDENCE:

  • Tests found: N/A - DOCS/CONFIG only
  • Test execution: PASS - 7098 passed, 3 skipped (no regressions)
  • Edge cases: N/A
  • Error handling: N/A
  • Blocking issues: 0
  • Schema violations: 2 (endingCommit, prUrl contain "pending" instead of valid values)

The session log endingCommit: "pending" fails the schema pattern ^([0-9a-f]{7,40})?$. This should be either empty string "" or the actual commit SHA. Similarly, prUrl should be the actual PR URL. These are MEDIUM severity because the session log is ancillary to the main deliverable (the rules file).


{
  "verdict": "WARN",
  "message": "Documentation PR is sound but session log contains invalid placeholder values that violate JSON schema",
  "agent": "qa",
  "timestamp": "2026-04-25T12:26:25.986Z",
  "findings": [
    {
      "severity": "medium",
      "category": "code-quality",
      "description": "Session log endingCommit field contains 'pending' which violates schema pattern requiring empty string or 7-40 char hex SHA",
      "location": ".agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json:147",
      "recommendation": "Update to empty string or actual commit SHA"
    },
    {
      "severity": "medium",
      "category": "code-quality",
      "description": "Session log prUrl field contains placeholder 'pending' instead of actual PR URL",
      "location": ".agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json:148",
      "recommendation": "Update to actual PR URL or remove field"
    },
    {
      "severity": "low",
      "category": "code-quality",
      "description": "Session log missing recommended schemaVersion field",
      "location": ".agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json",
      "recommendation": "Add schemaVersion: '1.0' for migration compatibility"
    }
  ]
}
Analyst Review Details

Now I have enough context to complete the analysis.


Code Quality Score

Criterion Score (1-5) Notes
Readability 5 Clear headings, consistent structure, domain vocabulary explained upfront
Maintainability 5 Single-purpose file, no dependencies, well-sectioned for updates
Consistency 5 Matches sibling .claude/rules/ pattern from PR #1759; frontmatter convention followed
Simplicity 5 Plain markdown, no complex logic, actionable rules

Overall: 5/5


Impact Assessment

  • Scope: Isolated (single new markdown rule file + session log)
  • Risk Level: Low (documentation-only, no code execution)
  • Affected Components: .claude/rules/ directory, agent context when rules invoked

Findings

Priority Category Finding Location
Medium consistency endingCommit value "pending" violates schema pattern ^([0-9a-f]{7,40})?$; must be empty string or valid SHA .agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json:145
Medium consistency prUrl value "pending" is non-standard; should be empty or valid URL .agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json:146
Low documentation alwaysApply: false rationale clear in PR description but absent from file itself .claude/rules/enterprise-patterns.md:3

Recommendations

  1. Replace "endingCommit": "pending" with "endingCommit": "" to pass JSON schema validation (per repository memory citing .agents/schemas/session-log.schema.json:157-161).
  2. Replace "prUrl": "pending" with "prUrl": "" for consistency.
  3. No changes needed to enterprise-patterns.md. Content covers all five issue-specified patterns, ties to codebase seams, and provides actionable review checklist.

Verdict

VERDICT: WARN
MESSAGE: Session log contains "pending" placeholders that violate schema; rule content is high quality and spec-complete.

{
  "verdict": "WARN",
  "message": "Session log contains 'pending' placeholders violating schema pattern; rule content meets spec requirements.",
  "agent": "analyst",
  "timestamp": "2026-04-25T12:25:16Z",
  "findings": [
    {
      "severity": "medium",
      "category": "consistency",
      "description": "endingCommit value 'pending' violates schema pattern ^([0-9a-f]{7,40})?$",
      "location": ".agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json:145",
      "recommendation": "Replace with empty string or valid 7-40 char lowercase hex SHA"
    },
    {
      "severity": "medium",
      "category": "consistency",
      "description": "prUrl value 'pending' is non-standard placeholder",
      "location": ".agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json:146",
      "recommendation": "Replace with empty string or valid URL once PR is created"
    },
    {
      "severity": "low",
      "category": "documentation",
      "description": "alwaysApply: false rationale documented in PR but not in file",
      "location": ".claude/rules/enterprise-patterns.md:3",
      "recommendation": "Optional: add brief comment in frontmatter or opening paragraph"
    }
  ]
}
Architect Review Details

I see the issue. The session log has "endingCommit": "pending" which violates the schema pattern ^([0-9a-f]{7,40})?$. Let me complete my architectural review.

Design Quality Assessment

Aspect Rating (1-5) Notes
Pattern Adherence 5 Follows established .claude/rules/ pattern from sibling PRs
Boundary Respect 5 Rule file stays in designated location; session log in sessions directory
Coupling 5 No code dependencies; pure documentation
Cohesion 5 Single-purpose file covering related PEAA patterns
Extensibility 5 alwaysApply: false allows conditional activation

Overall Design Score: 5/5

Architectural Concerns

Severity Concern Location Recommendation
Low Session log endingCommit field has invalid placeholder value .agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json:148 Replace "pending" with empty string "" to match schema pattern
Low Session log prUrl field has invalid placeholder value .agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json:149 Replace "pending" with empty string or valid URL

Breaking Change Assessment

  • Breaking Changes: No
  • Impact Scope: None
  • Migration Required: No
  • Migration Path: N/A

Technical Debt Analysis

  • Debt Added: Low
  • Debt Reduced: Low (codifies implicit patterns)
  • Net Impact: Improved (documents patterns that reduce future debt)

ADR Assessment

  • ADR Required: No
  • Decisions Identified: None (rule documents existing patterns, does not introduce new architectural decisions)
  • Existing ADR: N/A
  • Recommendation: N/A

Recommendations

  1. Fix session log placeholder values to comply with schema (endingCommit and prUrl should be empty strings or valid values, not "pending").

Verdict

The rule file is well-structured and follows established patterns. The content accurately describes PEAA patterns with clear application guidance specific to the ai-agents codebase. The alwaysApply: false setting is appropriate for situational patterns. Session log has minor schema compliance issues with placeholder values.

VERDICT: WARN
MESSAGE: Session log uses invalid placeholder values for endingCommit and prUrl fields; rule content is architecturally sound.
{
  "verdict": "WARN",
  "message": "Session log uses invalid placeholder values for endingCommit and prUrl fields; rule content is architecturally sound.",
  "agent": "architect",
  "timestamp": "2026-04-25T12:25:23.063Z",
  "findings": [
    {
      "severity": "low",
      "category": "tech-debt",
      "description": "endingCommit field contains 'pending' which violates schema pattern ^([0-9a-f]{7,40})?$",
      "location": ".agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json:148",
      "recommendation": "Replace 'pending' with empty string or actual commit SHA"
    },
    {
      "severity": "low",
      "category": "tech-debt",
      "description": "prUrl field contains 'pending' which should be empty string or valid URL",
      "location": ".agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json:149",
      "recommendation": "Replace 'pending' with empty string or actual PR URL after creation"
    }
  ]
}
DevOps Review Details

DevOps Review: PR #1762

PR Scope Detection

Category Files Changed
DOCS .claude/rules/enterprise-patterns.md
CONFIG .agents/sessions/*.json

Classification: DOCS + CONFIG (session log JSON). No CI/CD, workflow, or infrastructure changes.

Pipeline Impact Assessment

Area Impact Notes
Build None No build configuration changes
Test None No test infrastructure changes
Deploy None No deployment changes
Cost None No runner or resource changes

CI/CD Quality Checks

Check Status Location
Workflow changes N/A No workflow files modified
Actions pinned N/A No actions referenced
Secrets secure N/A No secrets involved
Permissions minimal N/A No permissions changes
Shell scripts robust N/A No shell scripts

Findings

Severity Category Finding Location Fix
Low sessions Session log endingCommit and prUrl contain "pending" placeholder .agents/sessions/...json:147-148 Should contain actual SHA and URL per schema; minor issue

Note: The endingCommit: "pending" value technically violates the session log schema which requires empty string or 7-40 character hex SHA. However, this is a documentation artifact and does not affect CI/CD.

Template Assessment

  • PR Template: Adequate (PR follows template structure)
  • Issue Templates: N/A (not modified)

Automation Opportunities

None identified. This is a content-only documentation change.

Recommendations

  1. Update session log endingCommit from "pending" to actual commit SHA before merge (minor)

Verdict

VERDICT: PASS
MESSAGE: Documentation-only PR with no CI/CD impact. Session log placeholder is cosmetic.
{
  "verdict": "PASS",
  "message": "Documentation-only PR with no CI/CD impact",
  "agent": "devops",
  "timestamp": "2026-04-25T12:25:20.851Z",
  "findings": [
    {
      "severity": "low",
      "category": "artifacts",
      "description": "Session log contains 'pending' placeholder for endingCommit and prUrl instead of actual values",
      "location": ".agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json:147-148",
      "recommendation": "Update to actual commit SHA and PR URL; does not block merge"
    }
  ]
}
Roadmap Review Details

Strategic Alignment Assessment

Criterion Rating Notes
Aligns with project goals High Enables coordinated multi-agent workflows by codifying shared architectural vocabulary
Priority appropriate Medium Documentation-type work; not blocking roadmap items but fills implicit gap
User value clear High Agents gain consistent guidance on persistence/orchestration patterns; reduces competing abstractions
Investment justified High Single 11KB file, low effort, high leverage across all agent interactions

Feature Completeness

  • Scope Assessment: Right-sized
  • Ship Ready: Yes
  • MVP Complete: Yes
  • Enhancement Opportunities: None required; scope appropriately trimmed per issue (DTO assembly, remote facade, transaction script deferred to unified rules)

Impact Analysis

Dimension Assessment Notes
User Value Medium Indirect; improves agent code quality, not end-user features
Business Impact Low No monetization/growth impact; internal consistency gain
Technical Leverage High Reusable foundation; applies whenever agents touch persistence/orchestration
Competitive Position Neutral Standard patterns, not differentiating

Concerns

Priority Concern Recommendation
Low Session log has endingCommit: "pending" and prUrl: "pending" Update before merge to match actual commit SHA and PR URL
Low alwaysApply: false is intentional per PR description but limits automatic application Acceptable; enterprise patterns are situational, unlike everyday code-quality rules

Recommendations

  1. Accept as-is: The rule fills an implicit gap, ties patterns to existing codebase seams (orchestrator, session management, memory systems), and requires minimal ongoing maintenance.
  2. Validate session log: Ensure endingCommit and prUrl are updated to actual values before merge to satisfy schema requirements.
  3. No roadmap adjustment needed: This is additive documentation with no dependency on or impact to P0/P1 roadmap items.

Verdict

VERDICT: PASS
MESSAGE: Enterprise patterns rule aligns with multi-agent consistency goals, right-sized scope, and low maintenance burden. Fills implicit gap without impacting roadmap priorities.
{
  "verdict": "PASS",
  "message": "Enterprise patterns rule aligns with multi-agent consistency goals, right-sized scope, and low maintenance burden.",
  "agent": "roadmap",
  "timestamp": "2026-04-25T12:25:19.414Z",
  "findings": [
    {
      "severity": "low",
      "category": "documentation",
      "description": "Session log contains placeholder values for endingCommit and prUrl",
      "location": ".agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json:149-150",
      "recommendation": "Update to actual commit SHA and PR URL before merge"
    }
  ]
}

Run Details
Property Value
Run ID 24930837271
Triggered by pull_request on 1762/merge
Commit 00c082cd296cbad26fef0bfd0e5a48c89e329488

Powered by AI Quality Gate workflow

@coderabbitai

coderabbitai Bot commented Apr 25, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 2af6cc11-4e35-46df-95fb-a369bc2596a0

📥 Commits

Reviewing files that changed from the base of the PR and between 027b585 and 6e4172d.

⛔ Files ignored due to path filters (1)
  • .agents/sessions/2026-04-25-session-1753-enterprise-patterns-rules.json is excluded by !.agents/sessions/**
📒 Files selected for processing (1)
  • .claude/rules/enterprise-patterns.md

📝 Walkthrough

Walkthrough

New Claude rules document added consolidating PEAA enterprise architecture patterns including Repository, Unit of Work, Data Mapper, Service Layer, and Identity Map. Document specifies pattern usage rules, boundaries, transaction scope, identity caching, mapping responsibilities, service orchestration flow, anti-patterns, and includes a pre-change checklist.

Changes

Cohort / File(s) Summary
Enterprise Architecture Guidance
.claude/rules/enterprise-patterns.md
New documentation file establishing rules for PEAA patterns: Repository, Unit of Work, Data Mapper, Service Layer, and Identity Map. Defines boundaries for ai-agents seams (sessions, orchestrator, skills-hooks, memory systems), specifies transaction scope and commit semantics, enumerates anti-patterns (leaking persistence details, ambient transactions, smart entry points), and provides checklist for persistence/transaction/orchestration changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested labels

documentation, agent-orchestrator, agent-memory

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Title follows conventional commit format with 'feat(rules)' prefix and concisely describes adding enterprise-patterns rule covering Fowler PEAA.
Description check ✅ Passed Description clearly explains the addition of enterprise-patterns.md, lists sections, ties patterns to ai-agents seams, and documents testing performed.
Linked Issues check ✅ Passed PR fully implements requirements from #1753: creates enterprise-patterns.md covering Repository, Unit of Work, Data Mapper, Service Layer, and Identity Map; trims less-relevant patterns; ties to ai-agents seams.
Out of Scope Changes check ✅ Passed Changes are limited to the enterprise-patterns.md rule file and session log; both directly address #1753 objectives with no unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/1753-autonomous

Comment @coderabbitai help to get the list of available commands and usage tips.

@rjmurillo-bot rjmurillo-bot merged commit 065e374 into main Apr 25, 2026
96 checks passed
@rjmurillo-bot rjmurillo-bot deleted the feat/1753-autonomous branch April 25, 2026 12:29

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new rule file, .claude/rules/enterprise-patterns.md, which defines enterprise architecture patterns such as Repository, Unit of Work, and Service Layer for the codebase. The review feedback focuses on ensuring the documentation adheres to the project's style guide, specifically regarding maximum sentence length, the use of active voice, and addressing the user directly as 'you'.


# Enterprise Patterns

This rule consolidates the patterns from Martin Fowler's _Patterns of Enterprise Application Architecture_ (PEAA) that recur in this codebase. Use it when you change persistence, transactional, or orchestration code, or when you introduce a new component that touches a data store, an external service, or a long-running workspace.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This sentence exceeds the maximum length of 25 words (34 words) and combines multiple ideas. Break it into shorter, focused sentences to improve readability and adhere to the style guide.

Suggested change
This rule consolidates the patterns from Martin Fowler's _Patterns of Enterprise Application Architecture_ (PEAA) that recur in this codebase. Use it when you change persistence, transactional, or orchestration code, or when you introduce a new component that touches a data store, an external service, or a long-running workspace.
This rule consolidates the patterns from Martin Fowler's Patterns of Enterprise Application Architecture (PEAA) that recur in this codebase. Use it when changing persistence, transactional, or orchestration code. Also apply it when introducing components touching data stores, external services, or long-running workspaces.
References
  1. Sentences must not exceed 25 words and should convey one idea. (link)


This rule consolidates the patterns from Martin Fowler's _Patterns of Enterprise Application Architecture_ (PEAA) that recur in this codebase. Use it when you change persistence, transactional, or orchestration code, or when you introduce a new component that touches a data store, an external service, or a long-running workspace.

The codebase already uses several of these patterns implicitly. Make them explicit in new code rather than create competing shapes (for example, a second class that loads the same entity through a different path). When in doubt, find the existing collaborator and extend it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This sentence exceeds the maximum length of 25 words (27 words). Break it into shorter sentences to comply with the style guide.

Suggested change
The codebase already uses several of these patterns implicitly. Make them explicit in new code rather than create competing shapes (for example, a second class that loads the same entity through a different path). When in doubt, find the existing collaborator and extend it.
The codebase already uses several of these patterns implicitly. Make them explicit in new code. Avoid creating competing shapes, such as a second class loading the same entity through a different path. When in doubt, find the existing collaborator and extend it.
References
  1. Sentences must not exceed 25 words. (link)

- Methods read like collection operations: `add`, `remove`, `find...`, `exists`. Do not name them after SQL verbs.
- Each domain aggregate has at most one repository. If you find yourself writing a second repository for the same aggregate, you are usually missing a query method on the first one.
- Repositories do not commit. Commits belong to the Unit of Work or the calling Service Layer.
- Filtering and projection live behind named methods. Avoid passing predicates or query objects across the boundary unless you have a Specification pattern in place and the caller actually composes them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This sentence exceeds the maximum length of 25 words (28 words).

Suggested change
- Filtering and projection live behind named methods. Avoid passing predicates or query objects across the boundary unless you have a Specification pattern in place and the caller actually composes them.
- Filtering and projection live behind named methods. Avoid passing predicates or query objects across the boundary. Only do this if a Specification pattern exists and the caller composes them.
References
  1. Sentences must not exceed 25 words. (link)

- Track three sets explicitly: new, dirty, and removed. Resolve order at commit time so callers do not have to think about it.
- Commit at the boundary of the use case, not inside repositories or domain methods.
- On failure, roll back and surface the failure. Never partially commit. Never swallow the error and continue.
- A Unit of Work is short-lived. If yours spans HTTP requests, agent turns, or user interactions, you are using it for caching; use an Identity Map for that instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This sentence exceeds the maximum length of 25 words (26 words).

Suggested change
- A Unit of Work is short-lived. If yours spans HTTP requests, agent turns, or user interactions, you are using it for caching; use an Identity Map for that instead.
- A Unit of Work is short-lived. If yours spans HTTP requests, agent turns, or user interactions, you are using it for caching. Use an Identity Map instead.
References
  1. Sentences must not exceed 25 words. (link)

- Services depend on abstractions. Inject repositories and external clients; do not new them up inline.
- A Service method should be short. If it grows past a screen, the use case is doing too much; split it into a domain method or a smaller service.

In ai-agents, the agent orchestrator is the canonical Service Layer. New use cases that coordinate repositories, sessions, or external tools belong there or in a sibling service, not scattered across hooks and skills.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The second sentence exceeds the maximum length of 25 words (26 words) and uses passive voice ("scattered"). Use active voice with clear actors.

Suggested change
In ai-agents, the agent orchestrator is the canonical Service Layer. New use cases that coordinate repositories, sessions, or external tools belong there or in a sibling service, not scattered across hooks and skills.
In ai-agents, the agent orchestrator is the canonical Service Layer. New use cases coordinating repositories, sessions, or external tools belong there or in a sibling service. Do not scatter them across hooks and skills.
References
  1. Sentences must not exceed 25 words. Use active voice with clear actors. (link)

- **Repository as DAO**: methods named `executeQuery`, `runUpdate`, or `getConnection`. Replace with named, intention-revealing operations.
- **Ambient transactions**: a global or thread-local `currentTransaction()` that any code may read or write. Pass the Unit of Work explicitly.
- **Cross-aggregate transactions stretched across services**: do not paper over a missing aggregate boundary with a longer transaction. Redraw the boundary.
- **Pattern stacking**: every read goes through five layers because "the patterns say so." If a layer never varies and never gets tested in isolation, delete it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This sentence uses passive voice ("gets tested"). The style guide requires active voice with clear actors performing the action.

Suggested change
- **Pattern stacking**: every read goes through five layers because "the patterns say so." If a layer never varies and never gets tested in isolation, delete it.
- Pattern stacking: every read goes through five layers because "the patterns say so." If a layer never varies and you never test it in isolation, delete it.
References
  1. Use active voice with clear actors performing the action. (link)

- Skills and hooks are entry points. Keep them thin: parse inputs, call a service, format output. They are not the place for business rules.
- Memory systems (Serena, Forgetful) act as Repositories of long-lived knowledge. Do not bypass them with direct file reads when the named operation already exists.

When you find a place where the codebase deviates from this rule, prefer a small focused refactor on the path you are already touching over a large rewrite. Note the deviation in the PR description so future readers see your reasoning.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The first sentence exceeds the maximum length of 25 words (31 words).

Suggested change
When you find a place where the codebase deviates from this rule, prefer a small focused refactor on the path you are already touching over a large rewrite. Note the deviation in the PR description so future readers see your reasoning.
When the codebase deviates from this rule, prefer a small focused refactor on the current path. Avoid large rewrites. Note the deviation in the PR description so future readers see your reasoning.
References
  1. Sentences must not exceed 25 words. (link)

- Does the code touch a data store directly, or through a repository?
- If it changes more than one aggregate, is there exactly one Unit of Work that commits the whole change?
- Do domain objects depend on persistence types, or only on other domain types?
- Is the use case named, single-purpose, and visible at the Service Layer?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This sentence uses passive voice ("named"). Use active voice to improve clarity.

Suggested change
- Is the use case named, single-purpose, and visible at the Service Layer?
- Does the use case have a name, a single purpose, and visibility at the Service Layer?
References
  1. Use active voice with clear actors. (link)

- If it changes more than one aggregate, is there exactly one Unit of Work that commits the whole change?
- Do domain objects depend on persistence types, or only on other domain types?
- Is the use case named, single-purpose, and visible at the Service Layer?
- Could the same entity be loaded twice in this operation? If yes, is the Identity Map handling that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This sentence uses passive voice ("be loaded"). Use active voice and address the user as "you".

Suggested change
- Could the same entity be loaded twice in this operation? If yes, is the Identity Map handling that?
- Could you load the same entity twice in this operation? If yes, is the Identity Map handling that?
References
  1. Use active voice and address the user as 'you'. (link)

rjmurillo pushed a commit that referenced this pull request Apr 26, 2026
Resolves conflict in .github/workflows/pytest.yml. Both branches added
--ignore-vuln CVE-2026-3219 to pip-audit (this branch in aee5278, main
in #1779). Took main's version since #1779 has the canonical, more
detailed rationale comment block (links to pypa/pip#13870 fix PR,
explains the local-only attack surface and why it does not apply to CI).

Also addresses the latest Copilot review comments on this PR:

- tests/eval/test_eval_prompt_change.py: scope the sys.path mutation
  to module load only and restore it in a finally block. eval-prompt-
  change.py imports sibling modules (_anthropic_api, _eval_common) by
  bare name, so EVAL_DIR must be on sys.path during exec_module();
  removing the entry afterwards prevents the addition from leaking
  into other tests' import resolution. Tests still pass: 85 in this
  file, 107 with workspace-limits tests included.

- .agents/sessions/2026-04-25-session-1714.json: rewrite workLog steps
  1 and 7 evidence so they no longer reference .agents/audit/eval-1741/
  or .agents/audit/eval-1755/ paths that do not exist in the repo (the
  artifacts were transient and dropped in 31ed283). Step 1 now points
  to the reproducer command; step 7 points to the per-agent table in
  the PR Honesty notes section.

Pulls in main's PR #1779 (pip CVE ignore w/ rationale) and PR #1762
(enterprise-patterns rule) as part of the merge.

Refs #1755

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

https://claude.ai/code/session_01XALNMgBrrH7Ya8dM1CjYzo
rjmurillo pushed a commit that referenced this pull request Apr 26, 2026
Adds .claude/rules/refactoring.md following the established .claude/rules/
pattern (mirrors merged enterprise-patterns.md from PR #1762). Encodes the
discipline from Martin Fowler's Refactoring so reviewers can tell whether a
change is structure, behavior, or both.

Covers all six items the issue lists as required:
- Refactoring preserves observable behavior
- Behavior changes stay separate from structural cleanup (two-hat rule)
- Small, named, mechanical transformations only (no big-bang rewrites)
- Tests must pass between every step
- Code-smell triggers (long function, feature envy, shotgun surgery, plus 14 more)
- No refactor + feature in the same commit

Integrates with ADR-008 commit budget and atomic-commit file limit
explicitly. Boundaries section ties the rule to the existing
enterprise-patterns.md (target shapes) and the session protocol (evidence).

Fixes #1746

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
rjmurillo pushed a commit that referenced this pull request Apr 26, 2026
…niques (#1747)

Encode Michael Feathers' techniques from Working Effectively with
Legacy Code as a conditional Claude rule. Activates when the file
under change has low test coverage, is older than six months, or is
on a To Improve fix cycle from the auto-escalation ladder.

Covers characterization tests, seams (object, link, build), sprout
method/class, wrap method/class, dependency-breaking techniques
(extract interface, parameterize constructor, introduce instance
delegator, subclass and override, pull up dependency), and the
hard rule never to delete failing tests to make a refactor pass.

Mirrors the structure and frontmatter of .claude/rules/enterprise-patterns.md
introduced in #1762.

Fixes #1747

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
rjmurillo pushed a commit that referenced this pull request Apr 26, 2026
…ut APoSD (#1748)

Adds .claude/rules/philosophy-of-software-design.md encoding John Ousterhout's
heuristics from "A Philosophy of Software Design": deep modules, information
hiding, complexity symptoms (change amplification, cognitive load, unknown
unknowns), pull complexity downward, define errors out of existence, design it
twice, comments-describe-what-code-cannot, strategic vs tactical.

Includes a Boundaries with Existing Codebase section that ties the rule to
ai-agents tool/skill interfaces, agent prompts, plugin seams, hooks, and
memory systems so workers reuse existing seams instead of introducing
parallel ones.

Mirrors the structural conventions of .claude/rules/enterprise-patterns.md
(PR #1762).

Fixes #1748

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
rjmurillo pushed a commit that referenced this pull request Apr 26, 2026
…rinciples (#1750)

Fixes #1750

Adds .claude/rules/pragmatic-programmer.md as a binding engineering policy
applied as a general overlay for all worker agents. Source content adapted
from ciembor/agent-rules-books (MIT) at the-pragmatic-programmer/claude/.claude/rules/the-pragmatic-programmer.md.

Covers DRY at the knowledge level, orthogonality, tracer-bullet delivery,
prototyping discipline, automation, fast feedback loops, design by contract,
error handling, naming and communication, text and data, state and
concurrency, estimation, tooling, broken-windows discipline, forbidden
patterns, code generation defaults, testing rules, and a pre-merge review
checklist.

Adds a Multi-Agent Context section that maps each principle to ai-agents
agent, skill, and hook boundaries — DRY at knowledge level for cross-prompt
policy, orthogonality across agents, tracer bullets for new agent
capabilities, broken windows for stale prompts, automation in hooks
instead of prose, and short-feedback signals.

Mirrors the frontmatter schema established by sibling PR #1762 (issue #1753,
enterprise-patterns.md). alwaysApply set to true because pragmatic
principles are everyday engineering overlay, unlike enterprise-patterns
which is conditional.

markdownlint-cli2 confirms zero violations from the new file.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
rjmurillo pushed a commit that referenced this pull request Apr 26, 2026
Adds .claude/rules/clean-architecture.md (~15KB) encoding Robert C.
Martin's Clean Architecture for this codebase: dependency rule,
entities, use cases, interface adapters, frameworks and drivers,
boundary protection, pattern selection, anti-patterns, and a
quick self-review.

The Boundaries section ties the rule to existing ai-agents seams:
the orchestrator and lifecycle skills as use cases, GitHub and MCP
wrappers as interface adapters, GitHub Actions/gh/MCP servers as
frameworks. Reinforces, not duplicates, AGENTS.md guidance.

alwaysApply: false because the rule is conditional, applied when
boundary-crossing changes are in flight, not on every edit.

Refs PR #1762 (enterprise-patterns) for the established
.claude/rules/ pattern; this change matches that schema and
adds a session log under .agents/sessions/.

Fixes #1749

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
rjmurillo-bot added a commit that referenced this pull request Apr 26, 2026
…1775)

* feat(rules): add refactoring rule covering Fowler discipline (#1746)

Adds .claude/rules/refactoring.md following the established .claude/rules/
pattern (mirrors merged enterprise-patterns.md from PR #1762). Encodes the
discipline from Martin Fowler's Refactoring so reviewers can tell whether a
change is structure, behavior, or both.

Covers all six items the issue lists as required:
- Refactoring preserves observable behavior
- Behavior changes stay separate from structural cleanup (two-hat rule)
- Small, named, mechanical transformations only (no big-bang rewrites)
- Tests must pass between every step
- Code-smell triggers (long function, feature envy, shotgun surgery, plus 14 more)
- No refactor + feature in the same commit

Integrates with ADR-008 commit budget and atomic-commit file limit
explicitly. Boundaries section ties the rule to the existing
enterprise-patterns.md (target shapes) and the session protocol (evidence).

Fixes #1746

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(rules): correct commit budget references in refactoring rule

ADR-008 covers SESSION-PROTOCOL lifecycle hooks, not commit budgets.
Point readers to CONTRIBUTING.md for the 20-commit PR limit and to
AGENTS.md for the atomic commits per-file (<=5 files) budget so the
refactoring rule cites the actual sources of truth.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: rjmurillo-bot <rjmurillo-bot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Test <test@test.com>
rjmurillo-bot added a commit that referenced this pull request Apr 26, 2026
…r bullets) (#1750) (#1764)

* feat(rules): add pragmatic-programmer rule covering Hunt and Thomas principles (#1750)

Fixes #1750

Adds .claude/rules/pragmatic-programmer.md as a binding engineering policy
applied as a general overlay for all worker agents. Source content adapted
from ciembor/agent-rules-books (MIT) at the-pragmatic-programmer/claude/.claude/rules/the-pragmatic-programmer.md.

Covers DRY at the knowledge level, orthogonality, tracer-bullet delivery,
prototyping discipline, automation, fast feedback loops, design by contract,
error handling, naming and communication, text and data, state and
concurrency, estimation, tooling, broken-windows discipline, forbidden
patterns, code generation defaults, testing rules, and a pre-merge review
checklist.

Adds a Multi-Agent Context section that maps each principle to ai-agents
agent, skill, and hook boundaries — DRY at knowledge level for cross-prompt
policy, orthogonality across agents, tracer bullets for new agent
capabilities, broken windows for stale prompts, automation in hooks
instead of prose, and short-feedback signals.

Mirrors the frontmatter schema established by sibling PR #1762 (issue #1753,
enterprise-patterns.md). alwaysApply set to true because pragmatic
principles are everyday engineering overlay, unlike enterprise-patterns
which is conditional.

markdownlint-cli2 confirms zero violations from the new file.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* ci: trigger validation re-run with bypass label

* docs(rules): address review feedback on pragmatic-programmer

- Inline the engineering-qualities guidance instead of referencing
  .claude/skills/golden-principles/. Project policy requires agent
  templates to be self-contained without external file paths
  (CodeRabbit major finding).
- Reword the prototyping rule to drop the "pretend you are done"
  phrasing that triggered a Semgrep skill-roleplay-persona-attack
  false positive. Meaning is unchanged: a prototype is for learning,
  not a substitute for finished work.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: rjmurillo-bot <rjmurillo-bot@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Test <test@test.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-memory Context persistence agent agent-orchestrator Task coordination agent documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Claude rules: enterprise-patterns (repository, unit-of-work, service layer)

1 participant