BC5 readiness: Go wrapper forward-compat audit + field-level drift check

Merged
JE
4mo ago
+3980-649

Summary

The Go SDK is unique among 37signals' SDKs in having hand-written wrapper structs in go/pkg/basecamp/ that re-shape the generated types from go/pkg/generated/. PR 1 (#293) regenerated the generated Go client with BC5 forward-compat fields, but the wrappers were not updated — so external consumers (basecamp-cli Phase 1) couldn't see the new fields. A field-level audit (filed at go/BRIEF-bc5-forward-compat-wrappers.md by basecamp-cli's dev agent) revealed the gap predates BC5: ~65 fields across 22 wrapper structs were missing.

This PR closes the gap on three scope categories and installs a field-level drift check to prevent recurrence.

Stacked on: PR #293 (bc5-readiness-spec-foundations) because the generated fields in commit 7e9c4345 are inputs the wrapper propagation depends on. Will retarget to main after #293 merges.

Downstream impact: unblocks basecamp-cli Phase 1, which is blocked on this PR.

Scope

Category A — BC5 forward-compat (9 fields, original brief scope)

  • Todo.Steps []CardStep
  • Todoset.{TodosCount, CompletedLooseTodosCount, TodosURL, AppTodosURL}
  • Person.Tagline (alongside existing Bio — surfaced as a separate wrapper field per the spec note)
  • Notification.{BubbleUpURL, BubbleUpAt} (time.Time matching the existing ReadAt/UnreadAt pattern)
  • NotificationsResult.{BubbleUps, ScheduledBubbleUps}

Category B — Cross-cutting structural (~50 fields, pre-existing gaps)

Pervasive Recording-shaped fields (BookmarkURL, BoostsCount, BoostsURL, CommentsCount, CommentsURL, SubscriptionURL, InheritsStatus, VisibleToClients, Title) added to Recording, Comment, Message, MessageBoard, Forward, ForwardReply, CampfireLine, ScheduleEntry, QuestionAnswer, Todolist, TimesheetEntry, Inbox. One-offs: Campfire.{Topic, Position, BookmarkURL, SubscriptionURL}, MessageBoard.{AppMessagesURL, Position}, Template.{URL, AppURL, Dock []DockItem} (reusing existing DockItem), Person.{CanPing, CanAccessHillCharts, CanAccessTimesheet} (CanPing field existed; propagation didn't), Notification.{Creator, Participants, PreviewableAttachments} (new PreviewableAttachment companion type), Gauge.{Creator, Bucket}, GaugeNeedle.{Creator, Bucket, Parent}, Inbox.{Position, ForwardsCount, ForwardsURL}, Forward.{RepliesCount, RepliesURL}, plus Card-table fields surfaced by the drift audit: Card.BoostsURL, CardColumn.CommentsCount, CardStep.CompletionURL, Document.BoostsURL, Event.{BoostsCount, BoostsURL}, Todo.{VisibleToClients, SubscriptionURL, BoostsURL, CommentsCount, CommentsURL, CompletionURL, CompletionSubscribers}, Upload.BoostsURL.

Category C — Structural pattern fixes

  1. Standardize nested Person on personFromGenerated — every *FromGenerated that built a nested *Person previously inlined a 6-field shallow copy that silently dropped Bio, Tagline, Location, Title, PersonableType, AttachableSGID, Client, Employee, TimeZone, CanPing, CanAccessHillCharts, CanAccessTimesheet, CanManageProjects, CanManagePeople, Company, CreatedAt, UpdatedAt. Replaced with personFromGenerated calls. Pure refactor; makes commit 3's Person.Tagline flow through every nested context for free.
  2. Direct-decode wrappers — Notification, NotificationsResult, MyAssignment, Gauge, GaugeNeedle decode via json.Unmarshal on raw bytes. Added the missing fields with the appropriate JSON tags; decode pattern unchanged.

Cadence (8 commits)

Each commit individually builds and passes existing tests. Ordering chosen so the drift check (commit 5) goes green at introduction.

  1. wrappers: standardize nested Person on personFromGenerated
  2. wrappers: cross-cutting Recording-shaped fields
  3. wrappers: BC5 forward-compat fields
  4. wrappers: one-off structural fields
  5. (audit-driven) wrappers: close remaining structural gaps surfaced by drift audit
  6. scripts: field-level wrapper drift check
  7. wrappers: tests for new field propagation
  8. wrappers: gofmt long-tag struct alignment

Drift check

scripts/check-wrapper-drift/ (new), wired into make go-check-wrapper-drift and make check. Discovery is signature-based on *FromGenerated declarations plus an explicit map for the 5 direct-decode wrappers. Matching is keyed on JSON tag (not Go field name), so shape-equivalent collisions (URL vs Url, both tagged "url") are handled correctly. Opt-out marker format: // intentionally-omitted: <tag> - <reason> (ASCII hyphen + reason required, validated by regex). On the fully-fixed tree:

  • 51 (wrapper, generated) pairs walked
  • 842 generated fields verified
  • 0 drift, 0 intentionally-omitted markers required

Self-tests in scripts/check-wrapper-drift/main_test.go exercise the parser, marker regex, exclusion logic, and an end-to-end happy/drift case.

Verification

GateResult
cd go && go build ./...clean
cd go && go test ./pkg/basecamp/...all pass (21 new propagation tests)
make go-check-drift (operation-level)196 / 203 operations (96%), no drift
make go-check-wrapper-drift (NEW field-level)51 pairs, 842 fields, no drift
make conformance-go68 / 0 / 0 (unchanged from baseline)
make checkall checks passed

make conformance-go-replay is not applicable on this branch (the replay target is part of PR 3, on a separate branch).

Risks + open questions

  • Untyped JSON marshalling assertions in downstream consumers. Nested Person values gain ~17 fields. Any user asserting JSONEq against the previously-truncated wrapper output sees additions. Mitigation: this is forward-compat additive (no removals or renames); basecamp-cli's bump-PR is well-understood.
  • Person.{CreatedAt, UpdatedAt} in nested contexts. personFromGenerated formats these as RFC3339 strings; nested contexts now also populate them when present (previously dropped). Forward-compat additive.
  • Shape-equivalent tag collisions. The drift check matches by JSON tag, not Go field name. Documented in scripts/check-wrapper-drift/main.go header.
  • Untouched MyAssignment Date semantics. StartsOn/DueOn already used string (matching Todo.DueOn); no change needed.

Coordination

basecamp-cli Phase 1 is blocked on this PR. Please notify the basecamp-cli five branch on merge so they can make bump-sdk and resume.


Summary by cubic

Propagates BC5 fields through the Go wrappers and upgrades the wrapper-drift check to flag both tag gaps and unassigned fields, including inline-converted and direct-decode wrappers. Also standardizes nested Person mapping, normalizes flexible embedded-person IDs, and fixes required-bool and timestamp serialization.

  • New Features

    • Surface BC5 fields across wrappers: Todo.Steps, Todoset.{TodosCount, CompletedLooseTodosCount, TodosURL, AppTodosURL}, Person.Tagline, Notification.{BubbleUpURL, BubbleUpAt}, NotificationsResult.{BubbleUps, ScheduledBubbleUps}.
    • Cross-cutting structural fields added where missing: BookmarkURL, Boosts{Count,URL}, Comments{Count,URL}, SubscriptionURL, InheritsStatus, VisibleToClients, Title, plus card/vault/event/todo completions and URLs (e.g., Card.BoostsURL, CardStep.CompletionURL, Event.{BoostsCount,BoostsURL}, Document/Upload.BoostsURL, Todo.{VisibleToClients,SubscriptionURL,BoostsURL,Comments{Count,URL},CompletionURL,CompletionSubscribers}).
    • One-offs: Notification.{Creator, Participants, PreviewableAttachments}, Gauge.{Creator,Bucket}, GaugeNeedle.{Creator,Bucket,Parent}, Inbox.{Position, ForwardsCount, ForwardsURL}, Forward.{RepliesCount, RepliesURL}, Campfire.{Topic, Position, BookmarkURL, SubscriptionURL}, MessageBoard.{AppMessagesURL, Position}, Template.{URL, AppURL, Dock}, Person.{CanAccessHillCharts, CanAccessTimesheet}.
  • Refactors

    • Standardize all nested Person conversions on personFromGenerated; route Subscription.Subscribers through it. Add embedded-person ID normalization so Creator/Participants decode in notifications and gauges even when IDs are strings or sentinels.
    • Wrapper-drift checker now verifies both tag presence and field population, including inline-converted wrappers via composite-literal/selector analysis; direct-decode wrappers are tag-checked. Coverage: 76 pairs, no drift. make go-check-wrapper-drift runs checker tests before the drift pass.
    • Serialization/decode fixes: drop omitempty from required visible_to_clients/inherits_status bools on Todo, Comment, Message, MessageBoard, Inbox, Forward, ForwardReply, TimesheetEntry; change Notification.BubbleUpAt to *time.Time. Tests pin required-bool serialization and field propagation.
    • Delegate ProjectConstruction.Project to projectFromGenerated; share dockItemFromGenerated for Project/Template.