Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
root = true

[*.{kt,kts}]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
max_line_length = 120

ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL

# Disable wildcard imports entirely
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
ij_kotlin_packages_to_use_import_on_demand = unset

ktlint_code_style = ktlint_official
ktlint_standard_annotation = disabled
ktlint_standard_class-naming = disabled
ktlint_standard_class-signature = disabled
ktlint_standard_filename = disabled
ktlint_standard_function-expression-body = disabled
ktlint_standard_function-signature = disabled
ktlint_standard_if-else-bracing = enabled
ktlint_standard_if-else-wrapping = enabled
ktlint_standard_no-consecutive-comments = disabled
ktlint_standard_no-single-line-block-comment = disabled
ktlint_standard_property-naming = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
ktlint_standard_try-catch-finally-spacing = enabled
ktlint_standard_backing-property-naming = disabled

[**/build/**/*]
ktlint = disabled
15 changes: 11 additions & 4 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,29 @@ on:
branches: [main]

jobs:
build:
lint:
name: Lint Code Base
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
statuses: write

steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Lint Code Base
- name: GitHub Super Linter
uses: super-linter/super-linter/slim@v8
env:
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LOG_LEVEL: WARN
SHELLCHECK_OPTS: -e SC1091 -e 2086
VALIDATE_ALL_CODEBASE: false
FILTER_REGEX_EXCLUDE: "^(\\.github/|\\.vscode/).*"
FILTER_REGEX_EXCLUDE: "^(\\.github/|\\.vscode/).*|CODE_OF_CONDUCT.md|(extensions/agp/).*"
VALIDATE_PYTHON_BLACK: false
VALIDATE_PYTHON_FLAKE8: false
VALIDATE_PYTHON_ISORT: false
Expand All @@ -44,3 +48,6 @@ jobs:
VALIDATE_JUPYTER_NBQA_PYLINT: false
VALIDATE_JUPYTER_NBQA_RUFF: false
VALIDATE_TRIVY: false
VALIDATE_BIOME_FORMAT: false
VALIDATE_BIOME_LINT: false
VALIDATE_GITHUB_ACTIONS_ZIZMOR: false
124 changes: 124 additions & 0 deletions extensions/agp/agp_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import logging

from agp_protocol import (
AGPTable,
AgentGatewayProtocol,
CapabilityAnnouncement,
IntentPayload,
)


# Set logging level to WARNING so only our custom routing failures are visible
logging.basicConfig(level=logging.WARNING)


def run_simulation():
"""Simulates the core routing process of the Agent Gateway Protocol (AGP),
demonstrating Policy-Based Routing and cost optimization.
"""
# --- PHASE 1: Setup and Announcement ---

# 1. Initialize the central routing table
corporate_agp_table = AGPTable()

# 2. Initialize the Corporate Gateway Agent (Router)
corporate_gateway = AgentGatewayProtocol(
squad_name='Corporate_GW', agp_table=corporate_agp_table
)

# 3. Squads announce their capabilities to the Corporate Gateway

print('===============================================================')
print(' AGENT GATEWAY PROTOCOL (AGP) ROUTING SIMULATION')
print('===============================================================')
print('\n--- PHASE 1: SQUAD ANNOUNCEMENTS ---')

# --- Announcement 1: Engineering Squad (Internal, Secure) ---
# Can provision VMs, handles sensitive data (PII), but is more expensive than the external vendor.
eng_announcement = CapabilityAnnouncement(
capability='infra:provision:vm',
version='1.0',
cost=0.10, # Higher cost
policy={'security_level': 5, 'requires_PII': True},
)
corporate_gateway.announce_capability(
eng_announcement, path='Squad_Engineering/vm_provisioner'
)

# --- Announcement 2: External Vendor Squad (Cheapest, Low Security) ---
# Can provision VMs, but fails the PII check and only meets standard security.
vendor_announcement = CapabilityAnnouncement(
capability='infra:provision:vm',
version='1.1',
cost=0.05, # Lowest cost
policy={'security_level': 3, 'requires_PII': False},
)
corporate_gateway.announce_capability(
vendor_announcement, path='External_Vendor/vm_provisioning_api'
)

# --- Announcement 3: Finance Squad (Standard Analysis) ---
finance_announcement = CapabilityAnnouncement(
capability='financial_analysis:quarterly',
version='2.0',
cost=0.15,
policy={'security_level': 3, 'geo': 'US'},
)
corporate_gateway.announce_capability(
finance_announcement, path='Squad_Finance/analysis_tool'
)

# --- PHASE 2: Intent Routing Simulation ---

print('\n--- PHASE 2: INTENT ROUTING ---')

# Intent A: Standard VM provisioning (Cost-driven, minimal policy)
# Expected: Route to External Vendor (Cost: 0.05) because it's cheapest and complies with security_level: 3.
intent_a = IntentPayload(
target_capability='infra:provision:vm',
payload={'type': 'standard', 'user': 'bob'},
policy_constraints={'security_level': 3},
)
print(
'\n[Intent A] Requesting standard VM provisioning (Lowest cost, Security Level 3).'
)
corporate_gateway.route_intent(intent_a)

# Intent B: Sensitive VM provisioning (Policy-driven, requires PII)
# Expected: Route to Engineering Squad (Cost: 0.10) because the External Vendor (0.05) fails the PII policy.
# The router uses the sufficiency check (5 >= 5 is True).
intent_b = IntentPayload(
target_capability='infra:provision:vm',
payload={'type': 'sensitive', 'user': 'alice', 'data': 'ssn_data'},
policy_constraints={'security_level': 5, 'requires_PII': True},
)
print(
'\n[Intent B] Requesting sensitive VM provisioning (Requires PII and Security Level 5).'
)
corporate_gateway.route_intent(intent_b)

# Intent C: Requesting provisioning with security level 7 (Unmatched Policy)
# Expected: Fails because no announced route can satisfy level 7.
intent_c = IntentPayload(
target_capability='infra:provision:vm',
payload={'type': 'max_security'},
policy_constraints={'security_level': 7},
)
print(
'\n[Intent C] Requesting provisioning with security level 7 (Unmatched Policy).'
)
corporate_gateway.route_intent(intent_c)

# Intent D: Requesting HR onboarding (Unknown Capability)
# Expected: Fails because the capability was never announced.
intent_d = IntentPayload(
target_capability='hr:onboard:new_hire',
payload={'employee': 'Charlie'},
policy_constraints={},
)
print('\n[Intent D] Requesting HR onboarding (Unknown Capability).')
corporate_gateway.route_intent(intent_d)


if __name__ == '__main__':
run_simulation()
Loading