Skip to content

Store full Source alongside legacy source_identifier on all sourced commands - #15

Open
ryantaylor wants to merge 1 commit into
mainfrom
add-source-to-legacy-commands
Open

Store full Source alongside legacy source_identifier on all sourced commands#15
ryantaylor wants to merge 1 commit into
mainfrom
add-source-to-legacy-commands

Conversation

@ryantaylor

Copy link
Copy Markdown
Owner

Summary

  • BuildSquad/BuildGlobalUpgrade (SourcedPbgid), UseAbility (SourcedAbility), and CancelProduction (SourcedIndex) previously exposed only a legacy truncated u16 source_identifier — the fully parsed Source was thrown away right after wire parsing (Source::parse always runs and decodes it in full, regardless of command type; the truncation was purely a backward-compat holdover from before the Source enum existed).
  • Every other sourced command variant (Targeted, SourcePbgid, Sourced, Ability) already exposes the full Source. This closes that gap.
  • Each of the three structs now stores both source_identifier: u16 (kept for existing consumers) and source: Source (for new code — Self::source is now the recommended accessor), rather than replacing one with the other, per the precedent already set by a2eb90a (CMD_CancelConstruction).
  • CommandPayload::source() now returns Some(..) for BuildSquad/BuildGlobalUpgrade/UseAbility/CancelProduction, where it previously always returned None.
  • SourcedPbgid/SourcedIndex/SourcedAbility are no longer Copy (only Clone) since Source::Squads holds a Vec<u32>, consistent with every other full-Source struct in the crate.
  • Updated the cohlib-rb Ruby marshalling to include source in the hash for these three payload shapes.
  • Added a regression test (legacy_sourced_variants_now_expose_full_source) guarding that these four variants now carry a full source across the fixture corpus.

Test plan

  • cargo test --workspace — all green
  • cargo clippy --workspace -- -D warnings — clean
  • cargo fmt --check — clean
  • cargo build -p cohlib -p cohlib-rb --features cohlib/magnus — clean (Ruby-facing binding compiles)
  • cargo run --release --example vault_regression against the ~9.3k-replay real-world corpus — 0 panics, 0 parse errors, 0 unexpected Unknown fallbacks (confirms no command in the corpus hits the Source::Squads panic path for these four newly-exposed types)

🤖 Generated with Claude Code

…ommands

BuildSquad, BuildGlobalUpgrade, UseAbility, and CancelProduction
(backed by SourcedPbgid/SourcedAbility/SourcedIndex) previously exposed
only a legacy truncated u16 source_identifier and discarded the fully
parsed Source immediately after wire parsing, unlike every other
sourced command variant. Source::parse always decodes the full source
regardless of command type — the truncation was purely a backward
compatibility choice for these four types, predating the Source enum.

Now these three structs store both fields: source_identifier (u16, for
existing consumers) and source (Source, for new code going forward),
matching the pattern used elsewhere in the crate (e.g. the
CMD_CancelConstruction fix) rather than replacing one with the other.
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