Skip to content

Add immutable AgentCapabilities core data models - #671

Open
Akshaya-125 wants to merge 2 commits into
sreerevanth:mainfrom
Akshaya-125:feature/agent-capabilities
Open

Add immutable AgentCapabilities core data models#671
Akshaya-125 wants to merge 2 commits into
sreerevanth:mainfrom
Akshaya-125:feature/agent-capabilities

Conversation

@Akshaya-125

@Akshaya-125 Akshaya-125 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the core data models for the Capability Lattice.

Changes

  • Added immutable Capability data model.
  • Added immutable AgentCapabilities data model.
  • Added capability whitelist fields:
    • read_paths
    • write_paths
    • network_domains
    • db_tables
    • exec_binaries
  • Added unit tests for instantiation and immutability.

Closes #652

Summary by CodeRabbit

  • New Features

    • Added capability definitions for file access, network domains, database tables, and executable binaries.
    • Capability settings are immutable and default to empty permissions.
    • Capability types are available directly from the core package.
  • Tests

    • Added coverage for capability creation, configuration, and immutability.

@ecc-tools

ecc-tools Bot commented Jul 26, 2026

Copy link
Copy Markdown

Analyzing 200 commits...

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Akshaya-125, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d52bc649-c01b-4552-8dd8-bc497cc685c7

📥 Commits

Reviewing files that changed from the base of the PR and between 89a74d8 and a0e9df2.

📒 Files selected for processing (14)
  • .agents/skills/python-design-patterns/SKILL.md
  • .agents/skills/python-design-patterns/references/details.md
  • .agents/skills/python-observability/SKILL.md
  • .agents/skills/python-observability/references/details.md
  • README.md
  • agentwatch/core/capabilities.py
  • docs/adapters/langchain.md
  • docs/custom_adapters_tutorial.md
  • docs/getting_started_extended.md
  • tests/test_audit_persistence.py
  • tests/test_capabilities.py
  • tests/test_compliance.py
  • tests/test_gdpr_erasure.py
  • tests/test_rate_limiter_redis.py
📝 Walkthrough

Walkthrough

Adds frozen Capability and AgentCapabilities dataclasses, exposes them through agentwatch.core, and tests construction, permission fields, and immutability.

Changes

Capability models

Layer / File(s) Summary
Define capability structures
agentwatch/core/capabilities.py
Defines immutable capability dataclasses with path, network, database, and executable permission sets.
Expose and validate capabilities
agentwatch/core/__init__.py, tests/test_capabilities.py
Exports both types from agentwatch.core and tests construction, stored values, and frozen assignment behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A rabbit checked each path with care,
Froze every promise in the air.
Domains and binaries joined the set,
No mutable surprise was met.
“Hop!” cried the tests, “the model’s right!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: immutable AgentCapabilities core models.
Linked Issues check ✅ Passed The changes implement Capability and immutable AgentCapabilities with the required frozen set whitelists and tests, matching #652.
Out of Scope Changes check ✅ Passed The PR stays focused on the new capability data models, exports, and tests with no obvious unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@ecc-tools

ecc-tools Bot commented Jul 26, 2026

Copy link
Copy Markdown

Analysis Complete

Generated ECC bundle from 1 commits | Confidence: 50%

View Pull Request #672

Repository Profile
Attribute Value
Language Python
Framework Not detected
Commit Convention freeform
Test Directory separate
Changed Files (3)
Metric Value
Files changed 3
Additions 59
Deletions 0

Top hotspots

Path Status +/-
tests/test_capabilities.py added +33 / -0
agentwatch/core/capabilities.py added +25 / -0
agentwatch/core/__init__.py modified +1 / -0

Top directories

Directory Files Total changes
tests 1 33
agentwatch/core 2 26
Analysis Depth Readiness (commit-history, 7%)

ECC Tools uses this to decide whether recommendations should stay at commit-history/setup guidance or expand into CI, security, harness, reference-set, AI-routing, and team backlog work.

Area Status Evidence / Next Step
Commit history Partial 1 commits sampled
CI/CD signals Missing Add workflow files or CI troubleshooting evidence so ECC Tools can reason about pipeline setup.
Security evidence Missing Add AgentShield, audit, SARIF, SBOM, or security review evidence so recommendations can cover security posture.
Harness configuration Missing Add Claude, Codex, OpenCode, Zed, dmux, MCP, plugin, or cross-harness config evidence for harness-agnostic recommendations.
Reference/eval evidence Missing Add fixtures, golden traces, reference sets, or evaluator benchmarks so deeper recommendations have regression evidence.
AI routing and cost controls Missing Add model-routing, budget, usage, or cost-control files before relying on AI-heavy automation recommendations.
Team handoff and project tracking Missing Add roadmap, runbook, project, Linear, or follow-up tracking docs so generated work can land in a team queue.
Reference Set Readiness (0/7, 0%)
Area Status Evidence / Next Step
Deep analyzer corpus Missing Add analyzer fixture, golden, benchmark, or reference-set files that can catch analyzer regressions.
RAG/evaluator comparison Missing Add retrieval or evaluator reference-set comparison fixtures with expected ranking behavior.
PR salvage/review corpus Missing Add stale-PR, review-thread, reopen-flow, or salvage reference cases for queue cleanup automation.
Discussion triage corpus Missing Add public discussion triage fixtures, golden cases, or reference sets for informational, answered, and no-response classifications.
Harness compatibility Missing Add cross-harness, adapter-compliance, or harness-audit evidence for Claude, Codex, OpenCode, Zed, dmux, and agent surfaces.
Security evidence Missing Attach security evidence such as SBOMs, SARIF, audit reports, or AgentShield evidence packs.
CI failure-mode evidence Missing Add captured CI failure logs, dry-run fixtures, or troubleshooting docs for common workflow failure modes.
Generated Instincts (13)
Domain Count
git 2
code-style 9
testing 2

After merging, import with:

/instinct-import .claude/homunculus/instincts/inherited/AgentWatch-instincts.yaml

Files

  • .claude/ecc-tools.json
  • .claude/skills/AgentWatch/SKILL.md
  • .agents/skills/AgentWatch/SKILL.md
  • .agents/skills/AgentWatch/agents/openai.yaml
  • .claude/identity.json
  • .codex/config.toml
  • .codex/AGENTS.md
  • .codex/agents/explorer.toml
  • .codex/agents/reviewer.toml
  • .codex/agents/docs-researcher.toml
  • .claude/homunculus/instincts/inherited/AgentWatch-instincts.yaml

ECC Tools | Everything Claude Code

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

🧪 PR Test Results

Check Result
Tests (pytest tests/) ✅ success
Lint (ruff check .) ✅ success
Coverage (agentwatch) 74.22%

Python 3.12 · commit a0e9df2

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (3)
tests/test_capabilities.py (3)

8-8: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Test the public agentwatch.core API.

Importing from agentwatch.core.capabilities bypasses the package re-export, so these tests will pass even if the public export is broken. Import through agentwatch.core and assert both names are present in __all__.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_capabilities.py` at line 8, Update the imports in the capabilities
tests to use the public agentwatch.core API instead of
agentwatch.core.capabilities. In the tests covering AgentCapabilities and
Capability, verify both names are exposed through agentwatch.core.__all__ while
preserving the existing behavior assertions.

29-33: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Test immutability of supplied collections.

This only checks field reassignment. Add a case that passes a mutable set, mutates the original or stored collection, and verifies the model retains an immutable snapshot.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_capabilities.py` around lines 29 - 33, Extend
test_agent_capabilities_are_immutable to construct AgentCapabilities with a
mutable set, mutate the original set or stored collection, and assert the model
retains an immutable snapshot with the original contents. Keep the existing
FrozenInstanceError field-reassignment check.

11-13: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Also verify Capability immutability.

Capability is frozen, but this test only checks construction. Add a FrozenInstanceError assertion for assigning cap.name.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_capabilities.py` around lines 11 - 13, Extend
test_capability_instantiation to verify the frozen Capability contract by
asserting that assigning a new value to cap.name raises FrozenInstanceError.
Preserve the existing construction and name assertion, and import the
appropriate exception or testing utility if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@agentwatch/core/__init__.py`:
- Line 1: Update agentwatch/core/__init__.py to add AgentCapabilities and
Capability to __all__ while following the existing re-export convention. In
tests/test_capabilities.py, import both names through agentwatch.core and verify
they are publicly exported.

In `@agentwatch/core/capabilities.py`:
- Around line 18-22: The Capability dataclass must normalize all whitelist
inputs to immutable frozensets during construction. In
agentwatch/core/capabilities.py lines 18-22, add __post_init__ normalization for
read_paths, write_paths, network_domains, db_tables, and exec_binaries; in
tests/test_capabilities.py lines 29-33, add a mutable-input test that verifies
later changes to the original inputs cannot alter stored permissions.

---

Nitpick comments:
In `@tests/test_capabilities.py`:
- Line 8: Update the imports in the capabilities tests to use the public
agentwatch.core API instead of agentwatch.core.capabilities. In the tests
covering AgentCapabilities and Capability, verify both names are exposed through
agentwatch.core.__all__ while preserving the existing behavior assertions.
- Around line 29-33: Extend test_agent_capabilities_are_immutable to construct
AgentCapabilities with a mutable set, mutate the original set or stored
collection, and assert the model retains an immutable snapshot with the original
contents. Keep the existing FrozenInstanceError field-reassignment check.
- Around line 11-13: Extend test_capability_instantiation to verify the frozen
Capability contract by asserting that assigning a new value to cap.name raises
FrozenInstanceError. Preserve the existing construction and name assertion, and
import the appropriate exception or testing utility if needed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a1113318-0c46-4997-afef-33f9f3c56ecb

📥 Commits

Reviewing files that changed from the base of the PR and between d94dfd0 and 89a74d8.

📒 Files selected for processing (3)
  • agentwatch/core/__init__.py
  • agentwatch/core/capabilities.py
  • tests/test_capabilities.py

@@ -1,3 +1,4 @@
from agentwatch.core.capabilities import AgentCapabilities, Capability

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.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Validate the complete public agentwatch.core export contract.

  • agentwatch/core/__init__.py#L1-L1: add AgentCapabilities and Capability to __all__ and follow the configured re-export convention.
  • tests/test_capabilities.py#L8-L8: import through agentwatch.core and verify both names are publicly exported.
📍 Affects 2 files
  • agentwatch/core/__init__.py#L1-L1 (this comment)
  • tests/test_capabilities.py#L8-L8
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@agentwatch/core/__init__.py` at line 1, Update agentwatch/core/__init__.py to
add AgentCapabilities and Capability to __all__ while following the existing
re-export convention. In tests/test_capabilities.py, import both names through
agentwatch.core and verify they are publicly exported.

Source: Path instructions

Comment on lines +18 to +22
read_paths: frozenset[Path] = field(default_factory=frozenset)
write_paths: frozenset[Path] = field(default_factory=frozenset)
network_domains: frozenset[str] = field(default_factory=frozenset)
db_tables: frozenset[tuple[str, str]] = field(default_factory=frozenset)
exec_binaries: frozenset[str] = field(default_factory=frozenset)

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.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Preserve immutability across construction and testing.

frozen=True does not freeze mutable sets passed to the constructor.

  • agentwatch/core/capabilities.py#L18-L22: normalize every whitelist with frozenset(...) in __post_init__.
  • tests/test_capabilities.py#L29-L33: add a mutable-input test proving the stored permissions cannot be changed.
📍 Affects 2 files
  • agentwatch/core/capabilities.py#L18-L22 (this comment)
  • tests/test_capabilities.py#L29-L33
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@agentwatch/core/capabilities.py` around lines 18 - 22, The Capability
dataclass must normalize all whitelist inputs to immutable frozensets during
construction. In agentwatch/core/capabilities.py lines 18-22, add __post_init__
normalization for read_paths, write_paths, network_domains, db_tables, and
exec_binaries; in tests/test_capabilities.py lines 29-33, add a mutable-input
test that verifies later changes to the original inputs cannot alter stored
permissions.

@SHAURYASANYAL3

Copy link
Copy Markdown
Collaborator

The core data models look correct, but the CI pipeline is failing on 'Python Lint & Type Check'. We enforce a strict 0-warning policy. Fix the lint errors and ping me when CI is green.

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.

[v2] Define AgentCapabilities Core Structs and Data Models

2 participants