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 an OCAP2 Web recording, authorization, HTTP, or playback contract independently."
---

Read the [repository guide](../../AGENTS.md) and [handoff instructions](../../docs/agent-workflows.md). Use the contract review skill on the specified diff. Follow the registered gate or writer through the UI, persisted artifact, or external consumer. Return severity, file and line, triggering input, concrete consequence, and remaining checks. Work read-only. Keep the assignment local and return it to the coordinator.
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 OCAP2 Web workflow and its source, history, consumers, and recovery evidence."
---

Read the [repository guide](../../AGENTS.md) and [handoff instructions](../../docs/agent-workflows.md). Trace the entry point, state and side effects to each affected consumer. Use the context recovery skill. Return the first relevant decision, current behavior, checks and any missing evidence with file and line references. Work read-only. Keep the assignment local and return it to the coordinator.
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 OCAP2 Web retry, cancellation, concurrency, and restart behavior independently."
---

Read the [repository guide](../../AGENTS.md) and [handoff instructions](../../docs/agent-workflows.md). Trace ownership across handlers, queues, workers, database updates, and filesystem effects. Review retries, duplicate messages, incomplete writes, ack timing, and cleanup. Return concrete sequences and observed or unverified outcomes with file and line references. Work read-only. Keep the assignment local and return it to the coordinator.
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 OCAP2 Web change in explicitly assigned files."
---

Read the [repository guide](../../AGENTS.md) and [handoff instructions](../../docs/agent-workflows.md). Edit only the files listed in the brief and preserve local changes. Run the assigned synthetic checks and return changed files, results, and integration needs. Report any edit needed outside your scope. Keep the assignment local and return it to the coordinator.
14 changes: 14 additions & 0 deletions .agents/skills/ocap-context-recovery/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: ocap-context-recovery
description: "Recover the reason for an OCAP2 Web compatibility rule, state transition, or operational guard from Git history, callers, contracts, and tests."
---

# ocap-context-recovery

Read the [maintainer guide](../../../docs/maintainer-context.md) and the relevant workflow in [workflow evidence](../../../docs/context-evidence.md). Pin the checkout and identify the triggering input, output, and durable side effects.

Search the integration history and the owning file with `git log --first-parent`, `--follow`, and `-S` or `-G` on the symbol or error. Read patches and relevant parents. Check the producer and all affected consumers, including existing SQLite rows, files on disk, or UI decoders as applicable. Look for when the rule entered, when it changed, and which version applies today.

Use [Go source navigation](../../../docs/agent-workflows.md#go-source-navigation) to confirm Go callers when a symbol crosses packages or an interface.

Return the historical reason, current observed behavior, consumers, check, and any inference. Keep new rationale with the owning code, contract, or runbook. Add an open evidence item with an owner and next action if the history or an acceptance check is missing.
14 changes: 14 additions & 0 deletions .agents/skills/ocap-contract-review/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: ocap-contract-review
description: "Review OCAP2 Web HTTP authorization, WebSocket ingestion, recording schemas, and playback or map consumers when a contract or failure path changes."
---

# ocap-contract-review

Read the [review questions](../../../docs/maintainer-context.md#before-editing) and the affected [workflow evidence](../../../docs/context-evidence.md). Inspect the actual route or producer and the consuming UI, extension, or operator path.

- For credentials, check the registered route, mode, prefix, role, and unauthorized result. Producer credentials, viewer JWTs, admin JWTs, and map event tokens have different entry points.
- For recordings, follow manifest and chunk formats, frame bounds, field presence, and the status and files visible to readers. When changing stream ownership or retries, trace old and replacement sessions through save, discard, cancellation, and restart.
- For maps, check job state and the tile/style paths against their consumers. If one operation succeeds and another fails, follow both projections into the UI and persisted state.

Report concrete findings with the input, writer and reader locations, outcome, and the test that does or should exercise it. Mark actual provider or deployment verification separately. Use the [testkit](../../../docs/testkit.md) for applicable local cases.
15 changes: 15 additions & 0 deletions .agents/skills/ocap-local-verification/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: ocap-local-verification
description: "Select and run OCAP2 Web Go, SolidJS, schema, and agent-workflow checks for a local change, with CI and platform coverage in view."
---

# ocap-local-verification

Start with the [contributor setup](../../../CONTRIBUTING.md), [CI workflows](../../../.github/workflows), and the [testkit cases](../../../docs/testkit.md#cases).

- Test the affected Go package with a named case or `go test ./internal/<package> -run '^TestName$' -count=1`. For shared changes, run `go test ./...`. SQLite needs CGO and a working C compiler. Real map tool integration requires its native tools.
- For changes to stream ownership, timers, or goroutines, use the [stream race check](../../../docs/testkit.md#race-detector). Use the [Go concurrency testing guidance](../../../CONTRIBUTING.md#running-tests) to choose a fake clock or an integration harness.
- For UI changes, run `npm --prefix ui test` or pass selected files after `--`. From `ui/`, run `npx tsc --noEmit`, `npx eslint src/`, and `npm run build` as applicable. Build before checking the embedded SPA.
- For schema edits, regenerate bindings using the [contributor guide](../../../CONTRIBUTING.md#protobuf-schema-changes) and run `playback-delivery`. For agent guidance, run `go test ./internal/agentdocs` and `git diff --check`.

Record exact commands, results, and skips. Use the [runbook](../../../docs/operational-verification.md) for checks that need a real browser, native tools, or deployed provider.
14 changes: 14 additions & 0 deletions .agents/skills/ocap-testkit/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: ocap-testkit
description: "Run and maintain the OCAP2 Web testkit for isolated route, migration, stream, conversion, playback, map, and startup cases."
---

# ocap-testkit

Read the [testkit runbook](../../../docs/testkit.md). List with `go run ./cmd/ocap-testkit list`. Run one or several cases with `go run ./cmd/ocap-testkit run <case> ...`, or omit the names for the full catalog. Check the report and logs emitted by the command.

For a stream concurrency change, run `go run ./cmd/ocap-testkit run -race stream-recovery` on a [supported toolchain](../../../docs/testkit.md#race-detector).

Reuse a focused Go or Vitest check before adding a fixture. Use temporary files, synthetic recording bytes, or a fake provider on loopback. Keep a case independent of deployed services, real recordings, user settings, and credentials. Pin test selectors and bump the fixture version when changing case inputs or expected behavior.

For a regression proof, make the smallest change that violates the contract in a disposable clone. Run the same case and inspect its failing assertion and downstream state. Retain the local report and record the mutation outside the tracked case catalog.
1 change: 1 addition & 0 deletions .claude
4 changes: 4 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

<!-- Steps to verify the changes work correctly -->

## Contract and recovery

<!-- If changing a contract, guard, or failure path, name the affected producer and consumer, the requirement or rationale, the edge case exercised, and any open environment checks. See docs/maintainer-context.md. -->

## Checklist

- [ ] `go test ./...` passes
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.vscode

# Local development
.claude/settings.local.json
/.agents/settings.local.json

# Build artifacts
/ocap-webserver
Expand All @@ -29,6 +29,7 @@ cover.out
coverage.out
coverage.html
ui/coverage/
/testkit/runs/

# Frontend
node_modules/
Expand Down
22 changes: 22 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# OCAP2 Web 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 changes.

- Verify [HTTP authorization](internal/server/handler.go) through the registered mux under a non-root prefix. Viewer, admin, and producer routes use different credentials. Use the [streaming contract](docs/streaming-architecture.md) for ingestion, recording formats, and playback. Follow the [schema generation instructions](CONTRIBUTING.md#protobuf-schema-changes) for protobuf changes.
- Keep the UI's SolidJS, CSS module, and i18n conventions. Use the [operational runbook](docs/operational-verification.md) for startup, native map tooling, and Arsenal imports.
- Inspect the working tree before editing. Preserve local changes and use synthetic recordings, paths, identities, secrets, and provider responses for local checks. The [testkit](docs/testkit.md) is available without an application startup.
- Match [CI](.github/workflows) for Go tests and UI typecheck, lint, tests, and build when those surfaces change. Build the SPA before packaging the embedded binary. Keep tests close to the code they exercise.
- Always aim for 100% coverage in every test suite. Preserve existing coverage, test normal and failure paths deterministically, and check the coverage report for affected code. [Coverage commands](CONTRIBUTING.md#running-tests)

## 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.

Use [Go source navigation](docs/agent-workflows.md#go-source-navigation) for symbol-level caller evidence.

| Skill | Use when |
| --- | --- |
| [ocap-context-recovery](.agents/skills/ocap-context-recovery/SKILL.md) | Recover why a constraint exists and how to verify it |
| [ocap-contract-review](.agents/skills/ocap-contract-review/SKILL.md) | Review a producer, consumer, or recovery boundary |
| [ocap-local-verification](.agents/skills/ocap-local-verification/SKILL.md) | Select and run checks for a change |
| [ocap-testkit](.agents/skills/ocap-testkit/SKILL.md) | Run or maintain the named local cases |
107 changes: 0 additions & 107 deletions CLAUDE.md

This file was deleted.

1 change: 1 addition & 0 deletions CLAUDE.md
28 changes: 21 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
# Contributing

- [Maintainer context](docs/maintainer-context.md) maps contracts, failure recovery, and review evidence.
- [Comment hygiene](docs/comment-hygiene.md) covers keeping rationale and directives where maintainers need them.
- [Agent workflows](docs/agent-workflows.md) and the [local testkit](docs/testkit.md) document scoped handoffs and reproducible checks.

## Prerequisites

| Tool | Version | Notes |
|------|---------|-------|
| [Go](https://golang.org/dl/) | 1.26+ | Backend |
| [Go](https://golang.org/dl/) | See [go.mod](go.mod) | Backend, with a C compiler for SQLite |
| [Node.js](https://nodejs.org/) | 24+ | Frontend build |
| [protoc](https://grpc.io/docs/protoc-installation/) | 3+ | Only if editing `.proto` files |

Expand Down Expand Up @@ -52,12 +56,14 @@ The frontend is embedded into the binary via `//go:embed`, so you only need to r
```
cmd/
ocap-webserver/ # Server entry point and CLI commands
ocap-testkit/ # Local testkit entry point
internal/
server/ # HTTP handlers, repositories, configuration
frontend/ # Embedded SPA (go:embed)
conversion/ # Background format conversion worker
storage/ # Storage engines (JSON, Protobuf)
maptool/ # Map tile pipeline
testkit/ # Local testkit runner and case catalog
pkg/schemas/
protobuf/ # Protobuf schema and generated code
ui/ # SolidJS + Vite + TypeScript frontend source
Expand All @@ -75,6 +81,17 @@ cd ui
npm test
```

Aim for 100% coverage in every test suite. Check the coverage report for the affected code and add deterministic tests for missing behavior, including errors. Report any remaining gaps when submitting the change.

```bash
# From the repository root
go test -coverprofile=cover.out -coverpkg=./cmd/...,./internal/... ./...
go tool cover -func=cover.out
npm --prefix ui run test:coverage
```

Use [Go's `testing/synctest`](https://pkg.go.dev/testing/synctest) for timer and goroutine tests that stay in process. Wait for a competing goroutine to block with `synctest.Wait()` before checking an intermediate state. Keep real WebSocket and SQLite integration checks on the existing harnesses. Use the [testkit race option](docs/testkit.md#race-detector) when reviewing streaming or other concurrent Go changes.

## Making Changes

1. Create a branch from `main`
Expand All @@ -90,18 +107,15 @@ npm test

## Protobuf Schema Changes

If you modify `pkg/schemas/protobuf/v1/ocap.proto`:
The schemas in [pkg/schemas](pkg/schemas) are the source. Regenerate Go with `protoc` and `protoc-gen-go` on PATH:

```bash
go generate ./pkg/schemas/...
```

This regenerates the Go code. The frontend uses `ts-proto` — regenerate TypeScript types with:
Regenerate the affected TypeScript binding with the `ts-proto` version in its header. The decoders import [v1](ui/src/data/decoders/generated/ocap.pb.ts) or [v2](ui/src/data/decoders/generated/v2/ocap_v2.ts). Preserve the decoder-facing shapes and verify the generated diff and `playback-delivery` case. See the [open generation evidence](docs/context-evidence.md#open-evidence) for recovering the exact TypeScript options.

```bash
cd ui
npx protoc --ts_proto_out=./src/generated --ts_proto_opt=esModuleInterop=true ../pkg/schemas/protobuf/v1/ocap.proto
```
Preserve field numbers, wire types, defaults, and field presence for stored recordings. Check the affected recording versions and every writer and decoder using the changed field.

## Docker Build

Expand Down
17 changes: 17 additions & 0 deletions cmd/ocap-testkit/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main

import (
"fmt"
"os"

"github.com/OCAP2/web/internal/testkit"
)

var osExit = os.Exit

func main() {
if err := testkit.Run(os.Args[1:], os.Stdout, os.Stderr); err != nil {
fmt.Fprintln(os.Stderr, err)
osExit(1)
}
}
23 changes: 23 additions & 0 deletions cmd/ocap-testkit/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package main

import (
"os"
"testing"

"github.com/stretchr/testify/require"
)

func TestMainPassesArgumentsAndReportsFailure(t *testing.T) {
args, exit := os.Args, osExit
t.Cleanup(func() { os.Args, osExit = args, exit })
var codes []int
osExit = func(code int) { codes = append(codes, code) }

os.Args = []string{"ocap-testkit", "list"}
main()
require.Empty(t, codes)

os.Args = []string{"ocap-testkit", "unexpected"}
main()
require.Equal(t, []int{1}, codes)
}
Loading
Loading