Skip to content

Commit 1e75927

Browse files
committed
feat: wire conflow config validation pipeline
1 parent 8651d89 commit 1e75927

7 files changed

Lines changed: 226 additions & 0 deletions

File tree

.conflow.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# conflow pipeline - Nickel generation
2+
version: "1"
3+
name: "boj-server"
4+
5+
stages:
6+
- name: "generate"
7+
description: "Generate configuration from Nickel"
8+
tool:
9+
type: nickel
10+
command: export
11+
file: configs/config.ncl
12+
format: json
13+
input: "configs/config.ncl"
14+
output: generated/config.json
15+
16+
- name: "validate"
17+
description: "Validate generated configuration"
18+
tool:
19+
type: cue
20+
command: vet
21+
schemas:
22+
- schemas/config.cue
23+
input:
24+
from_stage: generate
25+
depends_on:
26+
- generate

alloyiser.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
# alloyiser manifest for boj-server
3+
4+
[project]
5+
name = "boj-server"
6+
7+
[[specs]]
8+
name = "boj-rest-api"
9+
source = "/var/mnt/eclipse/repos/boj-server/openapi.yaml"
10+
format = "openapi"
11+
12+
[[assertions]]
13+
name = "no-orphan-cartridges"
14+
check = "all c: Cartridge | some c.owner"
15+
scope = 5
16+
17+
[[assertions]]
18+
name = "cartridge-invoke-requires-auth"
19+
check = "all i: Invocation | some i.auth_token"
20+
scope = 5
21+
22+
[[assertions]]
23+
name = "no-duplicate-cartridge-ids"
24+
check = "all disj c1, c2: Cartridge | c1.id != c2.id"
25+
scope = 6
26+
27+
[alloy]
28+
solver = "sat4j"
29+
max-scope = 6

configs/config.ncl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Configuration generation
2+
{
3+
name = "my-app",
4+
replicas =
5+
let env = "dev" in
6+
if env == "prod" then 5
7+
else if env == "staging" then 3
8+
else 1,
9+
port = 8080,
10+
env = "dev",
11+
}

generated/alloyiser/boj_server.als

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
module boj_server
2+
3+
// Formal model generated by alloyiser from project 'boj-server'.
4+
// Verify with: java -jar alloy.jar boj_server.als
5+
6+
abstract sig Bool {}
7+
8+
abstract sig Int {}
9+
10+
abstract sig Object {}
11+
12+
abstract sig String {}
13+
14+
sig CartridgeInfo {
15+
abi_version: lone String,
16+
available: lone Bool,
17+
backends: set String,
18+
domain: lone String,
19+
ffi_status: lone String,
20+
name: lone String,
21+
operations: set String,
22+
protocols: set String,
23+
status: lone String,
24+
version: lone String
25+
}
26+
27+
sig CartridgeSummary {
28+
available: lone Bool,
29+
domain: lone String,
30+
name: lone String,
31+
protocols: set String,
32+
status: lone String,
33+
version: lone String
34+
}
35+
36+
sig GitHubRepo {
37+
description: lone String,
38+
full_name: lone String,
39+
html_url: lone String,
40+
id: lone Int,
41+
language: lone String,
42+
stargazers_count: lone Int,
43+
updated_at: lone String
44+
}
45+
46+
sig HealthResponse {
47+
cartridges: lone Int,
48+
components: lone String,
49+
status: lone String,
50+
uptime_seconds: lone Int,
51+
version: lone String
52+
}
53+
54+
sig InvokeRequest {
55+
operation: lone String,
56+
params: lone Object
57+
}
58+
59+
sig InvokeResponse {
60+
cartridge: lone String,
61+
data: lone Object,
62+
duration_ms: lone Int,
63+
error: lone String,
64+
operation: lone String,
65+
success: lone Bool
66+
}
67+
68+
sig MenuResponse {
69+
summary: lone Int,
70+
tier_ayo: set CartridgeSummary,
71+
tier_shield: set CartridgeSummary,
72+
tier_teranga: set CartridgeSummary
73+
}
74+
75+
sig RateLimit {
76+
limit: lone String,
77+
remaining: lone String,
78+
reset: lone String
79+
}
80+
81+
assert no_orphan_cartridges {
82+
all c: Cartridge | some c.owner
83+
}
84+
check no_orphan_cartridges for 5
85+
86+
assert cartridge_invoke_requires_auth {
87+
all i: Invocation | some i.auth_token
88+
}
89+
check cartridge_invoke_requires_auth for 5
90+
91+
assert no_duplicate_cartridge_ids {
92+
all disj c1, c2: Cartridge | c1.id != c2.id
93+
}
94+
check no_duplicate_cartridge_ids for 6
95+
96+
// Visualise a sample instance
97+
run {} for 5
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: PMPL-1.0-or-later
3+
# Generated by alloyiser — Alloy analysis script
4+
# Requires: java, alloy.jar
5+
6+
ALLOY_JAR="alloy.jar"
7+
MODEL="/var/mnt/eclipse/repos/boj-server/generated/alloyiser/boj_server.als"
8+
SOLVER="sat4j"
9+
TIMEOUT="300"
10+
11+
echo "=== alloyiser analysis ==="
12+
echo "Model: $MODEL"
13+
echo "Solver: $SOLVER"
14+
echo "Assertions: 3"
15+
16+
echo "Checking: no_orphan_cartridges..."
17+
timeout "$TIMEOUT" java -jar "$ALLOY_JAR" -batch -solver "$SOLVER" "$MODEL" 2>&1 | grep -A5 "no_orphan_cartridges"
18+
echo ""
19+
20+
echo "Checking: cartridge_invoke_requires_auth..."
21+
timeout "$TIMEOUT" java -jar "$ALLOY_JAR" -batch -solver "$SOLVER" "$MODEL" 2>&1 | grep -A5 "cartridge_invoke_requires_auth"
22+
echo ""
23+
24+
echo "Checking: no_duplicate_cartridge_ids..."
25+
timeout "$TIMEOUT" java -jar "$ALLOY_JAR" -batch -solver "$SOLVER" "$MODEL" 2>&1 | grep -A5 "no_duplicate_cartridge_ids"
26+
echo ""
27+
28+
echo "=== analysis complete ==="

schemas/config.cue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Configuration schema
2+
package config
3+
4+
#Config: {
5+
name: string
6+
replicas: int & >=1
7+
port: int & >=1 & <=65535
8+
env: string
9+
}

wokelangiser.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
# wokelangiser manifest for boj-server
3+
4+
[project]
5+
name = "boj-server"
6+
7+
[consent]
8+
gdpr = true
9+
ccpa = true
10+
default-state = "opt-out"
11+
categories = ["functional", "analytics", "third-party"]
12+
13+
[accessibility]
14+
wcag-level = "AA"
15+
check-contrast = true
16+
check-alt-text = true
17+
check-aria = true
18+
min-contrast-ratio = 4.5
19+
20+
[i18n]
21+
default-locale = "en-GB"
22+
supported-locales = ["en-GB", "fr-FR", "de-DE"]
23+
extract-strings = true
24+
25+
[report]
26+
format = "text"

0 commit comments

Comments
 (0)