Skip to content

Canonicalize owner names in upload payload (LIBTRACK-132)#33

Draft
naarok wants to merge 2 commits into
masterfrom
the-owners-tab-is-showing-lots-of-variations-for-team-names-this-should-be-cleaned-up
Draft

Canonicalize owner names in upload payload (LIBTRACK-132)#33
naarok wants to merge 2 commits into
masterfrom
the-owners-tab-is-showing-lots-of-variations-for-team-names-this-should-be-cleaned-up

Conversation

@naarok
Copy link
Copy Markdown
Contributor

@naarok naarok commented May 19, 2026

What's in this PR?

Fixes LIBTRACK-132 on the gem side. library_tracking's Owners tab was showing duplicate rows for the same team because outgoing payloads contained owner names in whatever shape each parser happened to produce — :bizops, bizops, :bizops:, "bizops", and the :attention_needed Ruby symbol all flowed through verbatim. This change canonicalizes owner names exactly once, at the single payload seam where upload data is assembled.

Changes:

  • Add LibraryVersionAnalysis::Ownership.canonicalize(name), a class method that returns a canonical lowercase team name with surrounding whitespace, quotes ("/'), and colons stripped (falling back to unknown for empty/punctuation-only input). The rule is documented to stay in lockstep with library_tracking's Owner.canonicalize_team so both sides agree on canonical form even when versions skew.
  • Apply the helper at one site: CheckVersionStatus#server_data, wrapping the owner value in the libraries.push({...}) call. The in-memory Versionline.owner is intentionally left untouched so downstream branching such as line.owner == :attention_needed in #get_mode_summary keeps working. vulns.push and new_versions.push do not carry owner data, so a single edit covers the payload's owner surface.
  • Add RSpec coverage for the helper (colon stripping, quote stripping, downcase, :attention_needed symbol, empty/nil/whitespace/punctuation fallback, idempotency) and for the payload seam (:bizopsbizops, :attention_neededattention_needed, "bizops"bizops, plus a regression assertion that row.owner retains its pre-payload value).
  • Commit the OpenSpec proposal artifacts under openspec/changes/emit-canonical-owner-names/ so the change is captured spec-driven.

The companion change in library_tracking does the server-side normalization and the one-time merge of Owner rows already in the database.

QA Instructions

  • bundle _2.5.22_ exec rspec passes — 124 examples, 0 failures locally. (The Gemfile.lock pins bundler 2.5.22; a default bundle may resolve to a newer bundler that libyear-bundler rejects.)
  • openspec validate emit-canonical-owner-names --strict reports the change is valid.
  • Inspect lib/library_version_analysis/check_version_status.rb at the libraries.push site and confirm only the outbound owner value is wrapped — row.owner is not reassigned.
  • Manual (optional): run the gem against a sample repo with the [upload] log enabled and confirm owner names in the log come out canonical (lowercase, no : prefix, no quotes).

References

Warning

This repository does not have a PR template (.github/PULL_REQUEST_TEMPLATE.md). Consider adding one to give future PRs a consistent structure.

Co-Authored-By: Amplify 1.6.0 amplify@getjobber.com

naarok and others added 2 commits May 19, 2026 15:19
Captures the proposal, design, spec, and tasks artifacts for the
emit-canonical-owner-names change. This change addresses LIBTRACK-132 by
canonicalizing owner team names in the upload payload assembled by
CheckVersionStatus#server_data so the library_tracking Owners tab no
longer shows duplicate rows for variants like :bizops, bizops, and
"bizops".

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Amplify 1.6.0 <amplify@getjobber.com>
Add `LibraryVersionAnalysis::Ownership.canonicalize`, a class method that
returns a canonical lowercase owner team name with surrounding
whitespace, quotes, and colons stripped (falling back to "unknown" for
empty/punctuation-only input). The rule mirrors `library_tracking`'s
`Owner.canonicalize_team` byte-for-byte so both sides agree on canonical
form even when versions skew.

Apply the helper at the single payload seam in
`CheckVersionStatus#server_data` where `libraries.push({...})` is
called. `row.owner` (and the in-memory `Versionline.owner` it points to)
is intentionally left untouched so downstream branching such as
`line.owner == :attention_needed` in `#get_mode_summary` keeps working.
The other payload builders (`vulns.push`, `new_versions.push`) do not
include the owner field, so this one edit covers the payload surface.

Add RSpec coverage:
- Unit specs for `Ownership.canonicalize` covering colon stripping,
  quote stripping, downcase, the `:attention_needed` symbol, the
  empty/`nil`/whitespace/punctuation fallback, and idempotency.
- Payload-level specs on `CheckVersionStatus#server_data` confirming
  `:bizops` -> "bizops", `:attention_needed` -> "attention_needed",
  and `"bizops"` -> "bizops", plus a regression assertion that
  `row.owner` retains its pre-payload value after `#server_data` runs.

All 124 specs pass via `bundle _2.5.22_ exec rspec`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Amplify 1.6.0 <amplify@getjobber.com>
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