Skip to content

Commit 14729c8

Browse files
authored
Merge pull request #849 from smucclaw/mengwong/nix-service
2 parents 95c9491 + 8ae8842 commit 14729c8

File tree

18 files changed

+3989
-1
lines changed

18 files changed

+3989
-1
lines changed

Dockerfile.jl4-decision-service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ CMD ["jl4-decision-service-exe", \
5757
"--serverName", "http://localhost:8001", \
5858
"--sourcePaths", "/app/experiments/britishcitizen5.l4", \
5959
"--sourcePaths", "/app/experiments/parking.l4", \
60+
"--sourcePaths", "/app/experiments/thailand-cosmetics", \
6061
"--crudServerName", "jl4-websessions", \
6162
"--crudServerPort", "8002"]

dev-start.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ case "$MODE" in
2424
cabal run jl4-decision-service -- \
2525
--port "$DECISION_PORT" \
2626
--sourcePaths ../jl4/experiments/britishcitizen5.l4 \
27-
--sourcePaths ../jl4/experiments/parking.l4
27+
--sourcePaths ../jl4/experiments/parking.l4 \
28+
--sourcePaths ../jl4/experiments/thailand-cosmetics
2829
;;
2930

3031
websessions-only)
@@ -62,6 +63,7 @@ case "$MODE" in
6263
--port "$DECISION_PORT" \
6364
--sourcePaths ../jl4/experiments/britishcitizen5.l4 \
6465
--sourcePaths ../jl4/experiments/parking.l4 \
66+
--sourcePaths ../jl4/experiments/thailand-cosmetics \
6567
--crudServerName localhost \
6668
--crudServerPort "$WEBSESSIONS_PORT") > /tmp/jl4-decision.log 2>&1 &
6769
echo "DECISION_PID=$!" >> "$PIDFILE"
@@ -127,6 +129,7 @@ case "$MODE" in
127129
echo " --port $DECISION_PORT \\"
128130
echo " --sourcePaths ../jl4/experiments/britishcitizen5.l4 \\"
129131
echo " --sourcePaths ../jl4/experiments/parking.l4 \\"
132+
echo " --sourcePaths ../jl4/experiments/thailand-cosmetics \\"
130133
echo " --crudServerName localhost --crudServerPort $WEBSESSIONS_PORT"
131134
echo ""
132135
echo "Terminal 3 - Websessions (after decision service starts):"

docker-compose.dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ services:
2222
--serverName http://localhost:8001 \
2323
--sourcePaths /build/jl4/experiments/britishcitizen5.l4 \
2424
--sourcePaths /build/jl4/experiments/parking.l4 \
25+
--sourcePaths /build/jl4/experiments/thailand-cosmetics \
2526
--crudServerName jl4-websessions \
2627
--crudServerPort 8002"
2728
volumes:

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
root-ssh-keys = [
8585
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO2u9PR5FnBb8joGKHUVGqy9/cZu/iXIjgLpblkOF0H+ meng-and-ruslan"
8686
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIORxGnRHtCTqoh2IijZMfgC+0nExW2ujUybdG54u8wS4 mengwong@nixos"
87+
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN/JtalP151kdUUTh2/wA25IabXrJNkFIuMCeMj6U6CL nye"
8788
];
8889
};
8990
environment.etc."my-deploy-marker" = {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../britishcitizen5.l4
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@export default Determines if a person qualifies for the purposes of the rule. A person qualifies if they walk AND (drink OR eat).
2+
GIVEN walks IS A BOOLEAN
3+
drinks IS A BOOLEAN
4+
eats IS A BOOLEAN
5+
GIVETH A BOOLEAN
6+
DECIDE `compute_qualifies` IF
7+
walks
8+
AND drinks
9+
OR eats

jl4/experiments/classic/parking.l4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../parking.l4
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@export default A constant function with no parameters that returns 42.
2+
GIVETH A NUMBER
3+
DECIDE the_answer IS 42
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
DECLARE Inputs
2+
HAS
3+
`Loss or Damage.caused by rodents` IS A BOOLEAN
4+
`Loss or Damage.caused by insects` IS A BOOLEAN
5+
`Loss or Damage.caused by vermin` IS A BOOLEAN
6+
`Loss or Damage.caused by birds` IS A BOOLEAN
7+
`Loss or Damage.to Contents` IS A BOOLEAN
8+
`any other exclusion applies` IS A BOOLEAN
9+
`a household appliance` IS A BOOLEAN
10+
`a swimming pool` IS A BOOLEAN
11+
`a plumbing, heating, or air conditioning system` IS A BOOLEAN
12+
`Loss or Damage.ensuing covered loss` IS A BOOLEAN
13+
14+
@export default We do not cover any loss or damage caused by rodents, insects, vermin, or birds. However, this exclusion does not apply to: (a) loss or damage to your contents caused by birds; or (b) ensuing covered loss unless any other exclusion applies or where an animal causes water to escape from a household appliance, swimming pool or plumbing, heating or air conditioning system.
15+
GIVEN i IS Inputs
16+
GIVETH A BOOLEAN
17+
DECIDE `vermin_and_rodent` i IF
18+
`not covered if`
19+
`loss or damage by animals`
20+
AND NOT `damage to contents and caused by birds`
21+
OR `ensuing covered loss`
22+
AND NOT `exclusion apply`
23+
WHERE
24+
GIVEN x IS A BOOLEAN
25+
GIVETH A BOOLEAN
26+
`not covered if` x MEANS x
27+
28+
`loss or damage by animals` MEANS
29+
i's `Loss or Damage.caused by rodents`
30+
OR i's `Loss or Damage.caused by insects`
31+
OR i's `Loss or Damage.caused by vermin`
32+
OR i's `Loss or Damage.caused by birds`
33+
34+
`damage to contents and caused by birds` MEANS
35+
i's `Loss or Damage.to Contents`
36+
AND i's `Loss or Damage.caused by birds`
37+
38+
`ensuing covered loss` MEANS
39+
i's `Loss or Damage.ensuing covered loss`
40+
41+
`exclusion apply` MEANS
42+
i's `any other exclusion applies`
43+
OR i's `a household appliance`
44+
OR i's `a swimming pool`
45+
OR i's `a plumbing, heating, or air conditioning system`
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Anthropic Claude API Client Library
2+
// To use: IMPORT anthropic-client
3+
4+
// Type Definitions
5+
DECLARE `Message` HAS
6+
`role` IS A STRING
7+
`content` IS A STRING
8+
9+
DECLARE `API Request` HAS
10+
`model` IS A STRING
11+
`max_tokens` IS A NUMBER
12+
`messages` IS A LIST OF `Message`
13+
14+
// API Configuration
15+
anthropicUrl MEANS
16+
"https://api.anthropic.com/v1/messages"
17+
18+
anthropicVersion MEANS
19+
"2023-06-01"
20+
21+
defaultModel MEANS
22+
"claude-sonnet-4-5-20250929"
23+
24+
defaultMaxTokens MEANS
25+
1000
26+
27+
// Get API key from environment variable
28+
getApiKey MEANS
29+
CONSIDER ENV "ANTHROPIC_API_KEY"
30+
WHEN JUST key THEN key
31+
WHEN NOTHING THEN "ERROR: Set ANTHROPIC_API_KEY environment variable"
32+
33+
// Helper: Create a message record
34+
GIVEN role IS A STRING
35+
content IS A STRING
36+
createMessage MEANS
37+
`Message` WITH
38+
`role` IS role
39+
`content` IS content
40+
41+
// Helper: Build headers with API key
42+
buildHeaders key MEANS
43+
CONCAT
44+
"x-api-key: ", key, "\n",
45+
"anthropic-version: ", anthropicVersion, "\n",
46+
"content-type: application/json"
47+
48+
// Helper: Build API request (nested record encoding)
49+
GIVEN userMessage IS A STRING
50+
buildRequest MEANS
51+
`API Request` WITH
52+
`model` IS defaultModel
53+
`max_tokens` IS defaultMaxTokens
54+
`messages` IS LIST (createMessage "user" userMessage)
55+
56+
// Main: Call Claude API with explicit API key
57+
callClaudeWithKey apiKey userMessage MEANS
58+
POST
59+
anthropicUrl
60+
(buildHeaders apiKey)
61+
(JSONENCODE (buildRequest userMessage))
62+
63+
// Main: Call Claude API using environment variable
64+
callClaude userMessage MEANS
65+
callClaudeWithKey getApiKey userMessage

0 commit comments

Comments
 (0)