summaryrefslogtreecommitdiff
path: root/AGENTS.md
blob: ca4d51394055bb64d8a74e58aed7112c125d2073 (plain)
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
# AGENTS.md - AI Agent Instructions

## Project Overview

`goprecords` is a Go command-line program that generates uptime reports for hosts based on input record files from `uptimed`. It supports importing records into SQLite and querying for reports, or reporting directly from a stats directory.

## Build & Test Commands

```bash
# Build
go build -o goprecords ./cmd/goprecords
# or: mage

# Run tests
go test ./...
# Full check (unit + race): mage test
# Race only: mage testRace

# Run integration tests
./goprecords test

# Install to GOPATH/bin
mage install
```

## Docker image & f3s deploy

Image build and registry push live in the **`conf`** repo (`f3s/goprecords`), not in this tree. The Justfile there builds from **`docker-image/Justfile`**, which sets **`SRC`** to this **`goprecords`** checkout (default `/home/paul/git/goprecords`).

**Release checklist**

1. Bump **`internal/version/version.go`** (`Tag`, semver).
2. In **`conf`**: set **`docker-image/Justfile`** `TAG` to the same version; set **`helm-chart/templates/deployment.yaml`** `image:` to `registry.lan.buetow.org:30001/goprecords:<Tag>`; update **`f3s/goprecords/README.md`** example tags if present.
3. From **`conf/f3s/goprecords`**: run **`just build-push`** (tags and pushes **`r0.lan.buetow.org:30001/goprecords:<Tag>`**; the cluster pulls via **`registry.lan.buetow.org:30001`**).
4. Commit and tag **`goprecords`**; push branch and tag to Codeberg.
5. Commit **`conf`**; push **`master`** to Codeberg **and** to **`r0`** (`git push r0 master`) so the in-cluster git server Argo uses is updated.
6. Sync the app: from **`conf/f3s/goprecords`**, **`just sync`** (or wait for Argo automated sync). Confirm with **`kubectl rollout status deployment/goprecords -n services`** and the deployment image tag.

Utility targets in **`conf/f3s/goprecords/Justfile`**: **`status`**, **`logs`**, **`restart`**.

## Project Structure

```
goprecords/
├── cmd/goprecords/main.go    # Entry point, CLI handling
├── internal/
│   ├── goprecords/           # Core logic (db, aggregate, report, parse, order, types)
│   └── version/version.go    # Version constant
├── Dockerfile                # Multi-stage image (daemon binary)
├── Magefile.go               # Build automation
├── fixtures/                 # Test fixtures and expected outputs
└── go.mod                    # Go 1.21, modernc.org/sqlite
```

## Code Style

- Go 1.21
- No comments in code unless explicitly requested
- Functions should be ~30 lines; refactor when approaching 50 lines
- Move code from main.go to ./internal package when main.go grows too large
- Follow existing patterns in the codebase

## Categories & Metrics

- Categories: `Host`, `Kernel`, `KernelMajor`, `KernelName`
- Metrics: `Boots`, `Uptime`, `Score`, `Downtime`, `Lifespan`
- Output formats: `Plaintext`, `Markdown`, `Gemtext`, `HTML`
- `Downtime` and `Lifespan` metrics only apply to `Host` category

## Key Types

- `Category`, `Metric`, `OutputFormat` - enums for report configuration
- `Aggregate` - per-entity stats (host, kernel, etc.)
- `HostAggregate` - extends Aggregate with LastKernel, Downtime, Lifespan