Repository navigation
Network Policy Generalization [Spec + Impl] - #10
Conversation
📝 WalkthroughWalkthroughThis PR generalizes network policy generation to support multiple agents. It adds a ChangesAgent-aware policy assembly implementation
Feature specification and planning documents
Estimated code review effort: 3 (Moderate) | ~30 minutes Sequence Diagram(s)sequenceDiagram
participant Manifest
participant AssemblePolicyCore
participant AgentAdapter
participant Resolver
participant NetworkPolicy
Manifest->>AssemblePolicyCore: EffectiveAgents()
loop for each agent
AssemblePolicyCore->>AgentAdapter: RequiredDomainGroups()
AssemblePolicyCore->>Manifest: AllowedDomainsPerAgent[agent]
AssemblePolicyCore->>Resolver: expand domain groups
Resolver-->>AssemblePolicyCore: endpoints or warning
AssemblePolicyCore->>NetworkPolicy: add uncovered endpoints
end
AssemblePolicyCore->>AssemblePolicyCore: collectAgentBinaries(matched components)
AssemblePolicyCore->>NetworkPolicy: attach agentBinaries to MCP/pkg_node policies
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" 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. Comment |
Applied fixes from bot review comments: - Comment #3539183377: Add claude.ai and platform.claude.com to claude-code.yaml to prevent extra agent_anthropic entry (SC-001) - Comment #3539222279: Fix contract doc to describe shared groups as builtin components, not tool matches - Comment #3539222282: Add language tag to fenced code block in data-model.md - Comment #3539222287: Fix plan.md to show vertex-ai.yaml as credential-matched (consistent with research.md R5) - Comment #3539222304: Align FR-005 with component-based binary collection design Assisted-By: 🤖 Claude Code
Applied fixes from bot review comments: - Comment #3539249153: Fix docs to show correct opencode.yaml endpoints (api.openai.com, openrouter.ai) - Comment #3539249185: Rewrite dedup test to verify actual endpoint deduplication via shared domain groups - Comment #3539249234: Remove stray nonroot-write.txt test artifact from source tree - Comment #3539262510: Same as above (Devin also flagged) Assisted-By: 🤖 Claude Code
Each agent adapter declares required domain groups via RequiredDomainGroups() on the Agent interface. The build system queries agent adapters based on the manifest's agents list, replacing hardcoded claude_code matching with generic agent-based component selection. Key changes: - Add RequiredDomainGroups() to Agent interface - Add Agents field to Manifest and MatchCondition structs - Replace match: always: true with match: agents: [claude] - Generalize MCP binary lookup via collectAgentBinaries() - Add AllowedDomainsPerAgent for per-agent domain config - Add openai builtin group and opencode.yaml policy component - Centralize default agent logic in Manifest.EffectiveAgents() Backward compatible: manifests without agents field default to ["claude"]. Assisted-By: 🤖 Claude Code
455f2a1 to
d505e1b
Compare
| - host: claude.ai | ||
| port: 443 | ||
| - host: platform.claude.com | ||
| port: 443 |
There was a problem hiding this comment.
🟡 New endpoints added to the Claude Code policy component break the stated backward-compatibility guarantee
Two new endpoint entries are added to the Claude Code policy component (claude.ai:443 and platform.claude.com:443 at cc-deck/internal/build/policies/claude-code.yaml:16-19) alongside the match-condition change, so existing single-agent Claude builds produce different policy output than before.
Impact: Users upgrading cc-deck will see their generated OpenShell policies change unexpectedly, which may cause policy-diff validation failures or require re-approval of sandbox configurations.
Spec requirement SC-001 and the verification gap
The feature spec at specs/078-network-policy-generalization/spec.md:106 states:
SC-001: A build with only Claude Code configured produces a policy byte-identical to the current output (zero regression)
The task list at specs/078-network-policy-generalization/tasks.md:105 marks T030 as complete:
Verify backward compatibility: build a policy with an existing manifest (no agents field) and diff against the pre-change output
However, the actual test TestAssemblePolicy_ExplicitClaudeAgent at cc-deck/internal/build/policy_test.go:1448-1462 only verifies that agents: nil and agents: [claude] produce the same output as each other. It does not compare against the pre-change baseline.
The old claude-code.yaml had 5 endpoints:
api.anthropic.com,statsig.anthropic.com,sentry.io,downloads.claude.ai,raw.githubusercontent.com
The new file has 7 endpoints, adding claude.ai and platform.claude.com. These additions are unrelated to the network policy generalization feature (changing always: true to agents: [claude]) and should be in a separate change if SC-001 is to be honored.
Prompt for agents
The claude-code.yaml file has two new endpoints (claude.ai:443 and platform.claude.com:443) added in the same PR that changes the match condition from always:true to agents:[claude]. The spec requirement SC-001 requires byte-identical policy output for single-agent Claude builds before and after this change. Either remove the two new endpoints from this PR and add them in a separate change, or update SC-001 in the spec to acknowledge the intentional endpoint additions and update the backward-compatibility test to verify only the structural equivalence (match condition change) rather than byte-identical output.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
specs/078-network-policy-generalization/spec.md (1)
51-53: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winAlign this scenario with the component-based binary flow.
The scenario still says MCP endpoint processing uses the agent interface to locate binaries, but FR-005 and D5 both chose component-based binary collection instead. Update the wording so the spec does not point implementers back to the discarded approach.
Proposed fix
- **Given** the current `policy.go` with `if comp.Key == "claude_code"`, **When** the generalization is applied, **Then** MCP endpoint processing uses the agent interface to locate binaries for any agent, not just Claude Code. + **Given** the current `policy.go` with `if comp.Key == "claude_code"`, **When** the generalization is applied, **Then** MCP endpoint processing collects binaries from agent-matched policy components for any agent, not just Claude Code.🤖 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 `@specs/078-network-policy-generalization/spec.md` around lines 51 - 53, The scenario wording still refers to MCP endpoint processing using the agent interface to locate binaries, which conflicts with the chosen component-based binary flow. Update the spec text in the generalized network policy scenario so it describes component-based binary collection and policy matching, and remove any reference to agent-interface binary lookup; use the existing terms from `claude-code.yaml` and `policy.go` to keep the scenario aligned with the implemented approach.
🤖 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 `@cc-deck/brainstorm/idea-inbox.md`:
- Around line 5-14: The markdown heading hierarchy in idea-inbox.md skips from
the document title to level 3, which breaks heading increment rules. Update the
idea section headings such as credential-aware-domain-resolution and
agent-name-validation to use the same level as other top-level ideas, and ensure
the surrounding structure stays consistent with the existing markdown in that
file.
---
Duplicate comments:
In `@specs/078-network-policy-generalization/spec.md`:
- Around line 51-53: The scenario wording still refers to MCP endpoint
processing using the agent interface to locate binaries, which conflicts with
the chosen component-based binary flow. Update the spec text in the generalized
network policy scenario so it describes component-based binary collection and
policy matching, and remove any reference to agent-interface binary lookup; use
the existing terms from `claude-code.yaml` and `policy.go` to keep the scenario
aligned with the implemented approach.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3b5422de-2317-44a3-b774-60d6fd2df733
📒 Files selected for processing (28)
README.mdcc-deck/CLAUDE.mdcc-deck/brainstorm/idea-inbox.mdcc-deck/internal/agent/agent.gocc-deck/internal/agent/claude.gocc-deck/internal/agent/claude_test.gocc-deck/internal/agent/opencode.gocc-deck/internal/agent/opencode_test.gocc-deck/internal/agent/registry_test.gocc-deck/internal/build/component.gocc-deck/internal/build/component_test.gocc-deck/internal/build/manifest.gocc-deck/internal/build/policies/claude-code.yamlcc-deck/internal/build/policies/opencode.yamlcc-deck/internal/build/policy.gocc-deck/internal/build/policy_test.gocc-deck/internal/cmd/ws_new_test.gocc-deck/internal/credential/resolve_test.gocc-deck/internal/network/builtin.godocs/modules/reference/pages/configuration.adocspecs/078-network-policy-generalization/checklists/requirements.mdspecs/078-network-policy-generalization/contracts/agent-domain-groups.mdspecs/078-network-policy-generalization/data-model.mdspecs/078-network-policy-generalization/plan.mdspecs/078-network-policy-generalization/research.mdspecs/078-network-policy-generalization/review-findings.mdspecs/078-network-policy-generalization/spec.mdspecs/078-network-policy-generalization/tasks.md
✅ Files skipped from review due to trivial changes (7)
- specs/078-network-policy-generalization/checklists/requirements.md
- cc-deck/internal/agent/registry_test.go
- cc-deck/CLAUDE.md
- cc-deck/internal/network/builtin.go
- cc-deck/internal/cmd/ws_new_test.go
- cc-deck/internal/credential/resolve_test.go
- README.md
🚧 Files skipped from review as they are similar to previous changes (12)
- cc-deck/internal/agent/agent.go
- cc-deck/internal/agent/opencode.go
- cc-deck/internal/build/policies/opencode.yaml
- cc-deck/internal/agent/claude_test.go
- cc-deck/internal/agent/claude.go
- cc-deck/internal/agent/opencode_test.go
- docs/modules/reference/pages/configuration.adoc
- cc-deck/internal/build/component.go
- cc-deck/internal/build/policy.go
- cc-deck/internal/build/component_test.go
- cc-deck/internal/build/policy_test.go
- cc-deck/internal/build/manifest.go
| ### credential-aware-domain-resolution | ||
|
|
||
| - **Source**: triage | ||
| - **Date**: 2026-07-07 | ||
| - **Reference**: PR #10 (078-network-policy-generalization) | ||
| - **Summary**: Agents that support multiple credential backends (e.g., OpenCode supports both OpenAI and Anthropic) only declare their primary API domain group. When a user configures an alternate credential mode, the required domains for that backend are missing from the generated policy. Additionally, the policy component endpoint list and the builtin domain group can diverge (e.g., openrouter.ai in opencode.yaml but not in the openai builtin group). | ||
|
|
||
| > Devin flagged that OpenCodeAgent.RequiredDomainGroups() returns only ["openai"] despite CredentialSpecs() declaring both openai and anthropic modes. Separately, opencode.yaml includes openrouter.ai:443 but the openai builtin group does not, creating asymmetry between sandbox and container-level domain filtering. | ||
|
|
||
| ### agent-name-validation |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Fix the heading hierarchy.
### jumps from the title straight to level 3 and will trip markdownlint's heading-increment rule. Make both idea headings ##.
Proposed fix
-### credential-aware-domain-resolution
+## credential-aware-domain-resolution
@@
-### agent-name-validation
+## agent-name-validation📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ### credential-aware-domain-resolution | |
| - **Source**: triage | |
| - **Date**: 2026-07-07 | |
| - **Reference**: PR #10 (078-network-policy-generalization) | |
| - **Summary**: Agents that support multiple credential backends (e.g., OpenCode supports both OpenAI and Anthropic) only declare their primary API domain group. When a user configures an alternate credential mode, the required domains for that backend are missing from the generated policy. Additionally, the policy component endpoint list and the builtin domain group can diverge (e.g., openrouter.ai in opencode.yaml but not in the openai builtin group). | |
| > Devin flagged that OpenCodeAgent.RequiredDomainGroups() returns only ["openai"] despite CredentialSpecs() declaring both openai and anthropic modes. Separately, opencode.yaml includes openrouter.ai:443 but the openai builtin group does not, creating asymmetry between sandbox and container-level domain filtering. | |
| ### agent-name-validation | |
| ## credential-aware-domain-resolution | |
| - **Source**: triage | |
| - **Date**: 2026-07-07 | |
| - **Reference**: PR `#10` (078-network-policy-generalization) | |
| - **Summary**: Agents that support multiple credential backends (e.g., OpenCode supports both OpenAI and Anthropic) only declare their primary API domain group. When a user configures an alternate credential mode, the required domains for that backend are missing from the generated policy. Additionally, the policy component endpoint list and the builtin domain group can diverge (e.g., openrouter.ai in opencode.yaml but not in the openai builtin group). | |
| > Devin flagged that OpenCodeAgent.RequiredDomainGroups() returns only ["openai"] despite CredentialSpecs() declaring both openai and anthropic modes. Separately, opencode.yaml includes openrouter.ai:443 but the openai builtin group does not, creating asymmetry between sandbox and container-level domain filtering. | |
| ## agent-name-validation |
🧰 Tools
🪛 LanguageTool
[grammar] ~10-~10: Ensure spelling is correct
Context: ... policy component endpoint list and the builtin domain group can diverge (e.g., openrou...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
[grammar] ~10-~10: Ensure spelling is correct
Context: ... in opencode.yaml but not in the openai builtin group). > Devin flagged that OpenCodeA...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🪛 markdownlint-cli2 (0.22.1)
[warning] 5-5: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
🤖 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 `@cc-deck/brainstorm/idea-inbox.md` around lines 5 - 14, The markdown heading
hierarchy in idea-inbox.md skips from the document title to level 3, which
breaks heading increment rules. Update the idea section headings such as
credential-aware-domain-resolution and agent-name-validation to use the same
level as other top-level ideas, and ensure the surrounding structure stays
consistent with the existing markdown in that file.
Source: Linters/SAST tools
Summary
Implementation of Network Policy Generalization for multi-agent support.
Each agent adapter now declares which domain groups it requires via a new
RequiredDomainGroups()method on the Agent interface. The build system queries these declarations and composes network policies based on which agents are listed in the manifest.Key changes:
RequiredDomainGroups() []stringto theAgentinterfaceAgentsfield to the build manifest andMatchConditionstructclaude-code.yamlfrommatch: always: truetomatch: agents: [claude]if comp.Key == "claude_code"with genericcollectAgentBinaries()AllowedDomainsPerAgentfor per-agent domain group configurationopenaibuiltin domain group andopencode.yamlpolicy componentManifest.EffectiveAgents()Backward compatible: manifests without an
agentsfield default to["claude"].Artifacts
specs/078-network-policy-generalization/spec.mdspecs/078-network-policy-generalization/plan.mdspecs/078-network-policy-generalization/tasks.mdAssisted-By: 🤖 Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation