Skip to content
Merged
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
1 change: 1 addition & 0 deletions Dockerfile.jl4-decision-service
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ CMD ["jl4-decision-service-exe", \
"--serverName", "http://localhost:8001", \
"--sourcePaths", "/app/experiments/britishcitizen5.l4", \
"--sourcePaths", "/app/experiments/parking.l4", \
"--sourcePaths", "/app/experiments/thailand-cosmetics", \
"--crudServerName", "jl4-websessions", \
"--crudServerPort", "8002"]
5 changes: 4 additions & 1 deletion dev-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ case "$MODE" in
cabal run jl4-decision-service -- \
--port "$DECISION_PORT" \
--sourcePaths ../jl4/experiments/britishcitizen5.l4 \
--sourcePaths ../jl4/experiments/parking.l4
--sourcePaths ../jl4/experiments/parking.l4 \
--sourcePaths ../jl4/experiments/thailand-cosmetics
;;

websessions-only)
Expand Down Expand Up @@ -62,6 +63,7 @@ case "$MODE" in
--port "$DECISION_PORT" \
--sourcePaths ../jl4/experiments/britishcitizen5.l4 \
--sourcePaths ../jl4/experiments/parking.l4 \
--sourcePaths ../jl4/experiments/thailand-cosmetics \
--crudServerName localhost \
--crudServerPort "$WEBSESSIONS_PORT") > /tmp/jl4-decision.log 2>&1 &
echo "DECISION_PID=$!" >> "$PIDFILE"
Expand Down Expand Up @@ -127,6 +129,7 @@ case "$MODE" in
echo " --port $DECISION_PORT \\"
echo " --sourcePaths ../jl4/experiments/britishcitizen5.l4 \\"
echo " --sourcePaths ../jl4/experiments/parking.l4 \\"
echo " --sourcePaths ../jl4/experiments/thailand-cosmetics \\"
echo " --crudServerName localhost --crudServerPort $WEBSESSIONS_PORT"
echo ""
echo "Terminal 3 - Websessions (after decision service starts):"
Expand Down
1 change: 1 addition & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
--serverName http://localhost:8001 \
--sourcePaths /build/jl4/experiments/britishcitizen5.l4 \
--sourcePaths /build/jl4/experiments/parking.l4 \
--sourcePaths /build/jl4/experiments/thailand-cosmetics \
--crudServerName jl4-websessions \
--crudServerPort 8002"
volumes:
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
root-ssh-keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO2u9PR5FnBb8joGKHUVGqy9/cZu/iXIjgLpblkOF0H+ meng-and-ruslan"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIORxGnRHtCTqoh2IijZMfgC+0nExW2ujUybdG54u8wS4 mengwong@nixos"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN/JtalP151kdUUTh2/wA25IabXrJNkFIuMCeMj6U6CL nye"
];
};
environment.etc."my-deploy-marker" = {
Expand Down
1 change: 1 addition & 0 deletions jl4/experiments/classic/britishcitizen5.l4
9 changes: 9 additions & 0 deletions jl4/experiments/classic/compute_qualifies.l4
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@export default Determines if a person qualifies for the purposes of the rule. A person qualifies if they walk AND (drink OR eat).
GIVEN walks IS A BOOLEAN
drinks IS A BOOLEAN
eats IS A BOOLEAN
GIVETH A BOOLEAN
DECIDE `compute_qualifies` IF
walks
AND drinks
OR eats
1 change: 1 addition & 0 deletions jl4/experiments/classic/parking.l4
3 changes: 3 additions & 0 deletions jl4/experiments/classic/the_answer.l4
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@export default A constant function with no parameters that returns 42.
GIVETH A NUMBER
DECIDE the_answer IS 42
45 changes: 45 additions & 0 deletions jl4/experiments/classic/vermin_and_rodent.l4
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
DECLARE Inputs
HAS
`Loss or Damage.caused by rodents` IS A BOOLEAN
`Loss or Damage.caused by insects` IS A BOOLEAN
`Loss or Damage.caused by vermin` IS A BOOLEAN
`Loss or Damage.caused by birds` IS A BOOLEAN
`Loss or Damage.to Contents` IS A BOOLEAN
`any other exclusion applies` IS A BOOLEAN
`a household appliance` IS A BOOLEAN
`a swimming pool` IS A BOOLEAN
`a plumbing, heating, or air conditioning system` IS A BOOLEAN
`Loss or Damage.ensuing covered loss` IS A BOOLEAN

@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.
GIVEN i IS Inputs
GIVETH A BOOLEAN
DECIDE `vermin_and_rodent` i IF
`not covered if`
`loss or damage by animals`
AND NOT `damage to contents and caused by birds`
OR `ensuing covered loss`
AND NOT `exclusion apply`
WHERE
GIVEN x IS A BOOLEAN
GIVETH A BOOLEAN
`not covered if` x MEANS x

`loss or damage by animals` MEANS
i's `Loss or Damage.caused by rodents`
OR i's `Loss or Damage.caused by insects`
OR i's `Loss or Damage.caused by vermin`
OR i's `Loss or Damage.caused by birds`

`damage to contents and caused by birds` MEANS
i's `Loss or Damage.to Contents`
AND i's `Loss or Damage.caused by birds`

`ensuing covered loss` MEANS
i's `Loss or Damage.ensuing covered loss`

`exclusion apply` MEANS
i's `any other exclusion applies`
OR i's `a household appliance`
OR i's `a swimming pool`
OR i's `a plumbing, heating, or air conditioning system`
65 changes: 65 additions & 0 deletions jl4/experiments/thailand-cosmetics/anthropicClient.l4
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Anthropic Claude API Client Library
// To use: IMPORT anthropic-client

// Type Definitions
DECLARE `Message` HAS
`role` IS A STRING
`content` IS A STRING

DECLARE `API Request` HAS
`model` IS A STRING
`max_tokens` IS A NUMBER
`messages` IS A LIST OF `Message`

// API Configuration
anthropicUrl MEANS
"https://api.anthropic.com/v1/messages"

anthropicVersion MEANS
"2023-06-01"

defaultModel MEANS
"claude-sonnet-4-5-20250929"

defaultMaxTokens MEANS
1000

// Get API key from environment variable
getApiKey MEANS
CONSIDER ENV "ANTHROPIC_API_KEY"
WHEN JUST key THEN key
WHEN NOTHING THEN "ERROR: Set ANTHROPIC_API_KEY environment variable"

// Helper: Create a message record
GIVEN role IS A STRING
content IS A STRING
createMessage MEANS
`Message` WITH
`role` IS role
`content` IS content

// Helper: Build headers with API key
buildHeaders key MEANS
CONCAT
"x-api-key: ", key, "\n",
"anthropic-version: ", anthropicVersion, "\n",
"content-type: application/json"

// Helper: Build API request (nested record encoding)
GIVEN userMessage IS A STRING
buildRequest MEANS
`API Request` WITH
`model` IS defaultModel
`max_tokens` IS defaultMaxTokens
`messages` IS LIST (createMessage "user" userMessage)

// Main: Call Claude API with explicit API key
callClaudeWithKey apiKey userMessage MEANS
POST
anthropicUrl
(buildHeaders apiKey)
(JSONENCODE (buildRequest userMessage))

// Main: Call Claude API using environment variable
callClaude userMessage MEANS
callClaudeWithKey getApiKey userMessage
Loading
Loading