diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 313932a..e424410 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -426,11 +426,11 @@ describe('APortIntegration', () => { }); // Act - const result = await integration.verify('payments.refund.v1', 'agt_123'); + const result = await integration.verify('finance.payment.refund.v1', 'agt_123'); // Assert expect(result.verified).toBe(true); - expect(mockAPortAPI.verify).toHaveBeenCalledWith('payments.refund.v1', 'agt_123'); + expect(mockAPortAPI.verify).toHaveBeenCalledWith('finance.payment.refund.v1', 'agt_123'); }); it('should handle verification failure', async () => { @@ -438,7 +438,7 @@ describe('APortIntegration', () => { mockAPortAPI.verify.mockRejectedValue(new Error('Verification failed')); // Act & Assert - await expect(integration.verify('payments.refund.v1', 'agt_123')) + await expect(integration.verify('finance.payment.refund.v1', 'agt_123')) .rejects.toThrow('Verification failed'); }); }); @@ -461,7 +461,7 @@ describe('APortIntegration', () => { ```javascript /** * Verifies an agent against a policy pack - * @param {string} policy - Policy pack identifier (e.g., 'payments.refund.v1') + * @param {string} policy - Policy pack identifier (e.g., 'finance.payment.refund.v1') * @param {string} agentId - Agent identifier (e.g., 'agt_inst_xyz789') * @param {Object} context - Additional context for verification * @param {string} context.userId - User ID for user-specific policies @@ -469,7 +469,7 @@ describe('APortIntegration', () => { * @returns {Promise} Verification result * @throws {APortError} If verification fails * @example - * const result = await integration.verify('payments.refund.v1', 'agt_123', { + * const result = await integration.verify('finance.payment.refund.v1', 'agt_123', { * userId: 'user_456', * metadata: { amount: 100 } * }); diff --git a/README.md b/README.md index 80a862c..77cbea9 100644 --- a/README.md +++ b/README.md @@ -266,7 +266,7 @@ const aportMiddleware = createAPortMiddleware({ }); app.post("/api/refunds", - aportMiddleware("payments.refund.v1"), + aportMiddleware("finance.payment.refund.v1"), async (req, res) => { // Policy already verified! Check specific limits const passport = req.aport.passport; @@ -326,7 +326,7 @@ protected_refund_tool = APortToolGuard( description="Process customer refunds", func=refund_tool ), - policy_pack="payments.refund.v1", + policy_pack="finance.payment.refund.v1", agent_id="agt_inst_xyz789" ) @@ -349,7 +349,7 @@ jobs: - uses: aporthq/policy-verify-action@v1 with: agent-id: ${{ secrets.APORT_AGENT_ID }} - policy-pack: 'repo.v1' + policy-pack: 'code.repository.merge.v1' context: | { "repo": "${{ github.repository }}", diff --git a/docs/INTEGRATION_GUIDE.md b/docs/INTEGRATION_GUIDE.md index 2b4e7ce..268a224 100644 --- a/docs/INTEGRATION_GUIDE.md +++ b/docs/INTEGRATION_GUIDE.md @@ -263,11 +263,11 @@ describe('APortIntegration', () => { }); // Act - const result = await integration.verify('payments.refund.v1', 'agt_123'); + const result = await integration.verify('finance.payment.refund.v1', 'agt_123'); // Assert expect(result.verified).toBe(true); - expect(mockAPortAPI.verify).toHaveBeenCalledWith('payments.refund.v1', 'agt_123'); + expect(mockAPortAPI.verify).toHaveBeenCalledWith('finance.payment.refund.v1', 'agt_123'); }); it('should handle verification failure', async () => { @@ -275,7 +275,7 @@ describe('APortIntegration', () => { mockAPortAPI.verify.mockRejectedValue(new Error('Verification failed')); // Act & Assert - await expect(integration.verify('payments.refund.v1', 'agt_123')) + await expect(integration.verify('finance.payment.refund.v1', 'agt_123')) .rejects.toThrow('Verification failed'); }); }); diff --git a/examples/developer-tools/cli/README.md b/examples/developer-tools/cli/README.md index 985da05..f28b7c4 100644 --- a/examples/developer-tools/cli/README.md +++ b/examples/developer-tools/cli/README.md @@ -34,10 +34,10 @@ npm start demo npm start verify -- --interactive # Direct verification with real agent IDs - NO API KEY NEEDED! -npm start verify ap_a2d10232c6534523812423eec8a1425c payments.refund.v1 '{"amount":50}' +npm start verify ap_a2d10232c6534523812423eec8a1425c finance.payment.refund.v1 '{"amount":50}' # Or using options -npm start verify -a ap_a2d10232c6534523812423eec8a1425c -p payments.refund.v1 -c '{"amount":50}' +npm start verify -a ap_a2d10232c6534523812423eec8a1425c -p finance.payment.refund.v1 -c '{"amount":50}' # Get passport information - NO API KEY NEEDED! npm start get-passport -- --interactive @@ -55,10 +55,10 @@ npm start create-passport -- --interactive aport verify --interactive # Direct mode (positional arguments) -aport verify agt_inst_refund_bot_123 payments.refund.v1 '{"amount":50}' +aport verify agt_inst_refund_bot_123 finance.payment.refund.v1 '{"amount":50}' # Direct mode (options) -aport verify -a agt_inst_refund_bot_123 -p payments.refund.v1 -c '{"amount":50}' +aport verify -a agt_inst_refund_bot_123 -p finance.payment.refund.v1 -c '{"amount":50}' ``` ### `policy` - Verify against specific policy pack @@ -113,9 +113,9 @@ The CLI includes pre-configured sample agent IDs for testing: Test against these policy packs: -- `payments.refund.v1` - Refund processing policies +- `finance.payment.refund.v1` - Refund processing policies - `data.export.v1` - Data export policies -- `repo.v1` - Repository operation policies +- `code.repository.merge.v1` - Repository operation policies - `admin.access.v1` - Admin access policies ## 🔧 Configuration @@ -158,7 +158,7 @@ npm start demo ### Example 1: Verify Refund Bot ```bash -aport verify -a agt_inst_refund_bot_123 -p payments.refund.v1 -c '{"amount":50,"currency":"USD"}' +aport verify -a agt_inst_refund_bot_123 -p finance.payment.refund.v1 -c '{"amount":50,"currency":"USD"}' ``` ### Example 2: Create Test Passport diff --git a/examples/developer-tools/cli/src/index.js b/examples/developer-tools/cli/src/index.js index 3efc67b..c7d3270 100644 --- a/examples/developer-tools/cli/src/index.js +++ b/examples/developer-tools/cli/src/index.js @@ -61,9 +61,9 @@ program name: "policy", message: "Select a policy pack:", choices: [ - "payments.refund.v1", + "finance.payment.refund.v1", "data.export.v1", - "repo.v1", + "code.repository.merge.v1", "admin.access.v1", ], }, @@ -372,11 +372,13 @@ program // Demo 1: Verify refund bot console.log( - chalk.yellow("1. Verifying refund bot against payments.refund.v1 policy") + chalk.yellow( + "1. Verifying refund bot against finance.payment.refund.v1 policy" + ) ); try { const result1 = await client.verify( - "payments.refund.v1", + "finance.payment.refund.v1", SAMPLE_AGENTS["refund-bot"], { amount: 50, @@ -449,14 +451,16 @@ program }); console.log(chalk.yellow("\nPolicy Packs:")); - console.log(" payments.refund.v1 # Refund processing"); + console.log(" finance.payment.refund.v1 # Refund processing"); console.log(" data.export.v1 # Data export"); - console.log(" repo.v1 # Repository operations"); + console.log( + " code.repository.merge.v1 # Repository operations" + ); console.log(" admin.access.v1 # Admin access\n"); console.log(chalk.yellow("Examples (No API Key Needed!):")); console.log( - " aport verify -a ap_a2d10232c6534523812423eec8a1425c -p payments.refund.v1 -c '{\"amount\":50}'" + " aport verify -a ap_a2d10232c6534523812423eec8a1425c -p finance.payment.refund.v1 -c '{\"amount\":50}'" ); console.log( " aport policy -a ap_b804b365003247888c06c94347cf54fe -p data.export.v1 -c '{\"rows\":1000}'" diff --git a/scripts/create-hacktoberfest-issues-complete.sh b/scripts/create-hacktoberfest-issues-complete.sh index 1bb9565..0e653a9 100755 --- a/scripts/create-hacktoberfest-issues-complete.sh +++ b/scripts/create-hacktoberfest-issues-complete.sh @@ -267,7 +267,7 @@ create_issue_interactive \ "Complete production-ready Shopify app using APort to verify refund requests via webhooks. ## Success Criteria -- Deployable app in /examples/shopify-guardrail using payments.refund.v1 policy +- Deployable app in /examples/shopify-guardrail using finance.payment.refund.v1 policy - Complete Shopify app with APort verification - Refund processing with policy checks - Comprehensive tests and documentation diff --git a/templates/javascript-middleware/README.md b/templates/javascript-middleware/README.md index 413c3df..2d6005c 100644 --- a/templates/javascript-middleware/README.md +++ b/templates/javascript-middleware/README.md @@ -40,7 +40,7 @@ const aportMiddleware = createAPortMiddleware({ // Protect a route app.post('/refund', - aportMiddleware('payments.refund.v1'), + aportMiddleware('finance.payment.refund.v1'), (req, res) => { // Agent is verified, access passport data const { passport, agentId } = req.aport; @@ -103,7 +103,7 @@ The middleware looks for agent IDs in the following order: ```javascript app.post('/refund', - aportMiddleware('payments.refund.v1'), + aportMiddleware('finance.payment.refund.v1'), (req, res) => { const { passport } = req.aport; diff --git a/templates/javascript-middleware/examples/server.js b/templates/javascript-middleware/examples/server.js index 8e4124b..1c8eb4a 100644 --- a/templates/javascript-middleware/examples/server.js +++ b/templates/javascript-middleware/examples/server.js @@ -20,7 +20,8 @@ app.get("/", (req, res) => { version: "1.0.0", endpoints: { "GET /public": "Public endpoint (no verification)", - "POST /refund": "Refund endpoint (requires payments.refund.v1 policy)", + "POST /refund": + "Refund endpoint (requires finance.payment.refund.v1 policy)", "GET /admin": "Admin endpoint (requires admin.access policy)", }, }); @@ -37,7 +38,7 @@ app.get("/public", (req, res) => { // Refund endpoint (requires verification) app.post( "/refund", - aportMiddleware("payments.refund.v1", { + aportMiddleware("finance.payment.refund.v1", { context: { endpoint: "refund", action: "process_refund", diff --git a/templates/javascript-middleware/tests/integration.test.js b/templates/javascript-middleware/tests/integration.test.js index 6af068e..7143333 100644 --- a/templates/javascript-middleware/tests/integration.test.js +++ b/templates/javascript-middleware/tests/integration.test.js @@ -33,12 +33,16 @@ describe("APort Express Middleware", () => { res.json({ message: "public" }); }); - app.post("/refund", aportMiddleware("payments.refund.v1"), (req, res) => { - res.json({ - success: true, - agentId: req.aport.agentId, - }); - }); + app.post( + "/refund", + aportMiddleware("finance.payment.refund.v1"), + (req, res) => { + res.json({ + success: true, + agentId: req.aport.agentId, + }); + } + ); }); afterEach(() => { @@ -74,7 +78,7 @@ describe("APort Express Middleware", () => { expect(response.body.success).toBe(true); expect(response.body.agentId).toBe("agt_test123"); expect(mockClient.verify).toHaveBeenCalledWith( - "payments.refund.v1", + "finance.payment.refund.v1", "agt_test123", expect.any(Object) ); @@ -132,7 +136,7 @@ describe("APort Express Middleware", () => { .expect(200); expect(mockClient.verify).toHaveBeenCalledWith( - "payments.refund.v1", + "finance.payment.refund.v1", "agt_header123", expect.any(Object) ); @@ -150,7 +154,7 @@ describe("APort Express Middleware", () => { .expect(200); expect(mockClient.verify).toHaveBeenCalledWith( - "payments.refund.v1", + "finance.payment.refund.v1", "agt_query123", expect.any(Object) ); @@ -171,7 +175,7 @@ describe("APort Express Middleware", () => { .expect(200); expect(mockClient.verify).toHaveBeenCalledWith( - "payments.refund.v1", + "finance.payment.refund.v1", "agt_body123", expect.any(Object) ); diff --git a/templates/python-middleware/README.md b/templates/python-middleware/README.md index 47c9881..aa32827 100644 --- a/templates/python-middleware/README.md +++ b/templates/python-middleware/README.md @@ -42,7 +42,7 @@ aport_middleware = APortMiddleware( async def process_refund( request: Request, aport_data: dict = Depends( - aport_middleware.require_policy("payments.refund.v1") + aport_middleware.require_policy("finance.payment.refund.v1") ) ): # Agent is verified, access passport data @@ -120,7 +120,7 @@ The middleware looks for agent IDs in the following order: async def process_refund( request: Request, aport_data: dict = Depends( - aport_middleware.require_policy("payments.refund.v1") + aport_middleware.require_policy("finance.payment.refund.v1") ) ): passport = aport_data["passport"] diff --git a/templates/python-middleware/examples/server.py b/templates/python-middleware/examples/server.py index af94b3e..6fd504f 100644 --- a/templates/python-middleware/examples/server.py +++ b/templates/python-middleware/examples/server.py @@ -41,7 +41,7 @@ async def root(): "version": "1.0.0", "endpoints": { "GET /public": "Public endpoint (no verification)", - "POST /refund": "Refund endpoint (requires payments.refund.v1 policy)", + "POST /refund": "Refund endpoint (requires finance.payment.refund.v1 policy)", "GET /admin": "Admin endpoint (requires admin.access policy)" } } @@ -59,7 +59,7 @@ async def process_refund( request: RefundRequest, aport_data: Dict[str, Any] = Depends( aport_middleware.require_policy( - "payments.refund.v1", + "finance.payment.refund.v1", context={"endpoint": "refund", "action": "process_refund"} ) ) diff --git a/templates/python-middleware/tests/test_middleware.py b/templates/python-middleware/tests/test_middleware.py index 61e3bbc..dbce82e 100644 --- a/templates/python-middleware/tests/test_middleware.py +++ b/templates/python-middleware/tests/test_middleware.py @@ -22,7 +22,7 @@ async def public(): @app.post("/refund") async def refund( request: Request, - aport_data: dict = middleware.require_policy("payments.refund.v1") + aport_data: dict = middleware.require_policy("finance.payment.refund.v1") ): return {"success": True, "agent_id": aport_data["agent_id"]} diff --git a/tools/cli/README.md b/tools/cli/README.md index 985da05..f28b7c4 100644 --- a/tools/cli/README.md +++ b/tools/cli/README.md @@ -34,10 +34,10 @@ npm start demo npm start verify -- --interactive # Direct verification with real agent IDs - NO API KEY NEEDED! -npm start verify ap_a2d10232c6534523812423eec8a1425c payments.refund.v1 '{"amount":50}' +npm start verify ap_a2d10232c6534523812423eec8a1425c finance.payment.refund.v1 '{"amount":50}' # Or using options -npm start verify -a ap_a2d10232c6534523812423eec8a1425c -p payments.refund.v1 -c '{"amount":50}' +npm start verify -a ap_a2d10232c6534523812423eec8a1425c -p finance.payment.refund.v1 -c '{"amount":50}' # Get passport information - NO API KEY NEEDED! npm start get-passport -- --interactive @@ -55,10 +55,10 @@ npm start create-passport -- --interactive aport verify --interactive # Direct mode (positional arguments) -aport verify agt_inst_refund_bot_123 payments.refund.v1 '{"amount":50}' +aport verify agt_inst_refund_bot_123 finance.payment.refund.v1 '{"amount":50}' # Direct mode (options) -aport verify -a agt_inst_refund_bot_123 -p payments.refund.v1 -c '{"amount":50}' +aport verify -a agt_inst_refund_bot_123 -p finance.payment.refund.v1 -c '{"amount":50}' ``` ### `policy` - Verify against specific policy pack @@ -113,9 +113,9 @@ The CLI includes pre-configured sample agent IDs for testing: Test against these policy packs: -- `payments.refund.v1` - Refund processing policies +- `finance.payment.refund.v1` - Refund processing policies - `data.export.v1` - Data export policies -- `repo.v1` - Repository operation policies +- `code.repository.merge.v1` - Repository operation policies - `admin.access.v1` - Admin access policies ## 🔧 Configuration @@ -158,7 +158,7 @@ npm start demo ### Example 1: Verify Refund Bot ```bash -aport verify -a agt_inst_refund_bot_123 -p payments.refund.v1 -c '{"amount":50,"currency":"USD"}' +aport verify -a agt_inst_refund_bot_123 -p finance.payment.refund.v1 -c '{"amount":50,"currency":"USD"}' ``` ### Example 2: Create Test Passport diff --git a/tools/cli/examples/advanced-usage.js b/tools/cli/examples/advanced-usage.js index 74383fa..23cd44c 100755 --- a/tools/cli/examples/advanced-usage.js +++ b/tools/cli/examples/advanced-usage.js @@ -16,9 +16,9 @@ async function advancedExample() { // Example 1: Batch verification with different policies console.log("1. Batch verification with multiple policies..."); const policies = [ - { policy: "payments.refund.v1", context: { amount: 50 } }, + { policy: "finance.payment.refund.v1", context: { amount: 50 } }, { policy: "data.export.v1", context: { rows: 1000 } }, - { policy: "repo.v1", context: { action: "merge" } }, + { policy: "code.repository.merge.v1", context: { action: "merge" } }, ]; const agentId = "agt_inst_refund_bot_123"; @@ -65,9 +65,13 @@ async function advancedExample() { } }; - const retryResult = await retryVerify("payments.refund.v1", agentId, { - amount: 100, - }); + const retryResult = await retryVerify( + "finance.payment.refund.v1", + agentId, + { + amount: 100, + } + ); console.log( `Retry result: ${retryResult.success ? "✅" : "❌"} (${ retryResult.attempts @@ -110,7 +114,7 @@ async function advancedExample() { // Verify the new passport const verifyNewPassport = await client.verify( - "payments.refund.v1", + "finance.payment.refund.v1", createdPassport.agent_id, { amount: 150, @@ -142,7 +146,9 @@ async function advancedExample() { console.log(`Available policy packs: ${policyPacks.length}`); // Get details for a specific policy pack - const refundPolicy = await client.getPolicyPack("payments.refund.v1"); + const refundPolicy = await client.getPolicyPack( + "finance.payment.refund.v1" + ); console.log(`Refund policy: ${refundPolicy.name || "Unknown"}`); console.log( `Description: ${refundPolicy.description || "No description"}` diff --git a/tools/cli/examples/basic-usage.js b/tools/cli/examples/basic-usage.js index 6a0c092..5e8c1d0 100755 --- a/tools/cli/examples/basic-usage.js +++ b/tools/cli/examples/basic-usage.js @@ -17,7 +17,7 @@ async function basicExample() { // Example 1: Verify a refund bot console.log("1. Verifying refund bot..."); const verifyResult = await client.verify( - "payments.refund.v1", + "finance.payment.refund.v1", "agt_inst_refund_bot_123", { amount: 50, diff --git a/tools/cli/src/client.js b/tools/cli/src/client.js index 4cd10e7..efaa064 100644 --- a/tools/cli/src/client.js +++ b/tools/cli/src/client.js @@ -114,7 +114,7 @@ class APortClient { try { const response = await this.client.get(`/api/verify/${agentId}`, { params: { - policy_pack: "repo.v1", // Use a basic policy for passport retrieval + policy_pack: "code.repository.merge.v1", // Use a basic policy for passport retrieval context: JSON.stringify({}), }, }); diff --git a/tools/cli/src/index.js b/tools/cli/src/index.js index 3efc67b..c7d3270 100755 --- a/tools/cli/src/index.js +++ b/tools/cli/src/index.js @@ -61,9 +61,9 @@ program name: "policy", message: "Select a policy pack:", choices: [ - "payments.refund.v1", + "finance.payment.refund.v1", "data.export.v1", - "repo.v1", + "code.repository.merge.v1", "admin.access.v1", ], }, @@ -372,11 +372,13 @@ program // Demo 1: Verify refund bot console.log( - chalk.yellow("1. Verifying refund bot against payments.refund.v1 policy") + chalk.yellow( + "1. Verifying refund bot against finance.payment.refund.v1 policy" + ) ); try { const result1 = await client.verify( - "payments.refund.v1", + "finance.payment.refund.v1", SAMPLE_AGENTS["refund-bot"], { amount: 50, @@ -449,14 +451,16 @@ program }); console.log(chalk.yellow("\nPolicy Packs:")); - console.log(" payments.refund.v1 # Refund processing"); + console.log(" finance.payment.refund.v1 # Refund processing"); console.log(" data.export.v1 # Data export"); - console.log(" repo.v1 # Repository operations"); + console.log( + " code.repository.merge.v1 # Repository operations" + ); console.log(" admin.access.v1 # Admin access\n"); console.log(chalk.yellow("Examples (No API Key Needed!):")); console.log( - " aport verify -a ap_a2d10232c6534523812423eec8a1425c -p payments.refund.v1 -c '{\"amount\":50}'" + " aport verify -a ap_a2d10232c6534523812423eec8a1425c -p finance.payment.refund.v1 -c '{\"amount\":50}'" ); console.log( " aport policy -a ap_b804b365003247888c06c94347cf54fe -p data.export.v1 -c '{\"rows\":1000}'" diff --git a/tools/cli/test-messaging-policy.js b/tools/cli/test-messaging-policy.js index 0dfbce8..01f04fc 100755 --- a/tools/cli/test-messaging-policy.js +++ b/tools/cli/test-messaging-policy.js @@ -3,7 +3,7 @@ /** * Comprehensive Messaging Policy Tests * - * Tests all limits and validation rules defined in messaging.v1 policy: + * Tests all limits and validation rules defined in messaging.message.send.v1 policy: * - Message length limits (max 2000 characters) * - Required fields validation * - Message type validation @@ -169,7 +169,7 @@ async function runMessagingPolicyTests() { ); const agentId = "ap_a2d10232c6534523812423eec8a1425c"; // Agent with messaging.send capability - const policy = "messaging.v1"; + const policy = "messaging.message.send.v1"; let passed = 0; let failed = 0; diff --git a/tools/cli/tests/client.test.js b/tools/cli/tests/client.test.js index 8ef628e..bea49ae 100644 --- a/tools/cli/tests/client.test.js +++ b/tools/cli/tests/client.test.js @@ -53,9 +53,13 @@ describe("APortClient", () => { post: jest.fn().mockResolvedValue(mockResponse), }); - const result = await client.verify("payments.refund.v1", "test-agent", { - amount: 100, - }); + const result = await client.verify( + "finance.payment.refund.v1", + "test-agent", + { + amount: 100, + } + ); expect(result.verified).toBe(true); expect(result.passport.agent_id).toBe("test-agent"); @@ -73,7 +77,7 @@ describe("APortClient", () => { }); await expect( - client.verify("payments.refund.v1", "invalid-agent") + client.verify("finance.payment.refund.v1", "invalid-agent") ).rejects.toThrow("API Error: Agent not found"); }); @@ -84,7 +88,7 @@ describe("APortClient", () => { }); await expect( - client.verify("payments.refund.v1", "test-agent") + client.verify("finance.payment.refund.v1", "test-agent") ).rejects.toThrow("Network Error: Network Error"); }); });