planar 0.10.0__py3-none-any.whl → 0.12.0__py3-none-any.whl

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 (73) hide show
  1. planar/app.py +26 -6
  2. planar/cli.py +26 -0
  3. planar/data/__init__.py +1 -0
  4. planar/data/config.py +12 -1
  5. planar/data/connection.py +89 -4
  6. planar/data/dataset.py +13 -7
  7. planar/data/utils.py +145 -25
  8. planar/db/alembic/env.py +68 -57
  9. planar/db/alembic.ini +1 -1
  10. planar/files/storage/config.py +7 -1
  11. planar/routers/dataset_router.py +5 -1
  12. planar/routers/info.py +79 -36
  13. planar/scaffold_templates/pyproject.toml.j2 +1 -1
  14. planar/testing/fixtures.py +7 -4
  15. planar/testing/planar_test_client.py +8 -0
  16. planar/version.py +27 -0
  17. planar-0.12.0.dist-info/METADATA +202 -0
  18. {planar-0.10.0.dist-info → planar-0.12.0.dist-info}/RECORD +20 -71
  19. planar/ai/test_agent_serialization.py +0 -229
  20. planar/ai/test_agent_tool_step_display.py +0 -78
  21. planar/data/test_dataset.py +0 -358
  22. planar/files/storage/test_azure_blob.py +0 -435
  23. planar/files/storage/test_local_directory.py +0 -162
  24. planar/files/storage/test_s3.py +0 -299
  25. planar/files/test_files.py +0 -282
  26. planar/human/test_human.py +0 -385
  27. planar/logging/test_formatter.py +0 -327
  28. planar/modeling/mixins/test_auditable.py +0 -97
  29. planar/modeling/mixins/test_timestamp.py +0 -134
  30. planar/modeling/mixins/test_uuid_primary_key.py +0 -52
  31. planar/routers/test_agents_router.py +0 -174
  32. planar/routers/test_dataset_router.py +0 -429
  33. planar/routers/test_files_router.py +0 -49
  34. planar/routers/test_object_config_router.py +0 -367
  35. planar/routers/test_routes_security.py +0 -168
  36. planar/routers/test_rule_router.py +0 -470
  37. planar/routers/test_workflow_router.py +0 -564
  38. planar/rules/test_data/account_dormancy_management.json +0 -223
  39. planar/rules/test_data/airline_loyalty_points_calculator.json +0 -262
  40. planar/rules/test_data/applicant_risk_assessment.json +0 -435
  41. planar/rules/test_data/booking_fraud_detection.json +0 -407
  42. planar/rules/test_data/cellular_data_rollover_system.json +0 -258
  43. planar/rules/test_data/clinical_trial_eligibility_screener.json +0 -437
  44. planar/rules/test_data/customer_lifetime_value.json +0 -143
  45. planar/rules/test_data/import_duties_calculator.json +0 -289
  46. planar/rules/test_data/insurance_prior_authorization.json +0 -443
  47. planar/rules/test_data/online_check_in_eligibility_system.json +0 -254
  48. planar/rules/test_data/order_consolidation_system.json +0 -375
  49. planar/rules/test_data/portfolio_risk_monitor.json +0 -471
  50. planar/rules/test_data/supply_chain_risk.json +0 -253
  51. planar/rules/test_data/warehouse_cross_docking.json +0 -237
  52. planar/rules/test_rules.py +0 -1494
  53. planar/security/tests/test_auth_middleware.py +0 -162
  54. planar/security/tests/test_authorization_context.py +0 -78
  55. planar/security/tests/test_cedar_basics.py +0 -41
  56. planar/security/tests/test_cedar_policies.py +0 -158
  57. planar/security/tests/test_jwt_principal_context.py +0 -179
  58. planar/test_app.py +0 -142
  59. planar/test_cli.py +0 -394
  60. planar/test_config.py +0 -515
  61. planar/test_object_config.py +0 -527
  62. planar/test_object_registry.py +0 -14
  63. planar/test_sqlalchemy.py +0 -193
  64. planar/test_utils.py +0 -105
  65. planar/testing/test_memory_storage.py +0 -143
  66. planar/workflows/test_concurrency_detection.py +0 -120
  67. planar/workflows/test_lock_timeout.py +0 -140
  68. planar/workflows/test_serialization.py +0 -1203
  69. planar/workflows/test_suspend_deserialization.py +0 -231
  70. planar/workflows/test_workflow.py +0 -2005
  71. planar-0.10.0.dist-info/METADATA +0 -323
  72. {planar-0.10.0.dist-info → planar-0.12.0.dist-info}/WHEEL +0 -0
  73. {planar-0.10.0.dist-info → planar-0.12.0.dist-info}/entry_points.txt +0 -0
@@ -1,471 +0,0 @@
1
- {
2
- "nodes": [
3
- {
4
- "id": "inputNode",
5
- "name": "request",
6
- "type": "inputNode",
7
- "content": {
8
- "schema": ""
9
- },
10
- "position": {
11
- "x": 110,
12
- "y": 193.5
13
- }
14
- },
15
- {
16
- "id": "marketConditionsTable",
17
- "name": "marketConditionsAssessment",
18
- "type": "decisionTableNode",
19
- "content": {
20
- "rules": [
21
- {
22
- "_id": "rule1",
23
- "i1-1": "> 30",
24
- "i1-2": "< -15",
25
- "o1-1": "'severe'",
26
- "o1-2": "0.8",
27
- "o1-3": "'Highly volatile market with significant downward trend'"
28
- },
29
- {
30
- "_id": "rule2",
31
- "i1-1": "> 25",
32
- "i1-2": "< -10",
33
- "o1-1": "'high'",
34
- "o1-2": "0.7",
35
- "o1-3": "'Elevated volatility with substantial market decline'"
36
- },
37
- {
38
- "_id": "rule3",
39
- "i1-1": "> 20",
40
- "i1-2": "< -5",
41
- "o1-1": "'moderate'",
42
- "o1-2": "0.5",
43
- "o1-3": "'Increased volatility with market decline'"
44
- },
45
- {
46
- "_id": "rule4",
47
- "i1-1": "> 25",
48
- "i1-2": "> 5",
49
- "o1-1": "'neutral'",
50
- "o1-2": "0.3",
51
- "o1-3": "'High volatility but positive market trend'"
52
- },
53
- {
54
- "_id": "rule5",
55
- "i1-1": "> 15",
56
- "i1-2": "",
57
- "o1-1": "'elevated'",
58
- "o1-2": "0.4",
59
- "o1-3": "'Elevated market volatility'"
60
- },
61
- {
62
- "_id": "rule6",
63
- "i1-1": "",
64
- "i1-2": "< -10",
65
- "o1-1": "'negative'",
66
- "o1-2": "0.6",
67
- "o1-3": "'Significant market decline'"
68
- },
69
- {
70
- "_id": "rule7",
71
- "i1-1": "",
72
- "i1-2": "",
73
- "o1-1": "'normal'",
74
- "o1-2": "0.2",
75
- "o1-3": "'Normal market conditions'"
76
- }
77
- ],
78
- "inputs": [
79
- {
80
- "id": "i1-1",
81
- "name": "Market Volatility Index",
82
- "field": "market.volatilityIndex"
83
- },
84
- {
85
- "id": "i1-2",
86
- "name": "Market Trend Percent",
87
- "field": "market.trendPercentage"
88
- }
89
- ],
90
- "outputs": [
91
- {
92
- "id": "o1-1",
93
- "name": "Market Condition",
94
- "field": "assessment.marketCondition"
95
- },
96
- {
97
- "id": "o1-2",
98
- "name": "Market Risk Factor",
99
- "field": "assessment.marketRiskFactor"
100
- },
101
- {
102
- "id": "o1-3",
103
- "name": "Market Assessment",
104
- "field": "assessment.marketAssessment"
105
- }
106
- ],
107
- "hitPolicy": "first",
108
- "inputField": null,
109
- "outputPath": null,
110
- "passThrough": true,
111
- "executionMode": "single"
112
- },
113
- "position": {
114
- "x": 430,
115
- "y": 193.5
116
- }
117
- },
118
- {
119
- "id": "portfolioExposureTable",
120
- "name": "portfolioExposureAssessment",
121
- "type": "decisionTableNode",
122
- "content": {
123
- "rules": [
124
- {
125
- "_id": "rule1",
126
- "i1-1": "> 50",
127
- "i1-2": "assessment.marketCondition == 'severe' or assessment.marketCondition == 'high'",
128
- "o1-1": "'critical'",
129
- "o1-2": "0.9"
130
- },
131
- {
132
- "_id": "rule2",
133
- "i1-1": "> 40",
134
- "i1-2": "assessment.marketCondition == 'severe' or assessment.marketCondition == 'high'",
135
- "o1-1": "'high'",
136
- "o1-2": "0.7"
137
- },
138
- {
139
- "_id": "rule3",
140
- "i1-1": "> 30",
141
- "i1-2": "assessment.marketCondition != 'normal'",
142
- "o1-1": "'elevated'",
143
- "o1-2": "0.5"
144
- },
145
- {
146
- "_id": "rule4",
147
- "i1-1": "> 20",
148
- "i1-2": "",
149
- "o1-1": "'moderate'",
150
- "o1-2": "0.3"
151
- },
152
- {
153
- "_id": "rule5",
154
- "i1-1": "",
155
- "i1-2": "",
156
- "o1-1": "'low'",
157
- "o1-2": "0.1"
158
- }
159
- ],
160
- "inputs": [
161
- {
162
- "id": "i1-1",
163
- "name": "High-Risk Asset Percentage",
164
- "field": "portfolio.highRiskPercentage"
165
- },
166
- {
167
- "id": "i1-2",
168
- "name": "Market Condition Check"
169
- }
170
- ],
171
- "outputs": [
172
- {
173
- "id": "o1-1",
174
- "name": "Exposure Level",
175
- "field": "assessment.exposureLevel"
176
- },
177
- {
178
- "id": "o1-2",
179
- "name": "Exposure Factor",
180
- "field": "assessment.exposureFactor"
181
- }
182
- ],
183
- "hitPolicy": "first",
184
- "inputField": null,
185
- "outputPath": null,
186
- "passThrough": true,
187
- "executionMode": "single"
188
- },
189
- "position": {
190
- "x": 750,
191
- "y": 193.5
192
- }
193
- },
194
- {
195
- "id": "portfolioVolatilityTable",
196
- "name": "portfolioVolatilityAssessment",
197
- "type": "decisionTableNode",
198
- "content": {
199
- "rules": [
200
- {
201
- "_id": "rule1",
202
- "i1-1": "> 30",
203
- "i1-2": "> 0.6",
204
- "o1-1": "'high'",
205
- "o1-2": "0.8"
206
- },
207
- {
208
- "_id": "rule2",
209
- "i1-1": "> 25",
210
- "i1-2": "> 0.4",
211
- "o1-1": "'elevated'",
212
- "o1-2": "0.6"
213
- },
214
- {
215
- "_id": "rule3",
216
- "i1-1": "> 20",
217
- "i1-2": "",
218
- "o1-1": "'moderate'",
219
- "o1-2": "0.4"
220
- },
221
- {
222
- "_id": "rule4",
223
- "i1-1": "> 15",
224
- "i1-2": "",
225
- "o1-1": "'low'",
226
- "o1-2": "0.2"
227
- },
228
- {
229
- "_id": "rule5",
230
- "i1-1": "",
231
- "i1-2": "",
232
- "o1-1": "'minimal'",
233
- "o1-2": "0.1"
234
- }
235
- ],
236
- "inputs": [
237
- {
238
- "id": "i1-1",
239
- "name": "Portfolio Volatility",
240
- "field": "portfolio.volatility"
241
- },
242
- {
243
- "id": "i1-2",
244
- "name": "Market Risk Factor",
245
- "field": "assessment.marketRiskFactor"
246
- }
247
- ],
248
- "outputs": [
249
- {
250
- "id": "o1-1",
251
- "name": "Volatility Level",
252
- "field": "assessment.volatilityLevel"
253
- },
254
- {
255
- "id": "o1-2",
256
- "name": "Volatility Factor",
257
- "field": "assessment.volatilityFactor"
258
- }
259
- ],
260
- "hitPolicy": "first",
261
- "inputField": null,
262
- "outputPath": null,
263
- "passThrough": true,
264
- "executionMode": "single"
265
- },
266
- "position": {
267
- "x": 1070,
268
- "y": 193.5
269
- }
270
- },
271
- {
272
- "id": "riskScoreCalculation",
273
- "name": "calculateRiskScore",
274
- "type": "expressionNode",
275
- "content": {
276
- "inputField": null,
277
- "outputPath": null,
278
- "expressions": [
279
- {
280
- "id": "expr1",
281
- "key": "marketWeight",
282
- "value": "0.3"
283
- },
284
- {
285
- "id": "expr2",
286
- "key": "exposureWeight",
287
- "value": "0.4"
288
- },
289
- {
290
- "id": "expr3",
291
- "key": "volatilityWeight",
292
- "value": "0.3"
293
- },
294
- {
295
- "id": "expr4",
296
- "key": "riskScore",
297
- "value": "assessment.marketRiskFactor * $.marketWeight + assessment.exposureFactor * $.exposureWeight + assessment.volatilityFactor * $.volatilityWeight"
298
- },
299
- {
300
- "id": "expr5",
301
- "key": "portfolioDrift",
302
- "value": "abs(portfolio.currentAllocation.equity - portfolio.targetAllocation.equity)"
303
- },
304
- {
305
- "id": "expr6",
306
- "key": "riskCategory",
307
- "value": "$.riskScore >= 0.7 ? 'critical' : $.riskScore >= 0.5 ? 'high' : $.riskScore >= 0.3 ? 'moderate' : 'low'"
308
- }
309
- ],
310
- "passThrough": true,
311
- "executionMode": "single"
312
- },
313
- "position": {
314
- "x": 1390,
315
- "y": 193.5
316
- }
317
- },
318
- {
319
- "id": "actionDeterminationSwitch",
320
- "name": "determineAction",
321
- "type": "switchNode",
322
- "content": {
323
- "hitPolicy": "first",
324
- "statements": [
325
- {
326
- "id": "alertAction",
327
- "condition": "riskCategory == 'moderate' and assessment.marketCondition != 'normal'",
328
- "isDefault": false
329
- },
330
- {
331
- "id": "rebalanceAction",
332
- "condition": "portfolioDrift > 10 or (riskCategory == 'high' and portfolio.lastRebalance > 90)",
333
- "isDefault": false
334
- },
335
- {
336
- "id": "mitigateAction",
337
- "condition": "riskCategory == 'critical' or (riskCategory == 'high' and assessment.marketCondition == 'severe')",
338
- "isDefault": false
339
- },
340
- {
341
- "id": "noAction",
342
- "condition": "",
343
- "isDefault": true
344
- }
345
- ]
346
- },
347
- "position": {
348
- "x": 1710,
349
- "y": 193.5
350
- }
351
- },
352
- {
353
- "id": "alertFunction",
354
- "name": "generateAlert",
355
- "type": "functionNode",
356
- "content": {
357
- "source": "import dayjs from 'dayjs';\nexport const handler = async (input) => {\n const { customer, portfolio, assessment, riskScore, riskCategory } = input;\n const alertDate = dayjs().format('YYYY-MM-DD');\n\n return {\n action: 'alert',\n alertDetails: {\n customerId: customer.id,\n portfolioId: portfolio.id,\n date: alertDate,\n riskScore: riskScore,\n riskCategory: riskCategory,\n message: `Risk alert: Portfolio risk level is ${riskCategory} (${riskScore.toFixed(2)}). Market conditions: ${assessment.marketAssessment}`,\n recommendedAction: 'Review portfolio allocation'\n },\n outcome: { status: 'alert_generated', riskScore: riskScore, timestamp: new Date().toISOString() }\n };\n};"
358
- },
359
- "position": {
360
- "x": 2030,
361
- "y": 46.5
362
- }
363
- },
364
- {
365
- "id": "rebalanceFunction",
366
- "name": "suggestRebalancing",
367
- "type": "functionNode",
368
- "content": {
369
- "source": "import dayjs from 'dayjs';\nexport const handler = async (input) => {\n const { customer, portfolio, assessment, riskScore, riskCategory, portfolioDrift } = input;\n const currentDate = dayjs().format('YYYY-MM-DD');\n const suggestedEquity = portfolio.targetAllocation.equity;\n const suggestedBonds = portfolio.targetAllocation.bonds;\n const suggestedCash = portfolio.targetAllocation.cash;\n const driftPercentage = portfolioDrift.toFixed(1);\n\n return {\n action: 'rebalance',\n rebalanceDetails: {\n customerId: customer.id,\n portfolioId: portfolio.id,\n date: currentDate,\n riskScore: riskScore,\n riskCategory: riskCategory,\n currentAllocation: portfolio.currentAllocation,\n targetAllocation: portfolio.targetAllocation,\n driftPercentage: driftPercentage,\n suggestedChanges: {\n equity: suggestedEquity - portfolio.currentAllocation.equity,\n bonds: suggestedBonds - portfolio.currentAllocation.bonds,\n cash: suggestedCash - portfolio.currentAllocation.cash\n },\n message: `Rebalancing recommended: Portfolio has drifted ${driftPercentage}% from target allocation.`\n },\n outcome: { status: 'rebalance_suggested', riskScore: riskScore, timestamp: new Date().toISOString() }\n };\n};"
370
- },
371
- "position": {
372
- "x": 2030,
373
- "y": 144.5
374
- }
375
- },
376
- {
377
- "id": "mitigationFunction",
378
- "name": "implementRiskMitigation",
379
- "type": "functionNode",
380
- "content": {
381
- "source": "import dayjs from 'dayjs';\nexport const handler = async (input) => {\n const { customer, portfolio, assessment, riskScore, riskCategory } = input;\n const mitigationDate = dayjs().format('YYYY-MM-DD');\n const suggestedEquity = Math.max(portfolio.targetAllocation.equity - 15, 0);\n const suggestedBonds = Math.min(portfolio.targetAllocation.bonds + 10, 100 - suggestedEquity - 5);\n const suggestedCash = 100 - suggestedEquity - suggestedBonds;\n\n return {\n action: 'mitigate',\n mitigationDetails: {\n customerId: customer.id,\n portfolioId: portfolio.id,\n date: mitigationDate,\n riskScore: riskScore,\n riskCategory: riskCategory,\n currentAllocation: portfolio.currentAllocation,\n suggestedAllocation: { equity: suggestedEquity, bonds: suggestedBonds, cash: suggestedCash },\n message: `Risk mitigation required: Market conditions (${assessment.marketCondition}) and portfolio risk (${riskCategory}) indicate immediate action needed.`,\n automaticChanges: assessment.marketCondition === 'severe' && riskCategory === 'critical' && customer.preferences.allowAutomaticAdjustments\n },\n outcome: { status: 'mitigation_implemented', riskScore: riskScore, timestamp: new Date().toISOString() }\n };\n};"
382
- },
383
- "position": {
384
- "x": 2030,
385
- "y": 242.5
386
- }
387
- },
388
- {
389
- "id": "noActionRequired",
390
- "name": "noActionNeeded",
391
- "type": "expressionNode",
392
- "content": {
393
- "inputField": null,
394
- "outputPath": null,
395
- "expressions": [
396
- {
397
- "id": "expr1",
398
- "key": "outcome",
399
- "value": "{ status: 'no_action_required', riskScore: riskScore, timestamp: string(date('now')) }"
400
- }
401
- ],
402
- "passThrough": true,
403
- "executionMode": "single"
404
- },
405
- "position": {
406
- "x": 2030,
407
- "y": 340.5
408
- }
409
- }
410
- ],
411
- "edges": [
412
- {
413
- "id": "edge1",
414
- "type": "edge",
415
- "sourceId": "inputNode",
416
- "targetId": "marketConditionsTable"
417
- },
418
- {
419
- "id": "edge2",
420
- "type": "edge",
421
- "sourceId": "marketConditionsTable",
422
- "targetId": "portfolioExposureTable"
423
- },
424
- {
425
- "id": "edge3",
426
- "type": "edge",
427
- "sourceId": "portfolioExposureTable",
428
- "targetId": "portfolioVolatilityTable"
429
- },
430
- {
431
- "id": "edge4",
432
- "type": "edge",
433
- "sourceId": "portfolioVolatilityTable",
434
- "targetId": "riskScoreCalculation"
435
- },
436
- {
437
- "id": "edge5",
438
- "type": "edge",
439
- "sourceId": "riskScoreCalculation",
440
- "targetId": "actionDeterminationSwitch"
441
- },
442
- {
443
- "id": "edge6",
444
- "type": "edge",
445
- "sourceId": "actionDeterminationSwitch",
446
- "targetId": "alertFunction",
447
- "sourceHandle": "alertAction"
448
- },
449
- {
450
- "id": "edge7",
451
- "type": "edge",
452
- "sourceId": "actionDeterminationSwitch",
453
- "targetId": "rebalanceFunction",
454
- "sourceHandle": "rebalanceAction"
455
- },
456
- {
457
- "id": "edge8",
458
- "type": "edge",
459
- "sourceId": "actionDeterminationSwitch",
460
- "targetId": "mitigationFunction",
461
- "sourceHandle": "mitigateAction"
462
- },
463
- {
464
- "id": "edge9",
465
- "type": "edge",
466
- "sourceId": "actionDeterminationSwitch",
467
- "targetId": "noActionRequired",
468
- "sourceHandle": "noAction"
469
- }
470
- ]
471
- }