Skip to content

Upgrade Go to 1.27 - #625

Merged
fank merged 2 commits into
OCAP2:mainfrom
YetheSamartaka:main
Dec 1, 2026
Merged

fank merged 2 commits into
OCAP2:mainfrom
YetheSamartaka:main

Conversation

@YetheSamartaka

@YetheSamartaka YetheSamartaka commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor
  • Upgrade Go from 1.27.2 to 1.27.4 (go.mod). The README now states the real requirement; it said Go 1.26+.
  • Streamed recordings are saved as before by default: native v2 protobuf plus a v1 .json.gz copy and the debug manifest.json, and if writing v2 fails the mission is saved from the v1 JSON instead.
  • New setting streaming.protobufOnly (OCAP_STREAMING_PROTOBUFONLY, default false): store native v2 recordings without the v1 copy and manifest.json.
  • New setting streaming.disableV1Fallback (OCAP_STREAMING_DISABLEV1FALLBACK, default false): if writing the v2 recording fails, the save fails instead of falling back to v1 JSON. The producer gets no acknowledgement, the recording is marked failed, and a resumable extension sends the mission again from its spool. Any v1 copy written for that save is deleted.
  • The existing viewer download URL (/data/<name>.json.gz) still serves stored v1 JSON files. For a native v2 recording stored without its v1 copy, it generates v1 JSON from the protobuf when downloaded, one export at a time so parallel downloads can't exhaust memory.
  • The v2 to v1 export keeps which units are in vehicles (the extension only sends the vehicle id), keeps marker order, and adds the player UID to connected/disconnected events, matching the extension's v1 format.
  • Capture delay is rounded to the nearest millisecond instead of truncated (1.001 s now gives 1001 ms, not 1000 ms) in the JSON engine, v1 parser, streaming reader and v2 writer.
  • SQLite migration 16 adds indexes on operations(date) and operations(conversion_status, id). The mission list is explicitly ordered by id, and errors during row iteration are reported instead of returning partial results.
  • Tests: timing-based waits in the conversion and maptool tests replaced with testing/synctest, fixing data races. New tests cover the export, the download route through the prefixed mux, both storage settings (saves, v2 failures with and without the fallback) and the migration.
  • Docs: README settings table, setting.json.example, streaming architecture and testkit docs and cases updated. AGENTS.md describes the default storage and the two settings.

Go 1.27 features used (benchmarks: synthetic recording of 100 entities over 1,000 frames, Go 1.26.11 vs 1.27.4, benchstat, n=12):

  • compress/flate was rewritten in Go 1.27. Re-tuned for it, precompressed playback sidecars use default gzip compression instead of best: conversion went from 563 ms to 193 ms (−66%) and the gzip files were 4.7% smaller. On Go 1.27 the default level compresses this data better than the best level.

  • encoding/json/v2 is available by default in Go 1.27, without GOEXPERIMENT. The v2 to v1 download writes JSON straight into the gzip stream with MarshalWrite in v1-compatible mode, instead of building it in memory first.

  • The goroutineleak profile is always available in Go 1.27 (Go 1.26 needed GOEXPERIMENT). An optional stream-recovery diagnostic uses it (OCAP_STREAM_LEAK_PROFILE=1).

  • Tests use httptest.NewTestServer, new in Go 1.27.

  • Trade-off: on Go 1.27, encoding/json runs on the new v2 engine, so legacy JSON conversion makes 33% more allocations, uses 10% more memory and takes about 5% longer than on Go 1.26. The web has used this engine since moving to 1.27.2. This PR streams parsed positions straight into chunk buckets, which cuts conversion memory by 8.6%; the number of allocations is unchanged.

  • Verified locally: Go statement coverage 100% in every changed package, race detector clean on the server, ingestion, storage, conversion and maptool packages, testkit stream-recovery case passes.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Merging this branch will not change overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/web/internal/conversion 100.00% (ø)
github.com/OCAP2/web/internal/ingestion 100.00% (ø)
github.com/OCAP2/web/internal/maptool 100.00% (ø)
github.com/OCAP2/web/internal/server 100.00% (ø)
github.com/OCAP2/web/internal/storage 100.00% (ø)
github.com/OCAP2/web/internal/testkit 100.00% (ø)
Coverage details

Compared to commit 1979cd5 (run #46477815413)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/OCAP2/web/internal/ingestion/export_v1_from_v2.go 100.00% (+100.00%) 196 (+196) 196 (+196) 0 🌟
github.com/OCAP2/web/internal/ingestion/extra_events.go 100.00% (ø) 52 52 0
github.com/OCAP2/web/internal/ingestion/session.go 100.00% (ø) 445 (+6) 445 (+6) 0
github.com/OCAP2/web/internal/ingestion/writer_v2.go 100.00% (ø) 234 (+2) 234 (+2) 0
github.com/OCAP2/web/internal/server/handler.go 100.00% (ø) 365 (+2) 365 (+2) 0
github.com/OCAP2/web/internal/server/handler_stream.go 100.00% (ø) 555 (+14) 555 (+14) 0
github.com/OCAP2/web/internal/server/operation.go 100.00% (ø) 309 (+5) 309 (+5) 0
github.com/OCAP2/web/internal/server/recording_download.go 100.00% (+100.00%) 36 (+36) 36 (+36) 0 🌟
github.com/OCAP2/web/internal/server/setting.go 100.00% (ø) 101 (+2) 101 (+2) 0
github.com/OCAP2/web/internal/storage/json.go 100.00% (ø) 55 55 0
github.com/OCAP2/web/internal/storage/parser.go 100.00% (ø) 10 (+6) 10 (+6) 0
github.com/OCAP2/web/internal/storage/parser_v1.go 100.00% (ø) 292 (+6) 292 (+6) 0
github.com/OCAP2/web/internal/storage/precompress.go 100.00% (ø) 60 60 0
github.com/OCAP2/web/internal/storage/streaming_converter.go 100.00% (ø) 115 (+1) 115 (+1) 0
github.com/OCAP2/web/internal/storage/streaming_json_reader.go 100.00% (ø) 107 107 0
github.com/OCAP2/web/internal/testkit/cases.go 0.00% (ø) 0 0 0

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files:

  • github.com/OCAP2/web/internal/conversion/worker_test.go
  • github.com/OCAP2/web/internal/ingestion/export_v1_from_v2_test.go
  • github.com/OCAP2/web/internal/ingestion/writer_v2_test.go
  • github.com/OCAP2/web/internal/maptool/jobmanager_test.go
  • github.com/OCAP2/web/internal/server/coverage_extra_test.go
  • github.com/OCAP2/web/internal/server/handler_stream_resume_test.go
  • github.com/OCAP2/web/internal/server/handler_stream_test.go
  • github.com/OCAP2/web/internal/server/operation_indexes_test.go
  • github.com/OCAP2/web/internal/server/operation_test.go
  • github.com/OCAP2/web/internal/server/recording_download_test.go
  • github.com/OCAP2/web/internal/server/route_access_test.go
  • github.com/OCAP2/web/internal/storage/json_test.go
  • github.com/OCAP2/web/internal/storage/parser_test.go
  • github.com/OCAP2/web/internal/storage/precompress_test.go
  • github.com/OCAP2/web/internal/storage/streaming_json_reader_test.go

@fank

fank commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Ratatoskr reviewed this pull request.

Approved on 91f1bb64. See the review.

Finished 2026-11-30 22:13 UTC.

@fank fank left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE — 0 blocking findings.

Review details

Reviewed head 91f1bb64a0368dca5f88be4f0f62c57418e9f824 against base 1979cd51bb45af5af54b5cff76912e732e2a94bd, including the recording changes beyond the title. No actionable correctness or safety defects identified.

  • Traced protobuf-only finalization and failure propagation (internal/server/handler_stream.go:933), legacy download reconstruction (internal/ingestion/export_v1_from_v2.go:20), and the bounded/cancellable download path (internal/server/recording_download.go:28). Existing JSON downloads retain priority. The registered non-root-prefix viewer-route test covers authorization and native export, including missing/corrupt artifacts (internal/server/route_access_test.go:86).
  • Reviewed capture-delay rounding, visitor-based position conversion, and transactional v16 indexes plus iteration-error handling. New tests exercise conversion parity, cancellation, rollback, and downstream results.
  • Inspected CI run 46521814329: Go 1.27.4, embedded frontend build, go test -coverprofile=cover.raw -coverpkg=./cmd/...,./internal/... ./..., and backend build succeeded. Downloaded coverage confirms 196/196 statements in the exporter, 36/36 in recording downloads, 292/292 in the v1 parser, and 309/309 in the operation repository.
  • Local go version, go test ./..., and go run ./cmd/ocap-testkit run stream-recovery --race could not execute: go: command not found. No local test or race success is claimed. No UI source changed; no browser rendering or deployed-producer acceptance was performed.
  • GraphQL review-thread enumeration returned no threads (hasNextPage: false): none to resolve, keep open, or skip. Authenticated reviewer: fank.

The reviewed checkout was left unchanged. Approval is the code-review verdict, not a bypass of required checks.

Streamed native v2 recordings are saved as before: with a v1 .json.gz
copy and the debug manifest.json, and from the v1 JSON when writing v2
fails. Two settings opt out:

- streaming.protobufOnly stores them without the copy and
  manifest.json; downloads convert them to v1 JSON on request.
- streaming.disableV1Fallback fails the save instead of falling back
  and deletes a v1 copy written for it. The producer gets no
  acknowledgement, and a resumable extension resends the mission.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@YetheSamartaka
YetheSamartaka requested a review from fank December 1, 2026 08:50
@fank

fank commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Ratatoskr reviewed this pull request.

Approved on fb49ee08. See the review.

Finished 2026-12-01 09:05 UTC.

@fank fank left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE — 0 blocking findings.

Review details

Reviewed fb49ee08af38cffb9affb5957bc12f77c1bb3dc6 against 1979cd51bb45af5af54b5cff76912e732e2a94bd. No concrete correctness, data-loss, or authorization regression found after tracing finalization failures, download reconstruction, registered viewer access, and legacy conversion consumers.

Local verification (Go 1.27.4, PATH=/tmp/gotool/go/bin:$PATH):

  • go test -count=1 -coverprofile=/tmp/pr625-coverage.out ./internal/ingestion ./internal/storage ./internal/conversion ./internal/maptool — passed; each package reports 100% statement coverage. Inspected affected-function coverage with go tool cover -func=/tmp/pr625-coverage.out.
  • go test ./... — unsuccessful locally: SQLite-dependent server, webserver, and convert CLI tests cannot initialize SQLite because this environment lacks a C compiler and uses CGO_ENABLED=0. This is a verification limitation, not evidence of a PR defect. Local CGO-dependent integration, race, and stream-recovery testkit checks remain unverified; native map pipeline tooling was not independently exercised.
  • GitHub's current test and Code coverage report checks both succeeded. No UI source changes; no visual verification performed.

Earlier discussions: GraphQL review-thread enumeration returned no threads (hasNextPage: false). Resolved: 0; still open: 0; skipped: 0. No discussion mutations were needed. Confirmed the PR head remained unchanged before publication; reviewed checkout left unmodified.

@fank
fank merged commit d982b8a into OCAP2:main Dec 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants