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
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --workspace --all-targets

msrv:
name: rust 1.88
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.88.0
- name: Install OpenSSL
run: sudo apt-get update && sudo apt-get install -y pkg-config libssl-dev
- name: Test on the minimum supported Rust
run: cargo test --workspace --all-targets

build:
name: build
runs-on: ubuntu-latest
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/helm-install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: helm install

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
helm-install:
name: kind 1.28 helm install
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4

- name: Install kubectl
uses: azure/setup-kubectl@v4

- name: Install Helm
uses: azure/setup-helm@v4
with:
version: v3.14.0

- name: Install kind
run: |
curl -fsSL -o /usr/local/bin/kind https://kind.sigs.k8s.io/dl/v0.23.0/kind-linux-amd64
sudo chmod +x /usr/local/bin/kind

- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq

- name: Install chart on Kubernetes 1.28 and fail over the lease
run: ./scripts/helm-install-proof.sh
env:
KIND_NODE_IMAGE: kindest/node:v1.28.15

- name: Upload install and failover evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: setpoint-helm-proof-${{ github.sha }}
path: |
artifacts/helm-install/
artifacts/leader-failover/
retention-days: 30

- name: Teardown
if: always()
run: kind delete cluster --name setpoint-helm || true
7 changes: 5 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Run from repo root unless noted otherwise.
- Build local demo images: `make build-images-local`
- Helm lint: `make helm-lint`
- Helm render: `make helm-template`
- Clean kind install plus lease failover: `make helm-install-proof` (needs Docker, kind, kubectl, Helm, and jq; CI runs it on Kubernetes 1.28)

### Kubernetes and demo flows

Expand All @@ -76,7 +77,7 @@ Run from repo root unless noted otherwise.
- Clean up demo environment: `make demo-cleanup`
- Inject drift into the Auto-correct conveyor register: `make demo-drift-conveyor`
- Inject drift into the Alert-only print-head register: `make demo-drift-printhead`
- Trigger the Halt safety fault: `make demo-drift-halt`
- Trigger the Halt policy fault (marks the IndustrialPLC Failed; not a certified emergency stop): `make demo-drift-halt`
- Run flagship proof: `make flagship-proof`
- Proof cleanup only: `make proof-cleanup`
- Regenerate proof report from captured artifacts: `make proof-report`
Expand Down Expand Up @@ -137,7 +138,7 @@ This is the path a reviewer can run end-to-end. Each step lists the commands dis
```sh
make demo-drift-conveyor # Auto strategy: operator silently corrects
make demo-drift-printhead # Alert strategy: detected, never written
make demo-drift-halt # Halt strategy: IndustrialPLC marked Failed
make demo-drift-halt # Halt strategy: IndustrialPLC marked Failed (operator status, not a certified emergency stop)
```
7. Tear down: `make demo-cleanup`.
8. Reproduce the CI proof locally: `make flagship-proof`. The verdict and artifacts land under `artifacts/latest/`.
Expand Down Expand Up @@ -206,6 +207,8 @@ Document these instead of guessing:
- `landing/.next/` and `landing/node_modules/` are present in the working tree. Treat them as generated local artifacts, not source.
- The console at `landing/app/console/page.tsx` calls the Axum API at `http://localhost:8081`. When the API is offline, it falls back to a typed bundled replica and surfaces a "Demo data fallback" banner. Audit and SSE streams are always labeled as mock data in the response payload (`isMock: true`, `source: "mock"`).
- Drift demo commands (`make demo-drift-conveyor`, `make demo-drift-printhead`, `make demo-drift-halt`) target `127.0.0.1:5502`, which only works after `make demo` port-forwards the mock PLC service.
- Halt marks an IndustrialPLC Failed. It is an operator status, not a certified emergency stop. Physical PLC validation is pending; proofs use the mock PLC or an in-process Modbus peer.
- Minimum Kubernetes is 1.28 (`docs/SUPPORT.md`, chart `kubeVersion`). Minimum Rust is the workspace `rust-version`. `make helm-install-proof` needs Docker, kind, kubectl, Helm, and jq.

## Verification Guidance

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ license = "MIT"
repository = "https://github.com/apinzon/setpoint-operator"
homepage = "https://github.com/apinzon/setpoint-operator"
authors = ["Setpoint Maintainers"]
rust-version = "1.88"

[workspace.dependencies]
tokio = { version = "1.35", features = ["full"] }
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.mock-plc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y \

# Copy workspace configuration
COPY Cargo.toml ./
COPY Cargo.lock ./
# Cargo.lock is gitignored. The image resolves the workspace itself.
COPY crates/mock-plc/Cargo.toml ./crates/mock-plc/
COPY crates/mock-plc/src ./crates/mock-plc/src/
COPY crates/operator/Cargo.toml ./crates/operator/
Expand All @@ -24,7 +24,7 @@ COPY crates/api/Cargo.toml ./crates/api/
COPY crates/api/src ./crates/api/src/

# Build the mock-plc
RUN cargo build --release -p mock-plc
RUN cargo generate-lockfile && cargo build --release -p mock-plc

# Runtime stage
FROM debian:bookworm-slim
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.operator
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN apt-get update && apt-get install -y \

# Copy workspace configuration
COPY Cargo.toml ./
COPY Cargo.lock ./
# Cargo.lock is gitignored. The image resolves the workspace itself.
COPY crates/operator/Cargo.toml ./crates/operator/
COPY crates/operator/src ./crates/operator/src/
COPY crates/setpointctl/Cargo.toml ./crates/setpointctl/
Expand All @@ -24,7 +24,7 @@ COPY crates/api/Cargo.toml ./crates/api/
COPY crates/api/src ./crates/api/src/

# Build the operator
RUN cargo build --release -p operator
RUN cargo generate-lockfile && cargo build --release -p operator

# Runtime stage
FROM debian:bookworm-slim
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ helm-install: ## Install the chart into the current cluster
helm-uninstall: ## Uninstall the chart
helm uninstall setpoint --namespace $(NAMESPACE) || true

.PHONY: helm-install-proof
helm-install-proof: ## Install the chart on a clean kind 1.28 cluster and fail over the lease
./scripts/helm-install-proof.sh

# ---- Local demo ----

.PHONY: demo
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ The desired state of every register is git-tracked YAML. The operator
polls the live device, detects drift, and applies the per-register
remediation policy. **Auto** silently writes the desired value back;
**Alert** emits a `Warning DriftDetected` event and bumps a metric
but does not write; **Halt** marks the resource `Failed`.
but does not write; **Halt** marks the resource `Failed`. Halt is an
operator status, not a safety-certified industrial emergency stop.
Physical PLC validation is pending; the proofs below use a simulated device.

## Run the flagship proof

Expand Down Expand Up @@ -200,7 +202,8 @@ make demo # start local demo environment
make demo-cleanup # stop demo resources and local processes
make demo-drift-conveyor # inject drift into the Auto conveyor register
make demo-drift-printhead # inject drift into the Alert print-head register
make demo-drift-halt # trigger the Halt safety fault
make demo-drift-halt # Halt policy: mark the IndustrialPLC Failed
make helm-install-proof # clean kind 1.28 install, then lease failover
make flagship-proof # run the proof end to end
make proof-cleanup # clean resources created by the proof
make proof-report # regenerate report from captured artifacts
Expand Down Expand Up @@ -365,6 +368,6 @@ or behavior claims tied to the end-to-end demo.

MIT. See [LICENSE](LICENSE).

The CI matrix runs separate disposable kind clusters for Auto, Alert and Halt. Run locally after `kind create cluster --name setpoint-e2e`: `make flagship-proof` (Alert); override `PROOF_POLICY=Auto DRIFT_REGISTER=4001 DRIFT_VALUE=3500` or `PROOF_POLICY=Halt DRIFT_REGISTER=4003 DRIFT_VALUE=1`. No hardware safety certification is claimed.
The CI matrix runs separate disposable kind clusters for Auto, Alert and Halt. Run locally after `kind create cluster --name setpoint-e2e`: `make flagship-proof` (Alert); override `PROOF_POLICY=Auto DRIFT_REGISTER=4001 DRIFT_VALUE=3500` or `PROOF_POLICY=Halt DRIFT_REGISTER=4003 DRIFT_VALUE=1`. Halt is an operator status, not a safety-certified emergency stop. Physical PLC validation is pending. Supported versions are in [docs/SUPPORT.md](docs/SUPPORT.md).

See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, policy proof commands and pull request expectations.
1 change: 1 addition & 0 deletions charts/setpoint/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: Setpoint - GitOps control plane for industrial PLC drift detection
type: application
version: 0.2.0
appVersion: "0.2.0"
kubeVersion: ">=1.28.0-0"
keywords:
- industrial
- plc
Expand Down
20 changes: 17 additions & 3 deletions charts/setpoint/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,25 @@ spec:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: RUST_LOG
value: {{ .Values.config.logLevel }}
- name: HOSTNAME
value: {{ .Values.config.logLevel | quote }}
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: AUDIT_LEDGER_DIR
value: {{ .Values.audit.dir | quote }}
- name: AUDIT_CONFIGMAP_NAME
value: {{ .Values.audit.configMapName | quote }}
volumeMounts:
- name: audit-ledger
mountPath: {{ .Values.audit.dir | quote }}
volumes:
- name: audit-ledger
emptyDir: {}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
50 changes: 39 additions & 11 deletions charts/setpoint/templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "setpoint.serviceAccountName" . }}
labels:
{{- include "setpoint.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand Down Expand Up @@ -76,4 +65,43 @@ subjects:
- kind: ServiceAccount
name: {{ include "setpoint.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "setpoint.fullname" . }}-audit
labels:
{{- include "setpoint.labels" . | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- create
- apiGroups:
- ""
resources:
- configmaps
resourceNames:
- {{ .Values.audit.configMapName | quote }}
verbs:
- get
- update
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "setpoint.fullname" . }}-audit
labels:
{{- include "setpoint.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "setpoint.fullname" . }}-audit
subjects:
- kind: ServiceAccount
name: {{ include "setpoint.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
7 changes: 7 additions & 0 deletions charts/setpoint/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ podLabels: {}
podSecurityContext:
runAsNonRoot: true
runAsUser: 1000
fsGroup: 1000

securityContext:
allowPrivilegeEscalation: false
Expand Down Expand Up @@ -71,6 +72,12 @@ config:
logLevel: "info"
metricsPort: 8080

# Deletion audit records are appended under dir (process restart on the same
# pod) and copied into a ConfigMap (survives pod replacement).
audit:
dir: /var/lib/setpoint/audit
configMapName: setpoint-audit-ledger

# Prometheus ServiceMonitor
serviceMonitor:
enabled: false
Expand Down
1 change: 1 addition & 0 deletions crates/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "api"
version = "0.2.0"
edition = "2021"
rust-version.workspace = true
description = "Setpoint API Gateway - serves telemetry and control plane API to the web console"
license = "MIT"
repository = "https://github.com/AngelP17/fabgitops"
Expand Down
3 changes: 2 additions & 1 deletion crates/api/src/policy_sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub fn map_decision(req: &SimulationRequest, decision: PolicyDecision) -> Simula
),
PolicyDecision::Halt { reason } => (
"System Halt".to_string(),
"Mark IndustrialPLC Failed, halt operational line".to_string(),
"Mark the IndustrialPLC Failed. This is an operator status, not a safety-certified emergency stop.".to_string(),
reason,
"High / Critical".to_string(),
"halt",
Expand Down Expand Up @@ -150,6 +150,7 @@ mod tests {
let out = evaluate(&r);
assert_eq!(out.decision, "halt");
assert!(out.risk.contains("Critical"));
assert!(out.action.contains("not a safety-certified emergency stop"));
}

#[test]
Expand Down
1 change: 1 addition & 0 deletions crates/drift-simulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "drift-simulator"
version = "0.2.0"
edition = "2021"
rust-version.workspace = true
description = "Setpoint drift simulator - injects deterministic register drift to exercise the operator's remediation policies"
license = "MIT"
repository = "https://github.com/apinzon/setpoint-operator"
Expand Down
1 change: 1 addition & 0 deletions crates/mock-plc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "mock-plc"
version = "0.2.0"
edition = "2021"
rust-version.workspace = true
description = "Mock Modbus TCP server for Setpoint development and proof runs"
license = "MIT"
repository = "https://github.com/apinzon/setpoint-operator"
Expand Down
1 change: 1 addition & 0 deletions crates/operator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "operator"
version = "0.2.0"
edition = "2021"
rust-version.workspace = true
description = "Setpoint Kubernetes operator - reconciler for industrial PLCs"
license = "MIT"
repository = "https://github.com/apinzon/setpoint-operator"
Expand Down
Loading
Loading