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
6 changes: 6 additions & 0 deletions .agents/agents/contract-reviewer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: contract-reviewer
description: Review OCAP Recorder native commands, storage formats, and WebSocket contracts.
---

Read [AGENTS.md](../../AGENTS.md) and the [contract review skill](../skills/ocap-recorder-contract-review/SKILL.md). Work read-only. Follow the modified boundary to its producers and consumers. Return severity, triggering input, observable outcome, source links, and missing checks.
6 changes: 6 additions & 0 deletions .agents/agents/explorer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: explorer
description: Trace one OCAP Recorder workflow and its compatibility or recovery evidence.
---

Read [AGENTS.md](../../AGENTS.md) and the [handoff guide](../../docs/agent-workflows.md). Work read-only. Report the entry point, consumers, durable state, the relevant historical decision, and the case that verifies it. Include file and line evidence.
6 changes: 6 additions & 0 deletions .agents/agents/recovery-reviewer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: recovery-reviewer
description: Review OCAP Recorder ordering, retries, cancellation, and partial writes.
---

Read [AGENTS.md](../../AGENTS.md) and the [handoff guide](../../docs/agent-workflows.md). Work read-only. Follow ownership across commands, queues, connections, acknowledgement, databases, and files. Return concrete failure sequences, durable results, and remaining evidence.
6 changes: 6 additions & 0 deletions .agents/agents/worker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: worker
description: Implement one scoped OCAP Recorder change in assigned files.
---

Read [AGENTS.md](../../AGENTS.md) and the [handoff guide](../../docs/agent-workflows.md). Edit only assigned files and preserve local changes. Run synthetic success and failure checks and return exact results and integration needs.
6 changes: 6 additions & 0 deletions .agents/skills/ocap-recorder-context-recovery/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: ocap-recorder-context-recovery
description: Recover why an OCAP Recorder compatibility or recovery rule exists using its history, callers, and tests.
---

Read [Maintainer context](../../../docs/maintainer-context.md) and pin the checkout. Search the owning file and integration history for the rule. Trace the current producer, consumers, and durable effects, including older mission files or rows. Report the first relevant decision, present behavior, and the [local case](../../../docs/testkit.md) that verifies it.
6 changes: 6 additions & 0 deletions .agents/skills/ocap-recorder-contract-review/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: ocap-recorder-contract-review
description: Review compatibility boundaries for OCAP Recorder native arguments, mission storage, JSON export, and WebSocket delivery.
---

Read [Maintainer context](../../../docs/maintainer-context.md). Check native exports, argument order, callback shape, and exact command names against existing callers. For recording changes, follow field presence, frame numbering, and event representation through the writer and player. For streaming changes, verify old peer behavior, retries, and durable acknowledgement. Report the input, writer, consumer, outcome, and test.
6 changes: 6 additions & 0 deletions .agents/skills/ocap-recorder-local-verification/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: ocap-recorder-local-verification
description: Select and run OCAP Recorder Go, race, coverage, and native build checks with CI and CGO in view.
---

Start with [Contributing](../../../CONTRIBUTING.md), [CI](../../../.github/workflows), and the [local test cases](../../../docs/testkit.md). Run focused normal and failure paths before the shared suite. Check statement coverage and use the race detector when changing queues, workers, timers, or WebSocket ownership. Verify both native targets for build and ABI changes when their toolchains are available.
6 changes: 6 additions & 0 deletions .agents/skills/ocap-recorder-testkit/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: ocap-recorder-testkit
description: Run the named OCAP Recorder cases for native commands, exports, WebSocket recovery, mission save, and persistence.
---

Choose a case from the [local test catalog](../../../docs/testkit.md). Prefer existing fixtures and use temporary paths, synthetic missions, and loopback providers. Verify what callers receive and what is saved or retried. Record the exact command, outcome, and any deployment-only checks.
20 changes: 16 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
cache: true

- name: Run go vet
run: go vet ./internal/...
run: go vet ./...

- name: Run tests
# Use Go 1.20+ binary coverage format via GOCOVERDIR. Unlike the legacy
Expand All @@ -38,7 +38,7 @@ jobs:
# instrumented by -coverpkg — no dedup workaround needed.
run: |
mkdir -p covdata
go test -cover -coverpkg=./internal/... ./internal/... -args -test.gocoverdir="$PWD/covdata"
go test -tags=ocap_abi_test -cover -coverpkg=./... ./... -args -test.gocoverdir="$PWD/covdata"
go tool covdata textfmt -i=covdata -o=cover.out

- name: Archive code coverage results
Expand Down Expand Up @@ -86,7 +86,9 @@ jobs:

- name: Build x64 DLL
run: |
docker run --rm -v "${{ github.workspace }}:/go/work" -w /go/work x1unix/go-mingw:1.26 \
docker build -t ocap-recorder-builder .
docker run --rm -v "${{ github.workspace }}:/go/work" -w /go/work \
-e GOOS=windows -e GOARCH=amd64 -e CGO_ENABLED=1 -e CC=x86_64-w64-mingw32-gcc ocap-recorder-builder \
go build -buildvcs=false \
-ldflags "-X main.BuildDate=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -X main.BuildCommit=${{ github.sha }}" \
-o dist/ocap_recorder_x64.dll -buildmode=c-shared ./cmd/ocap_recorder
Expand All @@ -109,8 +111,18 @@ jobs:
pull-requests: write

steps:
- uses: fgrosse/go-coverage-report@c4bf7e78d1379325814b4dd42d80e526082e788b # v1.5.0
- id: report
uses: fgrosse/go-coverage-report@c4bf7e78d1379325814b4dd42d80e526082e788b # v1.5.0
with:
coverage-artifact-name: "code-coverage"
coverage-file-name: "cover.out"
root-package: "github.com/OCAP2/extension/v5"
# A pull request from a fork gets a read-only token, so it cannot be
# commented on. Its report goes to the run summary instead.
skip-comment: ${{ github.event.pull_request.head.repo.full_name != github.repository }}

- name: Add coverage report to the run summary
if: github.event.pull_request.head.repo.full_name != github.repository
env:
REPORT: ${{ steps.report.outputs.coverage_report }}
run: printf '%s\n' "$REPORT" >> "$GITHUB_STEP_SUMMARY"
8 changes: 5 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
include:
- goos: windows
goarch: amd64
docker_image: x1unix/go-mingw:1.26
cc: x86_64-w64-mingw32-gcc
binary: ocap_recorder_x64.dll
archive: ocap_recorder-windows-amd64.zip
archiver: zip -r
- goos: linux
goarch: amd64
docker_image: golang:1.26-bookworm
cc: gcc
binary: ocap_recorder_x64.so
archive: ocap_recorder-linux-amd64.tar.gz
archiver: tar -czvf
Expand All @@ -34,7 +34,9 @@ jobs:

- name: Build ${{ matrix.goos }}/${{ matrix.goarch }}
run: |
docker run --rm -v "${{ github.workspace }}:/go/work" -w /go/work ${{ matrix.docker_image }} \
docker build -t ocap-recorder-builder .
docker run --rm -v "${{ github.workspace }}:/go/work" -w /go/work \
-e GOOS=${{ matrix.goos }} -e GOARCH=${{ matrix.goarch }} -e CGO_ENABLED=1 -e CC=${{ matrix.cc }} ocap-recorder-builder \
go build -buildvcs=false \
-ldflags "-X main.BuildVersion=${{ github.ref_name }} -X main.BuildDate=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -X main.BuildCommit=${{ github.sha }}" \
-o dist/${{ matrix.binary }} -buildmode=c-shared ./cmd/ocap_recorder
Expand Down
20 changes: 20 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# OCAP Recorder agent guide

Start with [Contributing](CONTRIBUTING.md). Use [Maintainer context](docs/maintainer-context.md) to trace a contract, failure path, or guard and [Comment hygiene](docs/comment-hygiene.md) for comment edits.

- Preserve the [ArmA entry points](pkg/a3interface), command names and argument positions, and blank and zero defaults used by existing callers. Follow a changed command through parsing, dispatch, and its storage consumers.
- Review [mission save](cmd/ocap_recorder/mission_save.go), [v1 export](internal/storage/memory/export/v1), and [WebSocket messages](pkg/streaming/messages.go) when changing mission data. Preserve field presence, frame numbering, reconnect behavior, and SQLite and PostgreSQL data written by earlier releases.
- Send streamed mission data to the web server for native v2 protobuf storage. By default the web server also keeps a v1 JSON copy and falls back to it when v2 writing fails; with `streaming.protobufOnly` it converts native v2 to v1 JSON on download. The memory backend's v1 JSON export and upload remain supported.
- Inspect the working tree before editing. Preserve local changes and use synthetic missions, paths, credentials, and loopback services. Use the [test cases](docs/testkit.md) without launching ArmA.
- Match [CI](.github/workflows) for Go tests, vet, and native builds. Check the coverage report for affected code and aim for 100% statement coverage. Keep deterministic success and failure tests close to the code they cover.

## Agent workflows

Use [roles and handoffs](docs/agent-workflows.md) for independent exploration, a disjoint implementation assignment, or a fresh review of a consequential change. The coordinator owns integration and final verification.

| Skill | Use when |
| --- | --- |
| [ocap-recorder-context-recovery](.agents/skills/ocap-recorder-context-recovery/SKILL.md) | Recover why a compatibility or recovery rule exists |
| [ocap-recorder-contract-review](.agents/skills/ocap-recorder-contract-review/SKILL.md) | Review native commands, storage, exports, or WebSocket delivery |
| [ocap-recorder-local-verification](.agents/skills/ocap-recorder-local-verification/SKILL.md) | Select platform, race, build, and coverage checks |
| [ocap-recorder-testkit](.agents/skills/ocap-recorder-testkit/SKILL.md) | Run named local compatibility and recovery cases |
14 changes: 3 additions & 11 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
@AGENTS.md

## Project Overview

Go native DLL extension for ArmA 3 that records gameplay/mission replay data to PostgreSQL, SQLite, or in-memory JSON.

## Build Commands

```bash
# Build x64 Windows DLL
docker run --rm -v ${PWD}:/go/work -w /go/work x1unix/go-mingw:1.26 go build -buildvcs=false -o dist/ocap_recorder_x64.dll -buildmode=c-shared ./cmd/ocap_recorder

# Build x64 Linux .so (uses Bullseye for glibc 2.31 compatibility)
docker run --rm -v ${PWD}:/go/work -w /go/work golang:1.26-bullseye go build -buildvcs=false -o dist/ocap_recorder_x64.so -buildmode=c-shared ./cmd/ocap_recorder
```

**Output:** `dist/ocap_recorder_x64.dll`, `dist/ocap_recorder_x64.so`
See the [build commands](README.md#building) for Windows and Linux shared libraries.

## Project Structure (Go Standard Layout)

Expand All @@ -32,7 +24,7 @@ docker run --rm -v ${PWD}:/go/work -w /go/work golang:1.26-bullseye go build -bu
/internal/geo/ - Coordinate/geometry utilities
/pkg/a3interface/ - ArmA 3 extension interface (RVExtension exports, module path)
/pkg/core/ - Core domain types (storage-agnostic)
Dockerfile - Docker build for Linux
Dockerfile - Builder image for the Windows DLL and Linux .so
go.mod, go.sum - Go module dependencies
createViews.sql - PostgreSQL materialized views
ocap_recorder.cfg.json.example - Configuration template
Expand Down
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Contributing

- [Maintainer context](docs/maintainer-context.md) traces recording, storage, and recovery contracts.
- [Comment hygiene](docs/comment-hygiene.md) covers rationale, directives, and format rules.
- [Agent workflows](docs/agent-workflows.md) describes roles and evidence handoffs.
- [Local test cases](docs/testkit.md) provides focused checks without starting ArmA.

Use the Go version in [go.mod](go.mod). Building the native extension and testing its C entry points require CGO and a C compiler for the target platform. See the [build commands](README.md#building) and [CI](.github/workflows).

## Running tests

Run `go vet ./...`, `go test ./...`, and `go test -race ./...` on a supported host. Use temporary files and loopback providers. Match the package coverage scope and combine statement counts across packages.

```sh
mkdir -p covdata
go test -tags=ocap_abi_test -cover -coverpkg=./... ./... -args -test.gocoverdir="$PWD/covdata"
go tool covdata textfmt -i=covdata -o=cover.out
go tool cover -func=cover.out
```

Use a fresh coverage directory for each run. The test tag enables a synthetic C callback to verify the native callback path. Report untested behavior and checks that need a live ArmA server or deployed database. For release builds, verify both the Windows DLL and Linux shared object and keep the exported C entry points stable.
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# build Golang app for Linux
FROM golang:1.26
ARG DEBIAN_RELEASE=bookworm
FROM golang:1.27.4-bookworm AS toolchain

FROM debian:${DEBIAN_RELEASE}-slim
COPY --from=toolchain /usr/local/go /usr/local/go
ENV PATH="/usr/local/go/bin:${PATH}"
ENV GOPATH=/go

WORKDIR /app

# get gcc-multilib and gcc-mingw-w64
RUN apt update
RUN apt install -y gcc-multilib gcc-mingw-w64
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates gcc libc6-dev gcc-mingw-w64-x86-64 git && \
rm -rf /var/lib/apt/lists/*

CMD ["/bin/sh"]

15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,28 @@ internal/

## Building

Requires Docker with Linux containers.
The [module](go.mod) requires Go 1.27.4. The builder image includes Go and C compilers for both targets.

```bash
docker build -t ocap-recorder-builder .
```

### Windows DLL

```bash
docker pull x1unix/go-mingw:1.24

docker run --rm -v ${PWD}:/go/work -w /go/work x1unix/go-mingw:1.24 \
docker run --rm -v "$PWD:/go/work" -w /go/work \
-e GOOS=windows -e GOARCH=amd64 -e CGO_ENABLED=1 -e CC=x86_64-w64-mingw32-gcc ocap-recorder-builder \
go build -buildvcs=false -o dist/ocap_recorder_x64.dll -buildmode=c-shared ./cmd/ocap_recorder
```

### Linux .so

```bash
docker run --rm -v ${PWD}:/go/work -w /go/work golang:1.24-bullseye \
docker run --rm -v "$PWD:/go/work" -w /go/work -e CGO_ENABLED=1 ocap-recorder-builder \
go build -buildvcs=false -o dist/ocap_recorder_x64.so -buildmode=c-shared ./cmd/ocap_recorder
```

Uses Debian Bullseye (glibc 2.31) for broad compatibility with Linux game servers.
The default Debian Bookworm build matches the release environment. For a build that targets Debian Bullseye (glibc 2.31), rebuild the image with `docker build --build-arg DEBIAN_RELEASE=bullseye -t ocap-recorder-builder .`.

## Configuration

Expand Down
Loading
Loading