Skip to content

Fixes #7956: Define shared shadow and enforce governance decisions - #8310

Open
BobSong-dev wants to merge 49 commits into
apache:masterfrom
BobSong-dev:feat/agent-gateway-governance-7956-publication
Open

BobSong-dev wants to merge 49 commits into
apache:masterfrom
BobSong-dev:feat/agent-gateway-governance-7956-publication

Conversation

@BobSong-dev

@BobSong-dev BobSong-dev commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Fixes #7956

Dependency

#8002 merged on November 18, 2026, so it is no longer an outstanding prerequisite. This branch still contains the previously integrated audit snapshot; no new source revision was made for the November 20 CI rerun. Execution integration remains separate quota and budget work.

Background

MCP quotas and LLM budgets need consistent shadow/enforce decisions, without letting shadow mode bypass authentication or resource protection.

Changes

  • Define versioned decisions with bounded reasons, policy/configuration identity, effective time and correlation facts.
  • Turn policy denials into WOULD_DENY in shadow mode while keeping authentication, authorization and resource protection enforced.
  • Add bounded, expiring shadow reservations and generation-aware comparisons, separate from real quota state.
  • Adapt decisions to the existing metadata-only audit contract and low-cardinality metric vocabulary.

Verification

  • Maven-wrapper targeted governance and audit tests: 30 tests, no failures, errors or skips.
  • Reconciled baseline metrics registration: 5 tests passed.
  • Checkstyle, shenyu-common RAT and git diff --check passed.

…ateway-p105

# Conflicts:
#	shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/AgentGatewayPlugin.java
#	shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/protocol/AgentMcpHttpHandler.java
#	shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyEngine.java
#	shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway/src/main/java/org/apache/shenyu/springboot/starter/plugin/agent/gateway/AgentGatewayPluginConfiguration.java
…to integration/agent-gateway-p105

# Conflicts:
#	.github/scripts/test-agent-gateway-migrations.py
#	shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyEngine.java
#	shenyu-plugin/shenyu-plugin-metrics/src/main/java/org/apache/shenyu/plugin/metrics/reporter/MetricsReporter.java
#	shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway/src/main/java/org/apache/shenyu/springboot/starter/plugin/agent/gateway/AgentGatewayPluginConfiguration.java
…nt-gateway-audit-7950-integration

# Conflicts:
#	shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/protocol/AgentMcpDispatcher.java
#	shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/protocol/AgentMcpExecutionContext.java
#	shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/protocol/AgentMcpHttpHandler.java
#	shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyEngine.java
#	shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/test/java/org/apache/shenyu/plugin/ai/proxy/enhanced/AiProxyPluginTest.java
#	shenyu-plugin/shenyu-plugin-metrics/src/main/java/org/apache/shenyu/plugin/metrics/reporter/MetricsReporter.java
#	shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway/src/main/java/org/apache/shenyu/springboot/starter/plugin/agent/gateway/AgentGatewayPluginConfiguration.java
#	shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-ai-proxy/src/main/java/org/apache/shenyu/springboot/starter/plugin/ai/proxy/AiProxyPluginConfiguration.java
…nt-gateway-audit-7950-integration

# Conflicts:
#	shenyu-plugin/shenyu-plugin-metrics/src/main/java/org/apache/shenyu/plugin/metrics/reporter/MetricsReporter.java
#	shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway/src/main/java/org/apache/shenyu/springboot/starter/plugin/agent/gateway/AgentGatewayPluginConfiguration.java
# Conflicts:
#	shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway/src/main/java/org/apache/shenyu/springboot/starter/plugin/agent/gateway/AgentGatewayPluginConfiguration.java
# Conflicts:
#	shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/AiProxyPlugin.java
#	shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/test/java/org/apache/shenyu/plugin/ai/proxy/enhanced/AiProxyPluginTest.java
…ion/agent-gateway-p105

# Conflicts:
#	shenyu-spring-boot-starter/shenyu-spring-boot-starter-plugin/shenyu-spring-boot-starter-plugin-agent-gateway/src/main/java/org/apache/shenyu/springboot/starter/plugin/agent/gateway/AgentGatewayPluginConfiguration.java
@codecov-commenter

codecov-commenter commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.58333% with 98 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.51%. Comparing base (1748a0e) to head (7da40cf).
⚠️ Report is 1424 commits behind head on master.

Files with missing lines Patch % Lines
...mmon/governance/AgentGovernanceDecisionRouter.java 62.00% 8 Missing and 11 partials ⚠️
...henyu/common/audit/AgentInvocationAuditBridge.java 58.53% 12 Missing and 5 partials ⚠️
...common/governance/AgentGovernanceShadowLedger.java 80.89% 7 Missing and 10 partials ⚠️
...shenyu/common/audit/AgentInvocationAuditEvent.java 90.81% 8 Missing and 1 partial ⚠️
...g/apache/shenyu/plugin/key/auth/KeyAuthPlugin.java 47.05% 8 Missing and 1 partial ⚠️
.../org/apache/shenyu/common/dto/ProxyApiKeyData.java 0.00% 8 Missing ⚠️
...nyu/common/governance/AgentGovernanceDecision.java 91.46% 4 Missing and 3 partials ⚠️
...henyu/plugin/agent/gateway/AgentGatewayPlugin.java 78.57% 1 Missing and 2 partials ⚠️
.../gateway/protocol/AgentMcpTerminalObservation.java 62.50% 2 Missing and 1 partial ⚠️
...ent/gateway/protocol/AgentMcpExecutionContext.java 77.77% 1 Missing and 1 partial ⚠️
... and 4 more
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #8310      +/-   ##
============================================
+ Coverage     61.49%   70.51%   +9.01%     
- Complexity     8818    12142    +3324     
============================================
  Files          1261     1172      -89     
  Lines         39273    45420    +6147     
  Branches       3725     5923    +2198     
============================================
+ Hits          24151    32027    +7876     
+ Misses        12952    10373    -2579     
- Partials       2170     3020     +850     
Flag Coverage Δ
client-register-registry 54.30% <ø> (?)
core 67.41% <80.39%> (?)
dist-extra 64.37% <ø> (?)
gateway-runtime 83.65% <ø> (?)
plugin-ai 77.21% <82.14%> (?)
plugin-base 79.85% <100.00%> (?)
plugin-logging 77.65% <ø> (?)
plugin-proxy 77.10% <47.05%> (?)
sync 66.05% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Stream Agent analysis

FINAL synthesis of apache/shenyu PR #8310 at head 8d5f608. 35 partition reviews (part-0..part-34) all PASS with no blocking findings; complete_diff true. CI reported passed=false across 90 checks. A FINAL PASS requires CI passed, so verdict cannot be PASS. No anchored HIGH/CRITICAL defects exist to force NEEDS_CHANGES, thus INCONCLUSIVE.

Evidence

  • CI object: check_count=90, complete=true, passed=false, legacy_state=pending
  • all_parts_passed=true, complete_diff=true, global_complete_diff=true from attachment
  • 35 child partition reviews all review_verdict=PASS with empty blocking_findings

Recommended next steps

  • Inspect CI logs to identify which of the 90 checks failed
  • Fix any build or test failures indicated by CI
  • Re-run FINAL synthesis after CI passes to potentially grant PASS

Scope: captured diff and GitHub check metadata only; no local tests were executed.

Task: 75f2cb08-e85a-40be-94f4-d8c51855025d · Commit: 8d5f60889ba170c5cf8b6df517169526532b6739

Review verdict: INCONCLUSIVE

FINAL scope synthesis of PR #8310 head 8d5f608. All child partitions (35) reported PASS with no HIGH/CRITICAL findings, and diff is complete (complete_diff=true, global_complete_diff=true). However, the provided CI status shows passed=false (complete=true, legacy_state=pending). The FINAL review rule states all_parts_passed must be true, complete_diff true, and CI passed before a FINAL PASS. Since CI did not pass, a PASS verdict is prohibited. There are no anchored defects from children to justify NEEDS_CHANGES, so the only permissible verdict is INCONCLUSIVE. Cross-file correctness cannot be confirmed due to failing CI.

Publication: COMMENT (INCONCLUSIVE_REVIEW)

Review details

All 35 partition reviews passed with no blocking defects and the diff is complete. However, CI did not pass (passed=false). Per review policy, a FINAL PASS requires CI passed, so the synthesis verdict is INCONCLUSIVE. Please investigate CI failures and re-run checks before merging.

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

Stream Agent analysis

PR #8310 (apache/shenyu) at head cdb0298 implements shared shadow/enforce governance decisions and audit instrumentation. All 34 partition reviews (part-0..part-33) returned PASS with no anchored HIGH/CRITICAL findings, complete_diff=true, all_parts_passed=true. However, the supplied CI metadata shows passed=false across 88 checks, so a FINAL PASS cannot be granted per synthesis rules.

Evidence

  • all_parts_passed=true, complete_diff=true across 34 partitions (part-0..part-33)
  • ci.passed=false, ci.complete=true, check_count=88 (from cross-file review JSON)
  • head_sha=cdb0298a3aa42ad6a84a60bbf9c9c30ab9319856, base_sha=585f99da2275459dfaea94bc34aa488aeadc4514

Recommended next steps

  • Investigate CI failure (check_count=88, passed=false) to determine if related to governance/audit changes
  • Confirm shenyu-spring-boot-starter-agent-audit module exists and builds in reactor (dependent PR #8002)
  • Run full integration tests for AgentInvocationAudit bridging and governance decision contracts

Scope: captured diff and GitHub check metadata only; no local tests were executed.

Task: 507e5222-7e11-47e4-969e-41d9add4e1d1 · Commit: cdb0298a3aa42ad6a84a60bbf9c9c30ab9319856

Review verdict: INCONCLUSIVE

SYNTHESIS/FINAL scope: assessed all child review summaries (34 partitions) which all returned PASS with no blocking findings, and global complete_diff=true, all_parts_passed=true. However, the CI status in the supplied evidence shows passed=false (88 checks, complete=true). Per review rules, a FINAL PASS requires all_parts_passed true, complete_diff true AND CI passed. Since CI did not pass, a FINAL PASS cannot be issued. No anchored HIGH/CRITICAL defects exist in partitions, so NEEDS_CHANGES is unwarranted. Thus verdict is INCONCLUSIVE due to unverified CI and cross-module dependency on PR #8002 not fully validated. Reviewed head set to exact head_sha.

Publication: COMMENT (INCONCLUSIVE_REVIEW)

Review details

All scoped partition reviews for PR #8310 passed with complete diff coverage and no blocking defects. Nevertheless, the recorded CI run (88 checks) did not pass. Because a FINAL PASS requires passing CI in addition to all_parts_passed and complete_diff, the synthesis verdict is INCONCLUSIVE. Recommend investigating the CI failure, confirming the audit starter module from dependent PR #8002 is present in the reactor, and running full integration tests before merging.

@BobSong-dev
BobSong-dev marked this pull request as ready for review November 5, 2026 10:50
Aias00
Aias00 previously approved these changes Nov 5, 2026

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

Stream Agent analysis

FINAL synthesis of PR #8310 (apache/shenyu) at head cdb0298 implementing shared shadow/enforce governance decisions and audit baseline. All 34 partition reviews passed with no HIGH/CRITICAL findings; global complete_diff true; CI with 90 checks passed. Cross-file compatibility assessed from child summaries shows consistent contracts for audit events, governance decision routing, and spring wiring.

Evidence

  • All_parts_passed true with 34 partition reviews (part-0..part-33) each verdict PASS and empty blocking_findings
  • ci.passed true, complete true, check_count 90, legacy_state pending but passed
  • global_complete_diff true, head_sha cdb0298 matches reviewed_head

Recommended next steps

  • Merge after confirming dependent PR #8002 audit baseline is integrated in same reactor
  • Monitor runtime audit emission and shadow-mode metrics post-deploy
  • Ensure documentation updates are published with release notes

Scope: captured diff and GitHub check metadata only; no local tests were executed.

Task: 8bbf3d36-1975-4f7c-812c-d9c06f9e5308 · Commit: cdb0298a3aa42ad6a84a60bbf9c9c30ab9319856

Review verdict: PASS

SYNTHESIS/FINAL scope: assessed cross-file correctness from all child partition summaries. All 34 partitions reported PASS with no anchored HIGH/CRITICAL findings. complete_diff and global_complete_diff are true, CI passed (90 checks). No child NEEDS_CHANGES or INCONCLUSIVE to override. Residual uncertainties noted in partitions (e.g., cross-module symbol existence, reactor ordering for audit starter) are mitigated by passing CI and explicit PR description linking to #8002. Therefore FINAL PASS is warranted per guidelines.

Publication: APPROVE (EXPLICIT_PASS)

Review details

Recommendation: Approve and merge PR #8310. All partitioned reviews passed, complete diff reviewed, CI green. The added governance decision, shadow ledger, audit collector, and plugin wiring are internally consistent and backward compatible. No blocking defects identified.

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

Stream Agent analysis

Reviewed #8310 at head a2e3a1d. The PR adds shared shadow/enforce governance decisions (AgentGovernanceDecision, DecisionRouter, ShadowLedger, ContractLabels), an audit subsystem (AgentInvocationAuditEvent/Bridge/Observer/GovernanceAuditAdapter), a new shenyu-spring-boot-starter-agent-audit module, and wires these into the agent-gateway and ai-proxy plugins plus tests. Full pinned diff was read to completion (191,817 chars, final page has_more=false).

Evidence

  • FULL_DIFF: entire pinned diff read; 191,817 characters total, final page offset 189000-191817 reported has_more=false.
  • CI at head a2e3a1d: status complete=true, passed=false; failed checks: build (run 43165009865), test_group (plugin-ai, shenyu-plugin/shenyu-plugin-ai-*) (run 43165009865), build (shenyu-integrated-test-k8s-ingress-http) (run 43165009760).

Recommended next steps

  • Retrieve the failing CI logs for the 'build' and 'test_group (plugin-ai, shenyu-plugin/shenyu-plugin-ai-*)' checks (run 43165009865) to confirm whether the failures are caused by this PR's new agent-audit module wiring/dependencies.
  • If the plugin-ai test_group failure reproduces, anchor the failing assertion to a specific diff path/line/side and re-evaluate for a NEEDS_CHANGES verdict.

Scope: captured diff and GitHub check metadata only; no local tests were executed.

Task: 884be1cf-df98-4f1e-aa8f-92bead09d653 · Commit: a2e3a1de24fdd08ed908f67f395d70241c397747

Review verdict: INCONCLUSIVE

Full diff coverage is achieved and CI status is complete, but CI did not pass at the pinned head: the build, plugin-ai test_group, and k8s-ingress-http build all failed. Because the failing checks' root cause (specific compile error or failing assertion, and whether introduced by this PR) is not present in the provided evidence, a PASS cannot be granted and a line-anchored NEEDS_CHANGES defect cannot be confirmed. Verdict is INCONCLUSIVE pending CI failure details.

Publication: COMMENT (INCONCLUSIVE_REVIEW)

This branch has not been deployed

No deployments
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.

[Task] Define shared shadow and enforce governance decisions

3 participants