@aporthq/aport-agent-guardrails 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/LICENSE +217 -0
  2. package/README.md +481 -0
  3. package/bin/agent-guardrails +133 -0
  4. package/bin/aport-create-passport.sh +444 -0
  5. package/bin/aport-cursor-hook.sh +90 -0
  6. package/bin/aport-guardrail-api.sh +108 -0
  7. package/bin/aport-guardrail-bash.sh +394 -0
  8. package/bin/aport-guardrail-v2.sh +5 -0
  9. package/bin/aport-guardrail.sh +5 -0
  10. package/bin/aport-resolve-paths.sh +71 -0
  11. package/bin/aport-status.sh +276 -0
  12. package/bin/frameworks/crewai.sh +49 -0
  13. package/bin/frameworks/cursor.sh +95 -0
  14. package/bin/frameworks/langchain.sh +48 -0
  15. package/bin/frameworks/n8n.sh +36 -0
  16. package/bin/frameworks/openclaw.sh +19 -0
  17. package/bin/lib/allowlist.sh +18 -0
  18. package/bin/lib/common.sh +28 -0
  19. package/bin/lib/config.sh +46 -0
  20. package/bin/lib/constants.sh +232 -0
  21. package/bin/lib/detect.sh +65 -0
  22. package/bin/lib/error.sh +269 -0
  23. package/bin/lib/passport.sh +19 -0
  24. package/bin/lib/templates/.gitkeep +1 -0
  25. package/bin/lib/templates/config.yaml +6 -0
  26. package/bin/lib/validation.sh +206 -0
  27. package/bin/openclaw +660 -0
  28. package/docs/ADDING_A_FRAMEWORK.md +87 -0
  29. package/docs/AGENTS.md.example +40 -0
  30. package/docs/CODE_REVIEW.md +192 -0
  31. package/docs/DEPLOYMENT_READINESS.md +81 -0
  32. package/docs/FAQ_SECURITY_SCANNERS.md +373 -0
  33. package/docs/FRAMEWORK_ROADMAP.md +41 -0
  34. package/docs/HOSTED_PASSPORT_SETUP.md +362 -0
  35. package/docs/IMPLEMENTING_YOUR_OWN_EVALUATOR.md +433 -0
  36. package/docs/OPENCLAW_COMPATIBILITY.md +73 -0
  37. package/docs/OPENCLAW_LOCAL_INTEGRATION.md +596 -0
  38. package/docs/OPENCLAW_TOOLS_AND_POLICIES.md +54 -0
  39. package/docs/QUICKSTART.md +470 -0
  40. package/docs/QUICKSTART_OPENCLAW_PLUGIN.md +470 -0
  41. package/docs/README.md +28 -0
  42. package/docs/RELEASE.md +87 -0
  43. package/docs/REPO_LAYOUT.md +47 -0
  44. package/docs/SKILLS_ECOSYSTEM_ANALYSIS_FEB17.md +1260 -0
  45. package/docs/TOOL_POLICY_MAPPING.md +46 -0
  46. package/docs/UPGRADE.md +46 -0
  47. package/docs/VERIFICATION_METHODS.md +97 -0
  48. package/docs/assets/README.md +8 -0
  49. package/docs/assets/porter.svg +54 -0
  50. package/docs/development/ERROR_CODES.md +616 -0
  51. package/docs/frameworks/GITHUB_ISSUE_PROPOSALS.md +1105 -0
  52. package/docs/frameworks/crewai.md +114 -0
  53. package/docs/frameworks/cursor.md +159 -0
  54. package/docs/frameworks/langchain.md +72 -0
  55. package/docs/frameworks/n8n.md +40 -0
  56. package/docs/frameworks/openclaw.md +40 -0
  57. package/docs/launch/ADD_APORT_AWESOME_LISTS_INSTRUCTIONS.md +146 -0
  58. package/docs/launch/ANNOUNCEMENT_GUIDE.md +266 -0
  59. package/docs/launch/AWESOME_REPOS.md +53 -0
  60. package/docs/launch/CURSOR_VSCODE_HOOKS_RESEARCH.md +77 -0
  61. package/docs/launch/DEMO_TERMINAL_OUTPUT.txt +48 -0
  62. package/docs/launch/DRY_AND_PLAN_CHECKLIST.md +47 -0
  63. package/docs/launch/EVIDENCE_README.md +61 -0
  64. package/docs/launch/EVIDENCE_TERMINAL_CAPTURE.txt +10 -0
  65. package/docs/launch/FRAMEWORK_SUPPORT_PLAN.md +1640 -0
  66. package/docs/launch/LAUNCH_READINESS_CHECKLIST.md +237 -0
  67. package/docs/launch/LAUNCH_STRATEGY_SUMMARY.md +464 -0
  68. package/docs/launch/OPENCLAW_FEEDBACK_AND_FIXES.md +85 -0
  69. package/docs/launch/POST_1_VALENTINE_IMPROVED.md +233 -0
  70. package/docs/launch/POST_2_GUARDRAIL_IMPROVED.md +369 -0
  71. package/docs/launch/PRE_LAUNCH_FIXES.md +766 -0
  72. package/docs/launch/QUICK_LAUNCH_CHECKLIST.md +400 -0
  73. package/docs/launch/READINESS_SUMMARY.md +262 -0
  74. package/docs/launch/README.md +68 -0
  75. package/docs/launch/USER_STORIES.md +327 -0
  76. package/docs/launch/scripts/add-aport-awesome-pr.sh +69 -0
  77. package/docs/operations/MONITORING.md +588 -0
  78. package/docs/reviews/2026-02-18-staff-review.md +268 -0
  79. package/extensions/openclaw-aport/README.md +415 -0
  80. package/extensions/openclaw-aport/index.js +625 -0
  81. package/extensions/openclaw-aport/openclaw-aport.js +7 -0
  82. package/extensions/openclaw-aport/openclaw.plugin.json +46 -0
  83. package/extensions/openclaw-aport/package.json +36 -0
  84. package/extensions/openclaw-aport/test.js +307 -0
  85. package/external/aport-policies/README.md +363 -0
  86. package/external/aport-policies/agent.session.create.v1/README.md +345 -0
  87. package/external/aport-policies/agent.session.create.v1/policy.json +162 -0
  88. package/external/aport-policies/agent.tool.register.v1/README.md +361 -0
  89. package/external/aport-policies/agent.tool.register.v1/policy.json +172 -0
  90. package/external/aport-policies/code.release.publish.v1/README.md +51 -0
  91. package/external/aport-policies/code.release.publish.v1/policy.json +121 -0
  92. package/external/aport-policies/code.repository.merge.v1/README.md +287 -0
  93. package/external/aport-policies/code.repository.merge.v1/express.example.js +332 -0
  94. package/external/aport-policies/code.repository.merge.v1/fastapi.example.py +370 -0
  95. package/external/aport-policies/code.repository.merge.v1/policy.json +162 -0
  96. package/external/aport-policies/data.export.create.v1/README.md +226 -0
  97. package/external/aport-policies/data.export.create.v1/express.example.js +172 -0
  98. package/external/aport-policies/data.export.create.v1/fastapi.example.py +165 -0
  99. package/external/aport-policies/data.export.create.v1/policy.json +133 -0
  100. package/external/aport-policies/data.report.ingest.v1/README.md +134 -0
  101. package/external/aport-policies/data.report.ingest.v1/express.example.js +105 -0
  102. package/external/aport-policies/data.report.ingest.v1/minimal-example.js +68 -0
  103. package/external/aport-policies/data.report.ingest.v1/policy.json +174 -0
  104. package/external/aport-policies/finance.crypto.trade.v1/README.md +146 -0
  105. package/external/aport-policies/finance.crypto.trade.v1/express.example.js +109 -0
  106. package/external/aport-policies/finance.crypto.trade.v1/minimal-example.js +65 -0
  107. package/external/aport-policies/finance.crypto.trade.v1/policy.json +176 -0
  108. package/external/aport-policies/finance.payment.charge.v1/README.md +326 -0
  109. package/external/aport-policies/finance.payment.charge.v1/express.example.js +250 -0
  110. package/external/aport-policies/finance.payment.charge.v1/fastapi.example.py +227 -0
  111. package/external/aport-policies/finance.payment.charge.v1/minimal-example.js +64 -0
  112. package/external/aport-policies/finance.payment.charge.v1/policy.json +224 -0
  113. package/external/aport-policies/finance.payment.charge.v1/tests/contexts.jsonl +12 -0
  114. package/external/aport-policies/finance.payment.charge.v1/tests/expected.jsonl +12 -0
  115. package/external/aport-policies/finance.payment.charge.v1/tests/passport.instance.json +42 -0
  116. package/external/aport-policies/finance.payment.charge.v1/tests/passport.template.json +40 -0
  117. package/external/aport-policies/finance.payment.charge.v1/tests/payments-charge-policy.test.js +817 -0
  118. package/external/aport-policies/finance.payment.charge.v1/tests/test_payments_charge_policy.py +486 -0
  119. package/external/aport-policies/finance.payment.payout.v1/README.md +78 -0
  120. package/external/aport-policies/finance.payment.payout.v1/policy.json +181 -0
  121. package/external/aport-policies/finance.payment.refund.v1/README.md +275 -0
  122. package/external/aport-policies/finance.payment.refund.v1/express.example.js +167 -0
  123. package/external/aport-policies/finance.payment.refund.v1/fastapi.example.py +136 -0
  124. package/external/aport-policies/finance.payment.refund.v1/minimal-example.js +183 -0
  125. package/external/aport-policies/finance.payment.refund.v1/policy.json +216 -0
  126. package/external/aport-policies/finance.payment.refund.v1/tests/refunds-policy.test.js +924 -0
  127. package/external/aport-policies/finance.payment.refund.v1/tests/test_refunds_policy.py +778 -0
  128. package/external/aport-policies/finance.transaction.execute.v1/README.md +309 -0
  129. package/external/aport-policies/finance.transaction.execute.v1/express.example.js +261 -0
  130. package/external/aport-policies/finance.transaction.execute.v1/fastapi.example.py +231 -0
  131. package/external/aport-policies/finance.transaction.execute.v1/minimal-example.js +78 -0
  132. package/external/aport-policies/finance.transaction.execute.v1/policy.json +189 -0
  133. package/external/aport-policies/finance.transaction.execute.v1/tests/contexts.jsonl +12 -0
  134. package/external/aport-policies/finance.transaction.execute.v1/tests/expected.jsonl +12 -0
  135. package/external/aport-policies/finance.transaction.execute.v1/tests/passport.instance.json +42 -0
  136. package/external/aport-policies/finance.transaction.execute.v1/tests/passport.template.json +42 -0
  137. package/external/aport-policies/finance.transaction.execute.v1/tests/test_transactions_policy.py +214 -0
  138. package/external/aport-policies/finance.transaction.execute.v1/tests/transactions-policy.test.js +306 -0
  139. package/external/aport-policies/governance.data.access.v1/README.md +292 -0
  140. package/external/aport-policies/governance.data.access.v1/express.example.js +321 -0
  141. package/external/aport-policies/governance.data.access.v1/fastapi.example.py +279 -0
  142. package/external/aport-policies/governance.data.access.v1/minimal-example.js +65 -0
  143. package/external/aport-policies/governance.data.access.v1/policy.json +208 -0
  144. package/external/aport-policies/governance.data.access.v1/tests/contexts.jsonl +12 -0
  145. package/external/aport-policies/governance.data.access.v1/tests/data-access-policy.test.js +308 -0
  146. package/external/aport-policies/governance.data.access.v1/tests/expected.jsonl +12 -0
  147. package/external/aport-policies/governance.data.access.v1/tests/passport.instance.json +56 -0
  148. package/external/aport-policies/governance.data.access.v1/tests/passport.template.json +56 -0
  149. package/external/aport-policies/governance.data.access.v1/tests/test_data_access_policy.py +214 -0
  150. package/external/aport-policies/legal.contract.review.v1/README.md +109 -0
  151. package/external/aport-policies/legal.contract.review.v1/policy.json +378 -0
  152. package/external/aport-policies/legal.contract.review.v1/tests/legal-contract-review-policy.test.js +609 -0
  153. package/external/aport-policies/legal.contract.review.v1/tests/passport.template.json +49 -0
  154. package/external/aport-policies/mcp.tool.execute.v1/README.md +301 -0
  155. package/external/aport-policies/mcp.tool.execute.v1/policy.json +141 -0
  156. package/external/aport-policies/messaging.message.send.v1/README.md +230 -0
  157. package/external/aport-policies/messaging.message.send.v1/express.example.js +183 -0
  158. package/external/aport-policies/messaging.message.send.v1/fastapi.example.py +193 -0
  159. package/external/aport-policies/messaging.message.send.v1/policy.json +144 -0
  160. package/external/aport-policies/policy-template.json +107 -0
  161. package/external/aport-policies/system.command.execute.v1/README.md +275 -0
  162. package/external/aport-policies/system.command.execute.v1/policy.json +146 -0
  163. package/external/aport-spec/CONTRIBUTING.md +273 -0
  164. package/external/aport-spec/LICENSE +21 -0
  165. package/external/aport-spec/README.md +168 -0
  166. package/external/aport-spec/conformance/README.md +294 -0
  167. package/external/aport-spec/conformance/cases/data.export.v1/contexts/allow_users.json +6 -0
  168. package/external/aport-spec/conformance/cases/data.export.v1/contexts/deny_pii.json +6 -0
  169. package/external/aport-spec/conformance/cases/data.export.v1/expected/allow_users.decision.json +19 -0
  170. package/external/aport-spec/conformance/cases/data.export.v1/expected/deny_pii.decision.json +19 -0
  171. package/external/aport-spec/conformance/cases/data.export.v1/passports/template.json +29 -0
  172. package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/allow_50usd.json +9 -0
  173. package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/deny_150usd.json +9 -0
  174. package/external/aport-spec/conformance/cases/payments.refunds.v1/contexts/deny_currency.json +9 -0
  175. package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/allow_50usd.decision.json +19 -0
  176. package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/deny_150usd.decision.json +19 -0
  177. package/external/aport-spec/conformance/cases/payments.refunds.v1/expected/deny_currency.decision.json +19 -0
  178. package/external/aport-spec/conformance/cases/payments.refunds.v1/passports/template.json +42 -0
  179. package/external/aport-spec/conformance/package.json +44 -0
  180. package/external/aport-spec/conformance/pnpm-lock.yaml +642 -0
  181. package/external/aport-spec/conformance/src/cases.ts +371 -0
  182. package/external/aport-spec/conformance/src/ed25519.ts +167 -0
  183. package/external/aport-spec/conformance/src/jcs.ts +85 -0
  184. package/external/aport-spec/conformance/src/runner.ts +533 -0
  185. package/external/aport-spec/conformance/src/validators.ts +185 -0
  186. package/external/aport-spec/conformance/test-runner.js +315 -0
  187. package/external/aport-spec/conformance/tsconfig.json +21 -0
  188. package/external/aport-spec/error-schema.json +192 -0
  189. package/external/aport-spec/index.json +12 -0
  190. package/external/aport-spec/integrations/clawmoat/README.md +12 -0
  191. package/external/aport-spec/integrations/shield/README.md +245 -0
  192. package/external/aport-spec/integrations/shield/adapters/index.js +116 -0
  193. package/external/aport-spec/integrations/shield/adapters/system-command-execute.js +133 -0
  194. package/external/aport-spec/integrations/shield/test/README.md +58 -0
  195. package/external/aport-spec/integrations/shield/test/shield.md +40 -0
  196. package/external/aport-spec/integrations/shield/test/test-shield-to-verify.js +274 -0
  197. package/external/aport-spec/metrics-schema.json +504 -0
  198. package/external/aport-spec/oap/CHANGELOG.md +54 -0
  199. package/external/aport-spec/oap/VERSION.md +40 -0
  200. package/external/aport-spec/oap/capability-registry.md +229 -0
  201. package/external/aport-spec/oap/conformance.md +257 -0
  202. package/external/aport-spec/oap/decision-schema.json +114 -0
  203. package/external/aport-spec/oap/examples/context.refund.usd.50.json +9 -0
  204. package/external/aport-spec/oap/examples/decision.allow.sample.json +20 -0
  205. package/external/aport-spec/oap/examples/decision.deny.sample.json +23 -0
  206. package/external/aport-spec/oap/examples/passport.instance.v1.json +50 -0
  207. package/external/aport-spec/oap/examples/passport.template.v1.json +71 -0
  208. package/external/aport-spec/oap/oap-spec.md +426 -0
  209. package/external/aport-spec/oap/passport-schema.json +396 -0
  210. package/external/aport-spec/oap/security.md +213 -0
  211. package/external/aport-spec/oap/vc/context-oap-v1.jsonld +137 -0
  212. package/external/aport-spec/oap/vc/examples/oap-decision-vc.json +37 -0
  213. package/external/aport-spec/oap/vc/examples/oap-passport-vc.json +68 -0
  214. package/external/aport-spec/oap/vc/tools/INTEGRATION.md +375 -0
  215. package/external/aport-spec/oap/vc/tools/README.md +278 -0
  216. package/external/aport-spec/oap/vc/tools/examples/decision-to-vc.js +66 -0
  217. package/external/aport-spec/oap/vc/tools/examples/passport-to-vc.js +83 -0
  218. package/external/aport-spec/oap/vc/tools/examples/vc-to-decision.js +77 -0
  219. package/external/aport-spec/oap/vc/tools/examples/vc-to-passport.js +94 -0
  220. package/external/aport-spec/oap/vc/tools/package.json +38 -0
  221. package/external/aport-spec/oap/vc/tools/pnpm-lock.yaml +472 -0
  222. package/external/aport-spec/oap/vc/tools/src/cli.ts +226 -0
  223. package/external/aport-spec/oap/vc/tools/src/crypto-utils.ts +427 -0
  224. package/external/aport-spec/oap/vc/tools/src/index.ts +653 -0
  225. package/external/aport-spec/oap/vc/tools/src/test.ts +148 -0
  226. package/external/aport-spec/oap/vc/tools/src/vp.ts +382 -0
  227. package/external/aport-spec/oap/vc/tools/test-simple.js +214 -0
  228. package/external/aport-spec/oap/vc/tools/tsconfig.json +19 -0
  229. package/external/aport-spec/oap/vc/vc-mapping.md +443 -0
  230. package/external/aport-spec/passport-schema.json +586 -0
  231. package/external/aport-spec/rate-limiting.md +136 -0
  232. package/external/aport-spec/transport-profile.md +325 -0
  233. package/external/aport-spec/webhook-spec.md +314 -0
  234. package/package.json +70 -0
  235. package/skills/aport-agent-guardrail/SKILL.md +314 -0
  236. package/src/evaluator.js +252 -0
  237. package/src/server/index.js +72 -0
@@ -0,0 +1,616 @@
1
+ # APort Error Codes Reference
2
+
3
+ This document defines all error codes used in APort Agent Guardrails. Error codes follow the format: `oap.<category>.<specific>`
4
+
5
+ ## Error Code Format
6
+
7
+ ```
8
+ oap.<category>.<specific>
9
+ ```
10
+
11
+ - **oap**: Prefix for all Open Agent Passport errors
12
+ - **category**: Broad category (invalid_input, policy, passport, api, etc.)
13
+ - **specific**: Specific error type
14
+
15
+ ## Error Response Format
16
+
17
+ ### JSON Format (Python/API)
18
+
19
+ ```json
20
+ {
21
+ "allow": false,
22
+ "reasons": [{
23
+ "code": "oap.invalid_input.tool_name",
24
+ "message": "Tool name contains invalid characters",
25
+ "details": {
26
+ "tool_name": "rm; malicious",
27
+ "allowed_pattern": "^[a-zA-Z0-9._-]+$"
28
+ }
29
+ }],
30
+ "request_id": "req_1234567890",
31
+ "timestamp": "2026-02-19T10:30:00Z"
32
+ }
33
+ ```
34
+
35
+ ### Text Format (Bash)
36
+
37
+ ```
38
+ ERROR: oap.invalid_input.tool_name
39
+ Tool name contains invalid characters
40
+ Details: tool_name='rm; malicious', allowed_pattern='^[a-zA-Z0-9._-]+$'
41
+ Request ID: req_1234567890
42
+ ```
43
+
44
+ ---
45
+
46
+ ## Error Categories
47
+
48
+ ### 1. Invalid Input Errors (`oap.invalid_input.*`)
49
+
50
+ #### `oap.invalid_input.tool_name`
51
+ **Description**: Tool name contains invalid characters or exceeds length limit
52
+
53
+ **Cause**: Tool name doesn't match pattern `^[a-zA-Z0-9._-]+$` or exceeds 128 characters
54
+
55
+ **Resolution**:
56
+ - Use only alphanumeric characters, dots, underscores, and hyphens in tool names
57
+ - Keep tool names under 128 characters
58
+
59
+ **Example**:
60
+ ```json
61
+ {
62
+ "code": "oap.invalid_input.tool_name",
63
+ "message": "Tool name contains invalid characters",
64
+ "details": {
65
+ "tool_name": "rm; malicious",
66
+ "allowed_pattern": "^[a-zA-Z0-9._-]+$",
67
+ "max_length": 128
68
+ }
69
+ }
70
+ ```
71
+
72
+ #### `oap.invalid_input.context_too_large`
73
+ **Description**: Context JSON exceeds maximum size limit
74
+
75
+ **Cause**: Context data is larger than 100KB
76
+
77
+ **Resolution**:
78
+ - Reduce context data size
79
+ - Remove unnecessary fields
80
+ - Consider summarizing large data
81
+
82
+ **Configuration**: Set `APORT_MAX_CONTEXT_SIZE` to increase limit (not recommended)
83
+
84
+ #### `oap.invalid_input.context_too_nested`
85
+ **Description**: Context JSON nesting depth exceeds limit
86
+
87
+ **Cause**: Context has more than 10 levels of nesting
88
+
89
+ **Resolution**:
90
+ - Flatten nested structures
91
+ - Use simpler data representation
92
+
93
+ #### `oap.invalid_input.context_not_serializable`
94
+ **Description**: Context cannot be serialized to JSON
95
+
96
+ **Cause**: Context contains non-JSON-serializable objects
97
+
98
+ **Resolution**:
99
+ - Ensure all context values are JSON-serializable types
100
+ - Convert objects to dictionaries before passing as context
101
+
102
+ #### `oap.invalid_input.agent_id`
103
+ **Description**: Agent ID has invalid format
104
+
105
+ **Cause**: Agent ID doesn't match expected format `^ap_[a-zA-Z0-9_]+$`
106
+
107
+ **Resolution**:
108
+ - Use agent IDs from APort API
109
+ - Format: `ap_` prefix followed by alphanumeric characters
110
+
111
+ #### `oap.invalid_input.policy_pack_id`
112
+ **Description**: Policy pack ID contains invalid characters
113
+
114
+ **Cause**: Policy pack ID doesn't match pattern `^[a-zA-Z0-9._-]+$`
115
+
116
+ **Resolution**:
117
+ - Use valid policy pack IDs from APort policies
118
+ - Follow naming convention: `category.subcategory.action.v#`
119
+
120
+ ---
121
+
122
+ ### 2. Path Security Errors (`oap.path.*`)
123
+
124
+ #### `oap.path.not_allowed`
125
+ **Description**: File path is outside allowed directories
126
+
127
+ **Cause**: Path is not within `~/.openclaw/`, `~/.aport/`, or `/tmp/aport-*`
128
+
129
+ **Resolution**:
130
+ - Use standard APort directories for passports and config
131
+ - Contact administrator to add custom allowed directories
132
+
133
+ **Security Note**: This is a security feature to prevent path traversal attacks
134
+
135
+ #### `oap.path.traversal_attempt`
136
+ **Description**: Path contains traversal sequences
137
+
138
+ **Cause**: Path contains `../` or `/..` sequences
139
+
140
+ **Resolution**:
141
+ - Use absolute paths
142
+ - Remove parent directory references
143
+
144
+ **Security Note**: Path traversal attempts are blocked for security
145
+
146
+ #### `oap.path.invalid_characters`
147
+ **Description**: Path contains invalid characters
148
+
149
+ **Cause**: Path contains null bytes or other dangerous characters
150
+
151
+ **Resolution**:
152
+ - Use standard filesystem-safe characters
153
+ - Remove special characters from paths
154
+
155
+ #### `oap.path.resolution_error`
156
+ **Description**: Failed to resolve path to absolute location
157
+
158
+ **Cause**: Path doesn't exist or filesystem error
159
+
160
+ **Resolution**:
161
+ - Verify path exists
162
+ - Check filesystem permissions
163
+ - Verify filesystem is mounted
164
+
165
+ ---
166
+
167
+ ### 3. Passport Errors (`oap.passport.*`)
168
+
169
+ #### `oap.passport.not_found`
170
+ **Description**: Passport file not found
171
+
172
+ **Cause**: No passport file at expected location
173
+
174
+ **Resolution**:
175
+ ```bash
176
+ # Create a passport
177
+ npx @aporthq/agent-guardrails openclaw
178
+ # Or
179
+ aport-create-passport.sh
180
+ ```
181
+
182
+ **See**: [Passport Setup Guide](https://github.com/aporthq/agent-guardrails#passport-setup)
183
+
184
+ #### `oap.passport.invalid_format`
185
+ **Description**: Passport file is not valid JSON or missing required fields
186
+
187
+ **Cause**: Passport file is corrupted or manually edited incorrectly
188
+
189
+ **Resolution**:
190
+ - Regenerate passport using official tools
191
+ - Do not manually edit passport files
192
+ - Verify JSON syntax is valid
193
+
194
+ **Required Fields**: `passport_id`, `agent_id`, `owner`, `status`, `spec_version`, `capabilities`
195
+
196
+ #### `oap.passport.expired`
197
+ **Description**: Passport has expired
198
+
199
+ **Cause**: `expires_at` timestamp is in the past
200
+
201
+ **Resolution**:
202
+ - Generate new passport
203
+ - Contact APort administrator for renewal
204
+
205
+ #### `oap.passport.revoked`
206
+ **Description**: Passport has been revoked
207
+
208
+ **Cause**: `status` field is `"revoked"`
209
+
210
+ **Resolution**:
211
+ - Contact APort administrator
212
+ - Generate new passport if authorized
213
+
214
+ #### `oap.passport.missing_capability`
215
+ **Description**: Passport doesn't have required capability for operation
216
+
217
+ **Cause**: Capability not listed in passport's `capabilities` array
218
+
219
+ **Resolution**:
220
+ - Request capability be added to passport
221
+ - Generate new passport with required capabilities
222
+ - Use different operation that doesn't require this capability
223
+
224
+ **Example**:
225
+ ```json
226
+ {
227
+ "code": "oap.passport.missing_capability",
228
+ "message": "Passport lacks required capability: git.repository.merge",
229
+ "details": {
230
+ "required_capability": "git.repository.merge",
231
+ "passport_capabilities": ["system.command.execute", "messaging.message.send"]
232
+ }
233
+ }
234
+ ```
235
+
236
+ ---
237
+
238
+ ### 4. Policy Errors (`oap.policy.*`)
239
+
240
+ #### `oap.policy.not_found`
241
+ **Description**: Policy pack not found
242
+
243
+ **Cause**: Policy pack doesn't exist in policies directory
244
+
245
+ **Resolution**:
246
+ - Verify policy pack ID is correct
247
+ - Update policy submodule: `git submodule update --init --recursive`
248
+ - Check policy pack version exists
249
+
250
+ #### `oap.policy.invalid_format`
251
+ **Description**: Policy pack file is invalid
252
+
253
+ **Cause**: Policy JSON is malformed or missing required fields
254
+
255
+ **Resolution**:
256
+ - Update policy submodule to latest version
257
+ - Report issue if policy pack is from official repository
258
+
259
+ #### `oap.policy.evaluation_failed`
260
+ **Description**: Policy evaluation encountered an error
261
+
262
+ **Cause**: Logic error in policy rules or invalid data
263
+
264
+ **Resolution**:
265
+ - Check audit log for details
266
+ - Verify context data is complete
267
+ - Report issue if policy is from official repository
268
+
269
+ #### `oap.policy.evaluation_timeout`
270
+ **Description**: Policy evaluation exceeded timeout
271
+
272
+ **Cause**: Complex policy or infinite loop in evaluation
273
+
274
+ **Resolution**:
275
+ - Simplify policy rules
276
+ - Increase timeout: `APORT_SUBPROCESS_TIMEOUT=60`
277
+ - Report performance issue to policy maintainer
278
+
279
+ **Configuration**: Default timeout is 30 seconds
280
+
281
+ #### `oap.policy.denied`
282
+ **Description**: Operation denied by policy
283
+
284
+ **Cause**: Operation violates policy rules
285
+
286
+ **Resolution**: This is expected behavior. The operation is not allowed by your current policy configuration.
287
+
288
+ **Common Reasons**:
289
+ - Command not in allowed list
290
+ - Limit exceeded (e.g., max files in PR)
291
+ - Pattern matched blocked list
292
+ - Missing approval requirement
293
+
294
+ ---
295
+
296
+ ### 5. API Errors (`oap.api.*`)
297
+
298
+ #### `oap.api.connection_failed`
299
+ **Description**: Failed to connect to APort API
300
+
301
+ **Cause**: Network error, API down, or wrong URL
302
+
303
+ **Resolution**:
304
+ - Check internet connectivity
305
+ - Verify API URL: `echo $APORT_API_URL`
306
+ - Check API status: https://status.aport.io
307
+ - Verify firewall allows outbound HTTPS
308
+
309
+ **Configuration**: `APORT_API_URL` (default: https://api.aport.io)
310
+
311
+ #### `oap.api.authentication_failed`
312
+ **Description**: API authentication failed
313
+
314
+ **Cause**: Invalid or missing API key
315
+
316
+ **Resolution**:
317
+ - Verify API key is set: `echo $APORT_API_KEY | head -c 8`
318
+ - Generate new API key from APort dashboard
319
+ - Check key format: should start with `aprt_`
320
+
321
+ **Configuration**: `APORT_API_KEY`
322
+
323
+ #### `oap.api.rate_limit_exceeded`
324
+ **Description**: API rate limit exceeded
325
+
326
+ **Cause**: Too many requests in time window
327
+
328
+ **Resolution**:
329
+ - Wait for rate limit to reset (see `retry-after` header)
330
+ - Reduce request frequency
331
+ - Contact APort for higher rate limits
332
+ - Use local evaluation mode instead of API mode
333
+
334
+ **Configuration**: Default: 60 requests/minute per agent
335
+
336
+ #### `oap.api.timeout`
337
+ **Description**: API request timed out
338
+
339
+ **Cause**: Slow network or API overload
340
+
341
+ **Resolution**:
342
+ - Retry request
343
+ - Increase timeout: `APORT_API_TIMEOUT=30`
344
+ - Check network latency to API
345
+
346
+ #### `oap.api.invalid_response`
347
+ **Description**: API returned invalid response format
348
+
349
+ **Cause**: API error or version mismatch
350
+
351
+ **Resolution**:
352
+ - Check API status
353
+ - Update client library to latest version
354
+ - Report issue with request ID
355
+
356
+ #### `oap.api.not_found_404`
357
+ **Description**: Resource not found (404)
358
+
359
+ **Cause**: Agent ID, policy pack, or passport not found in API
360
+
361
+ **Resolution**:
362
+ - Verify agent ID is correct
363
+ - Check resource exists in APort dashboard
364
+ - Verify API URL is correct
365
+
366
+ ---
367
+
368
+ ### 6. Configuration Errors (`oap.config.*`)
369
+
370
+ #### `oap.config.not_found`
371
+ **Description**: Configuration file not found
372
+
373
+ **Cause**: No config file at expected locations
374
+
375
+ **Resolution**:
376
+ - Run setup: `npx @aporthq/agent-guardrails <framework>`
377
+ - Create config manually in `~/.aport/<framework>/config.yaml`
378
+
379
+ **Expected Locations**:
380
+ - `~/.aport/<framework>/config.yaml`
381
+ - `~/.openclaw/config.yaml`
382
+ - `./.aport/config.yaml`
383
+
384
+ #### `oap.config.invalid_format`
385
+ **Description**: Configuration file is invalid YAML/JSON
386
+
387
+ **Cause**: Syntax error in config file
388
+
389
+ **Resolution**:
390
+ - Validate YAML syntax
391
+ - Regenerate config with setup tool
392
+ - Check for tabs vs. spaces in YAML
393
+
394
+ #### `oap.config.missing_required`
395
+ **Description**: Required configuration option is missing
396
+
397
+ **Cause**: Config file missing required field
398
+
399
+ **Resolution**:
400
+ - Add missing field
401
+ - Run setup tool to generate complete config
402
+
403
+ ---
404
+
405
+ ### 7. System Errors (`oap.system.*`)
406
+
407
+ #### `oap.system.evaluator_error`
408
+ **Description**: Guardrail script execution failed
409
+
410
+ **Cause**: Script error or missing dependency
411
+
412
+ **Resolution**:
413
+ - Check script exists: `which aport-guardrail.sh`
414
+ - Verify dependencies: `jq`, `bash`, `grep`
415
+ - Check script permissions: `chmod +x`
416
+ - Review error logs
417
+
418
+ #### `oap.system.command_injection_detected`
419
+ **Description**: Potential command injection attempt blocked
420
+
421
+ **Cause**: Input contains bash metacharacters
422
+
423
+ **Resolution**: This is a security feature. Do not attempt to bypass.
424
+
425
+ **Security Note**: Commands with these characters are blocked: `$`, `` ` ``, `|`, `&`, `;`, `<`, `>`, `()`, `{}`, `[]`, `*`, `?`, `\`
426
+
427
+ #### `oap.system.dependency_missing`
428
+ **Description**: Required system dependency not found
429
+
430
+ **Cause**: Missing `jq`, `curl`, or other required tool
431
+
432
+ **Resolution**:
433
+ ```bash
434
+ # macOS
435
+ brew install jq
436
+
437
+ # Ubuntu/Debian
438
+ sudo apt-get install jq
439
+
440
+ # RHEL/CentOS
441
+ sudo yum install jq
442
+ ```
443
+
444
+ #### `oap.system.insufficient_permissions`
445
+ **Description**: Insufficient file system permissions
446
+
447
+ **Cause**: Cannot read passport/config or write decision/logs
448
+
449
+ **Resolution**:
450
+ - Check file permissions
451
+ - Verify user has read access to config directories
452
+ - Verify user has write access to data directories
453
+
454
+ ---
455
+
456
+ ### 8. Rate Limiting Errors (`oap.rate_limit.*`)
457
+
458
+ #### `oap.rate_limit.exceeded`
459
+ **Description**: Request rate limit exceeded
460
+
461
+ **Cause**: Too many requests in time window
462
+
463
+ **Resolution**:
464
+ - Wait for rate limit reset
465
+ - Check `retry-after` seconds in response
466
+ - Reduce request frequency
467
+
468
+ **Configuration**:
469
+ - `APORT_RATE_LIMIT_REQUESTS_PER_MINUTE` (default: 60)
470
+ - `APORT_RATE_LIMIT_BURST` (default: 10)
471
+
472
+ #### `oap.rate_limit.per_agent`
473
+ **Description**: Per-agent rate limit exceeded
474
+
475
+ **Cause**: Specific agent exceeded its rate limit
476
+
477
+ **Resolution**:
478
+ - Isolates rate limiting per agent
479
+ - One agent's high usage doesn't affect others
480
+ - Wait for reset or optimize agent behavior
481
+
482
+ ---
483
+
484
+ ### 9. Validation Errors (`oap.validation.*`)
485
+
486
+ #### `oap.validation.failed`
487
+ **Description**: Generic validation failure
488
+
489
+ **Cause**: Input failed validation checks
490
+
491
+ **Resolution**: See details field for specific validation failure
492
+
493
+ #### `oap.validation.required_field`
494
+ **Description**: Required field is missing
495
+
496
+ **Cause**: Missing required field in request
497
+
498
+ **Resolution**: Add required field to request
499
+
500
+ #### `oap.validation.invalid_format`
501
+ **Description**: Field has invalid format
502
+
503
+ **Cause**: Field doesn't match expected format
504
+
505
+ **Resolution**: Check field format in API documentation
506
+
507
+ ---
508
+
509
+ ### 10. Misconfigured Errors (`oap.misconfigured.*`)
510
+
511
+ #### `oap.misconfigured`
512
+ **Description**: System is misconfigured and cannot operate
513
+
514
+ **Cause**: Missing passport or guardrail script in local mode
515
+
516
+ **Resolution**:
517
+ ```bash
518
+ # Check passport exists
519
+ ls -la ~/.openclaw/passport.json
520
+
521
+ # Check guardrail script exists
522
+ ls -la ~/.openclaw/.skills/aport-guardrail.sh
523
+
524
+ # Run setup if missing
525
+ npx @aporthq/agent-guardrails openclaw
526
+ ```
527
+
528
+ **Legacy Mode**: Set `APORT_FAIL_OPEN_WHEN_MISSING_CONFIG=1` to allow by default (not recommended)
529
+
530
+ ---
531
+
532
+ ## Error Handling Best Practices
533
+
534
+ ### For Users
535
+
536
+ 1. **Read the error message carefully** - Error messages include resolution steps
537
+ 2. **Check the error code** - Use this document to understand the issue
538
+ 3. **Look at error details** - Additional context is in the `details` field
539
+ 4. **Check configuration** - Many errors are due to misconfiguration
540
+ 5. **Review logs** - Audit logs contain additional context
541
+
542
+ ### For Developers
543
+
544
+ 1. **Always include error codes** - Use constants from this document
545
+ 2. **Provide actionable messages** - Tell users how to fix the issue
546
+ 3. **Include context in details** - Add relevant data to help debugging
547
+ 4. **Log security events** - All security-related errors should be audited
548
+ 5. **Use structured format** - Follow JSON/text format standards
549
+
550
+ ### Example: Good Error Handling
551
+
552
+ ```python
553
+ from aport_guardrails.core.validation import validate_tool_name
554
+ from aport_guardrails.core.errors import ErrorCode, create_error_response
555
+
556
+ def evaluate_tool(tool_name: str, context: dict):
557
+ # Validate input
558
+ validation_result = validate_tool_name(tool_name)
559
+ if not validation_result.valid:
560
+ return create_error_response(
561
+ code=ErrorCode.INVALID_TOOL_NAME,
562
+ message=validation_result.error_message,
563
+ details=validation_result.details,
564
+ resolution="Use only alphanumeric characters, dots, underscores, and hyphens"
565
+ )
566
+
567
+ # Continue with evaluation...
568
+ ```
569
+
570
+ ---
571
+
572
+ ## Troubleshooting by Error Category
573
+
574
+ ### Security Errors
575
+ - **DO NOT** try to bypass security features
576
+ - **DO** report potential false positives
577
+ - **DO** review security documentation
578
+
579
+ ### Configuration Errors
580
+ - **Start with**: Run setup wizard
581
+ - **Check**: Environment variables
582
+ - **Verify**: File locations and permissions
583
+
584
+ ### API Errors
585
+ - **Check**: Network connectivity
586
+ - **Verify**: API keys and credentials
587
+ - **Review**: API status page
588
+
589
+ ### Policy Errors
590
+ - **Understand**: Policy rules and limits
591
+ - **Request**: Policy modifications from administrator
592
+ - **Alternative**: Use different operation
593
+
594
+ ---
595
+
596
+ ## Request IDs
597
+
598
+ All errors include a unique request ID for tracking and debugging:
599
+
600
+ **Format**: `req_<timestamp>_<random>`
601
+
602
+ **Example**: `req_1771528805673_2y4gr0`
603
+
604
+ **Usage**:
605
+ - Include in bug reports
606
+ - Reference in support requests
607
+ - Correlate with audit logs
608
+
609
+ ---
610
+
611
+ ## See Also
612
+
613
+ - [Security Policy](../../SECURITY.md)
614
+ - [Configuration Guide](../user/CONFIGURATION.md)
615
+ - [Troubleshooting Guide](../user/TROUBLESHOOTING.md)
616
+ - [API Reference](../api/README.md)