Skip to content

Commit 92ea4a6

Browse files
authored
Merge pull request #37 from YASSERRMD/phase_4
phase 4: health enrichment, make help & golangci-lint config
2 parents a83729d + e241927 commit 92ea4a6

5 files changed

Lines changed: 80 additions & 20 deletions

File tree

.golangci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
run:
2+
timeout: 5m
3+
modules-download-mode: readonly
4+
5+
linters:
6+
enable:
7+
- errcheck
8+
- govet
9+
- staticcheck
10+
- gosimple
11+
- ineffassign
12+
- unused
13+
- gofmt
14+
- misspell
15+
- unconvert
16+
- bodyclose
17+
18+
linters-settings:
19+
errcheck:
20+
check-type-assertions: true
21+
check-blank: false
22+
govet:
23+
enable-all: false
24+
gofmt:
25+
simplify: true
26+
27+
issues:
28+
exclude-rules:
29+
# Test files may use unsafe assertions and blank identifiers freely.
30+
- path: "_test\\.go"
31+
linters:
32+
- errcheck
33+
# Generated or legacy files.
34+
- path: "internal/merkle/"
35+
linters:
36+
- unused
37+
max-issues-per-linter: 50
38+
max-same-issues: 10

Makefile

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: build test lint docker-build docker-up clean build-tokenizer
1+
.PHONY: build test lint docker-build docker-up clean build-tokenizer help
22

33
BINARY_DIR := bin
44
SIQLAH_BIN := $(BINARY_DIR)/siqlah
@@ -16,34 +16,40 @@ VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
1616
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
1717
LDFLAGS := -ldflags "-X main.version=$(VERSION) -X main.commitSHA=$(COMMIT)"
1818

19-
build: $(BINARY_DIR)
19+
build: $(BINARY_DIR) ## Build all Go binaries into bin/
2020
$(GO) build $(LDFLAGS) -o $(SIQLAH_BIN) ./cmd/siqlah
2121
$(GO) build -o $(WITNESS_BIN) ./cmd/witness
2222
$(GO) build -o $(VERIFIER_BIN) ./cmd/verifier
2323

2424
$(BINARY_DIR):
2525
mkdir -p $(BINARY_DIR)
2626

27-
build-tokenizer:
27+
build-tokenizer: ## Build the Rust tokenizer static library
2828
cd $(TOKENIZER_DIR) && $(CARGO) build --release
2929

30-
test:
30+
test: ## Run the full Go test suite
3131
$(GO) test ./...
3232

33-
lint:
33+
lint: ## Run go vet and golangci-lint (if installed)
3434
$(GO) vet ./...
3535
@which golangci-lint > /dev/null 2>&1 && golangci-lint run ./... || echo "golangci-lint not installed, skipping"
3636

37-
docker-build:
37+
docker-build: ## Build the siqlah Docker image
3838
$(DOCKER) build -f deployments/Dockerfile -t siqlah:latest .
3939

40-
docker-up:
40+
docker-up: ## Start siqlah + witness containers via docker compose
4141
$(DOCKER_COMPOSE) -f deployments/docker-compose.yml up -d
4242

43-
clean:
43+
clean: ## Remove build artifacts (bin/ and Rust target/)
4444
rm -rf $(BINARY_DIR)
4545
cd $(TOKENIZER_DIR) && $(CARGO) clean
4646

47-
# build-legacy: build with SQLite-only mode (no Tessera)
48-
build-legacy:
47+
build-legacy: ## Build with SQLite-only mode (no Tessera)
4948
go build -tags sqlite_legacy -o bin/ ./cmd/...
49+
50+
help: ## Show this help message
51+
@grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) | \
52+
awk 'BEGIN {FS = ":.*##"}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
53+
@echo ""
54+
@echo "Targets without descriptions:"
55+
@grep -E '^[a-zA-Z_-]+:' $(MAKEFILE_LIST) | grep -v '##' | awk -F: '{print " " $$1}'

cmd/siqlah/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ func main() {
142142
}
143143
reg := provider.NewRegistry()
144144
srv := api.NewWithOptions(st, cpBuilder, operatorPub, operatorPriv, reg, version, *inferenceRegion)
145+
srv.WithBackendInfo(*logBackend, *signingBackend)
145146
if *x402Recipient != "" {
146147
srv.WithX402Recipient(*x402Recipient)
147148
}

internal/api/health.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ package api
22

33
import (
44
"net/http"
5+
"time"
56
)
67

78
// HealthResponse is returned by GET /v1/health.
89
type HealthResponse struct {
9-
Status string `json:"status"`
10-
Version string `json:"version"`
10+
Status string `json:"status"`
11+
Version string `json:"version"`
12+
LogBackend string `json:"log_backend,omitempty"`
13+
SignerType string `json:"signer_type,omitempty"`
14+
Timestamp string `json:"timestamp"`
1115
}
1216

1317
// StatsResponse is returned by GET /v1/stats.
@@ -19,18 +23,20 @@ type StatsResponse struct {
1923
}
2024

2125
func (s *Server) handleHealth(w http.ResponseWriter, r *http.Request) {
26+
resp := HealthResponse{
27+
Version: s.version,
28+
LogBackend: s.logBackend,
29+
SignerType: s.signerType,
30+
Timestamp: time.Now().UTC().Format(time.RFC3339),
31+
}
2232
// Probe DB connectivity via Stats (lightweight query).
2333
if _, err := s.store.Stats(); err != nil {
24-
writeJSON(w, http.StatusServiceUnavailable, HealthResponse{
25-
Status: "degraded",
26-
Version: s.version,
27-
})
34+
resp.Status = "degraded"
35+
writeJSON(w, http.StatusServiceUnavailable, resp)
2836
return
2937
}
30-
writeJSON(w, http.StatusOK, HealthResponse{
31-
Status: "ok",
32-
Version: s.version,
33-
})
38+
resp.Status = "ok"
39+
writeJSON(w, http.StatusOK, resp)
3440
}
3541

3642
func (s *Server) handleStats(w http.ResponseWriter, r *http.Request) {

internal/api/server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ type Server struct {
3131
registry providerRegistry
3232
version string
3333
logOrigin string
34+
logBackend string
35+
signerType string
3436
x402Bridge *x402.Bridge
3537
x402Recipient string
3638
modelReg *model.Registry
@@ -114,6 +116,13 @@ func (s *Server) WithX402Recipient(addr string) *Server {
114116
return s
115117
}
116118

119+
// WithBackendInfo sets the log backend and signer type strings surfaced by GET /v1/health.
120+
func (s *Server) WithBackendInfo(logBackend, signerType string) *Server {
121+
s.logBackend = logBackend
122+
s.signerType = signerType
123+
return s
124+
}
125+
117126
// Routes returns a ServeMux with all API routes registered.
118127
func (s *Server) Routes() *http.ServeMux {
119128
mux := http.NewServeMux()

0 commit comments

Comments
 (0)