1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// Jenkins Pipeline for TensorLogic Validation
// Save as: Jenkinsfile
pipeline {
agent any
environment {
TENSORLOGIC_VERSION = '0.1.0-alpha.2'
CARGO_HOME = "${WORKSPACE}/.cargo"
PATH = "${CARGO_HOME}/bin:${PATH}"
}
options {
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 30, unit: 'MINUTES')
timestamps()
}
stages {
stage('Setup') {
steps {
script {
echo "Setting up TensorLogic CLI..."
sh '''
curl https://sh.rustup.rs -sSf | sh -s -- -y
source $HOME/.cargo/env
cargo install tensorlogic-cli --version ${TENSORLOGIC_VERSION}
'''
}
}
}
stage('Validate') {
steps {
script {
echo "Validating logic rules..."
sh '''
tensorlogic batch rules/*.tl --validate
'''
}
}
}
stage('Statistics') {
parallel {
stage('Generate Stats') {
steps {
script {
echo "Generating statistics..."
sh '''
mkdir -p reports
for rule in rules/*.tl; do
name=$(basename "$rule" .tl)
tensorlogic "$rule" \\
--output-format stats \\
--analyze > "reports/${name}_stats.txt"
done
'''
}
}
}
stage('Compile to JSON') {
steps {
script {
echo "Compiling to JSON..."
sh '''
mkdir -p compiled
for rule in rules/*.tl; do
name=$(basename "$rule" .tl)
tensorlogic "$rule" \\
--output-format json \\
--output "compiled/${name}.json" \\
--validate
done
'''
}
}
}
}
}
stage('Visualize') {
when {
anyOf {
branch 'main'
branch 'develop'
}
}
steps {
script {
echo "Generating visualizations..."
sh '''
mkdir -p visualizations
for rule in rules/*.tl; do
name=$(basename "$rule" .tl)
tensorlogic "$rule" \\
--output-format dot \\
--output "visualizations/${name}.dot"
dot -Tpng "visualizations/${name}.dot" \\
-o "visualizations/${name}.png"
done
'''
}
}
}
stage('Test Strategies') {
matrix {
axes {
axis {
name 'STRATEGY'
values 'soft_differentiable', 'hard_boolean', 'fuzzy_godel', 'fuzzy_product'
}
}
stages {
stage('Test') {
steps {
script {
echo "Testing with strategy: ${STRATEGY}"
sh """
for rule in rules/*.tl; do
echo "Testing \$(basename \$rule) with ${STRATEGY}"
tensorlogic "\$rule" \\
--strategy ${STRATEGY} \\
--validate \\
--quiet
done
"""
}
}
}
}
}
}
stage('Quality Checks') {
steps {
script {
echo "Running quality checks..."
sh '''
# Check for large graphs
for rule in rules/*.tl; do
stats=$(tensorlogic "$rule" --output-format stats --quiet)
tensors=$(echo "$stats" | grep "Tensors:" | awk '{print $2}')
if [ "$tensors" -gt 100 ]; then
echo "⚠️ Large graph in $(basename $rule): $tensors tensors"
fi
done
# Format conversion checks
for rule in rules/*.tl; do
tensorlogic convert "$rule" \\
--from expr \\
--to json \\
--quiet > /dev/null
done
'''
}
}
}
stage('Deploy') {
when {
branch 'main'
}
steps {
script {
echo "Deploying compiled rules..."
sh '''
# Example deployment
# Upload to artifact repository, S3, etc.
echo "Deployment would happen here"
'''
}
}
}
}
post {
always {
archiveArtifacts artifacts: 'reports/*.txt, compiled/*.json, visualizations/*.png', allowEmptyArchive: true
}
success {
echo "✓ Pipeline completed successfully!"
}
failure {
echo "✗ Pipeline failed!"
}
cleanup {
cleanWs()
}
}
}