Skip to content

fix: sector event side field and capturedFlag cleanup#143

Merged
fank merged 3 commits intomainfrom
fix/sector-event-side-field
Mar 7, 2026
Merged

fix: sector event side field and capturedFlag cleanup#143
fank merged 3 commits intomainfrom
fix/sector-event-side-field

Conversation

@fank
Copy link
Member

@fank fank commented Mar 7, 2026

Summary

  • Preserve the Side field in SectorEvent through all storage backends (memory, postgres, websocket) and v1 JSON export
  • Remove capturedFlag references from sector event parser comments, test cases, and v1 builder format docs — capturedFlag is no longer routed through :EVENT:SECTOR: by the addon

Test plan

  • TestParseSectorEvent passes (capturedFlag test case removed)
  • TestBuildWithSectorEvents passes with side field in v1 JSON output
  • All storage backend tests pass with side field

The old C++ extension passed sector event data raw 1:1 into JSON, which
included the capturing side. The new typed pipeline was missing this field.

- Add Side field to core.SectorEvent struct
- Update parser to read side from arg[4], position from args[5-7]
- Include side in v1 JSON export: [objectType, unitName, side, [pos]]
- Include side in postgres message format
- Update all tests with side field data and assertions
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a regression introduced in a previous refactor (#142) by restoring the Side field to core.SectorEvent struct. This field, which indicates the capturing or contesting side of a sector event, was inadvertently dropped. The changes ensure that this crucial information is now correctly parsed, stored, and exported, maintaining data integrity and consistency across the system.

Highlights

  • core.SectorEvent struct: Added a Side field to the core.SectorEvent struct to store which side captured or contested a sector.
  • Event Parser: Updated the event parser to correctly read the Side field from positional argument 4 and adjusted the parsing indices for position (X, Y, Z) accordingly.
  • Data Export (v1 JSON): Modified the v1 JSON export format for sector events to include the newly added Side field.
  • Data Storage (PostgreSQL): Updated the PostgreSQL message format for sector events to incorporate the Side field.
  • Test Coverage: All relevant unit, parser, builder, and integration tests were updated to include the Side field data and assertions, ensuring comprehensive coverage.
Changelog
  • internal/parser/parse_events.go
    • Updated the ParseSectorEvent function to include side as a parameter in the argument description.
    • Modified the parsing logic to extract the Side from data[4] and adjusted the indices for PosX, PosY, and PosZ from data[4-6] to data[5-7].
  • internal/parser/parse_events_test.go
    • Updated existing test cases to include the Side field in the input data and assertions.
    • Added a new test case to cover minimal input without side or position.
    • Adjusted input arrays for error cases related to bad position to include a Side value.
  • internal/storage/memory/export/v1/builder.go
    • Modified the comment describing the v1 JSON export format for sector events to include side.
    • Updated the append logic to include evt.Side in the exported []any array for sector events.
  • internal/storage/memory/export/v1/builder_test.go
    • Updated SectorEvents test data to include Side values.
    • Adjusted assertions to verify the presence and correctness of the Side field in the exported JSON structure.
  • internal/storage/memory/export_test.go
    • Modified the RecordSectorEvent call to include a Side value.
    • Added an assertion to verify the Side field in the exported sector event payload.
  • internal/storage/memory/memory_test.go
    • Added Side field to the core.SectorEvent struct in the test data.
    • Added an assertion to check the Side field of the recorded sector event.
  • internal/storage/postgres/postgres.go
    • Modified the Message format for GeneralEvent created from SectorEvent to include e.Side.
  • internal/storage/postgres/postgres_test.go
    • Added Side field to the core.SectorEvent struct in the test data.
  • internal/worker/dispatch_test.go
    • Added Side field to the core.SectorEvent struct in the test data.
    • Added an assertion to check the Side field of the recorded sector event.
  • pkg/core/events.go
    • Added a Side field (string) to the SectorEvent struct with a comment explaining its purpose.
Activity
  • The author has completed the defined test plan, ensuring all unit, parser, builder, and integration tests pass and cover the new Side field.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly adds the Side field to core.SectorEvent to preserve which side captured or contested a sector. The changes are consistently applied across parsing, storage backends (memory and postgres), and the v1 JSON export format. All relevant tests have been updated to cover the new field, including cases where the side is present, absent, or empty. The implementation is clean and follows the intentions described in the pull request. I have no further suggestions for improvement.

capturedFlag is no longer routed through :EVENT:SECTOR: in the addon.
Remove it from parser comments, test cases, and builder format docs.
@fank fank changed the title fix: preserve side field in sector events fix: sector event side field and capturedFlag cleanup Mar 7, 2026
The v1 JSON spec wraps endMission data in an inner array:
  [frameNum, "endMission", [side, message]]

Builder was incorrectly producing flat format:
  [frameNum, "endMission", side, message]

This caused parser_v1.go to read only "side" as the message,
losing the actual message text.
@github-actions
Copy link

github-actions bot commented Mar 7, 2026

Merging this branch will not change overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/extension/v5/internal/parser 100.00% (ø)
github.com/OCAP2/extension/v5/internal/storage/memory 99.22% (ø)
github.com/OCAP2/extension/v5/internal/storage/memory/export/v1 100.00% (ø)
github.com/OCAP2/extension/v5/internal/storage/postgres 85.78% (ø)
github.com/OCAP2/extension/v5/internal/worker 100.00% (ø)
github.com/OCAP2/extension/v5/pkg/core 0.00% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/OCAP2/extension/v5/internal/parser/parse_events.go 100.00% (ø) 229 (+2) 229 (+2) 0
github.com/OCAP2/extension/v5/internal/storage/memory/export/v1/builder.go 100.00% (ø) 212 212 0
github.com/OCAP2/extension/v5/internal/storage/postgres/postgres.go 85.78% (ø) 232 199 33
github.com/OCAP2/extension/v5/pkg/core/events.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/extension/v5/internal/parser/parse_events_test.go
  • github.com/OCAP2/extension/v5/internal/storage/memory/export/v1/builder_test.go
  • github.com/OCAP2/extension/v5/internal/storage/memory/export_test.go
  • github.com/OCAP2/extension/v5/internal/storage/memory/memory_test.go
  • github.com/OCAP2/extension/v5/internal/storage/postgres/postgres_test.go
  • github.com/OCAP2/extension/v5/internal/worker/dispatch_test.go

@fank fank merged commit a85c71e into main Mar 7, 2026
3 checks passed
@fank fank deleted the fix/sector-event-side-field branch March 7, 2026 13:59
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.

1 participant