Skip to content

Move duplicate trait attributes to resource.#996

Open
ggreer wants to merge 1 commit into
mainfrom
ggreer/move-traits-to-resource
Open

Move duplicate trait attributes to resource.#996
ggreer wants to merge 1 commit into
mainfrom
ggreer/move-traits-to-resource

Conversation

@ggreer

@ggreer ggreer commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Add WithResourceProfile, WithResourceIcon, and WithResourceStatus to ResourceOption.

Deprecate old trait options, but have them still work by syncing the trait attributes to the resource.

Limit NHI details to 1024 bytes.

Protofmt.

@ggreer ggreer requested a review from a team July 1, 2026 23:45
Comment thread .golangci.yml Outdated
Comment on lines +99 to +103
# Trait tests intentionally exercise deprecated trait fields for backwards compatibility.
- linters:
- staticcheck
path: pkg/types/resource/.*_test\.go
text: "SA1019"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟠 Bug: Deprecating these trait proto fields (profile/icon/status/created_at) makes staticcheck SA1019 fire on every non-test caller that reads or writes them. This SA1019 exclusion only covers pkg/types/resource/*_test.go, but there are unguarded production callers — pkg/c1zsanitize/handlers.go (reads via getters and writes via UserTrait_builder{Profile,Icon}/SetStatus/SetCreatedAt), pkg/sync/syncer.go:1382,1391,1400,2361,2374, and pkg/baton/explorer/baton_service.go:23-24. make lint (staticcheck is enabled) will fail. Either broaden this exclusion / add //nolint:staticcheck at those sites, or migrate those callers to the resource-level fields. (confidence: high)

@ggreer ggreer force-pushed the ggreer/move-traits-to-resource branch from 578cdcf to 8ec25c9 Compare July 1, 2026 23:52
Comment on lines +229 to +233
string nhi_detail = 2 [(validate.rules).string = {
ignore_empty: true
max_bytes: 1024
min_bytes: 1
}];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: This adds a new min_bytes:1/max_bytes:1024 constraint to nhi_detail (a validation tightening) that's unrelated to the PR's stated purpose of moving trait attributes to the resource. ignore_empty keeps empty values valid, but any connector currently emitting an nhi_detail longer than 1024 bytes would newly fail validation. Confirm this tightening is intended and safe for existing callers. (confidence: low)

Comment on lines +229 to +233
string nhi_detail = 2 [(validate.rules).string = {
ignore_empty: true
max_bytes: 1024
min_bytes: 1
}];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: This tightens nhi_detail validation (new max_bytes: 1024) where none existed before. It's intentional per the PR description, but any existing connector emitting a longer detail will now fail message validation at sync time — worth confirming no downstream connector relies on longer values before this ships. (confidence: medium)

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

General PR Review: Move duplicate trait attributes to resource.

Blocking Issues: 0 | Suggestions: 1 | Threads Resolved: 0
Criteria: Criteria status: loaded .claude/skills/ci-review.md from trusted base 84d755cd854f.
Review mode: full
View review run

Review Summary

Full PR diff scanned for security and correctness. This PR adds resource-level profile/icon/status/created_at fields (proto field numbers 9-12, plus a new Status message), deprecates the equivalent trait-level fields, and keeps the deprecated WithXTrait options working by mirroring their values onto the resource. The proto changes are additive and wire-safe (no renumbered/reused/removed active fields), generated pb/*.pb.go output matches the proto sources, and the deprecated-field fallback getters in resource_attrs.go are covered by new tests. The enum-identity assumptions (UserTrait_Status, AgentTrait_AgentStatus, Status_ResourceStatus all 0-3) hold, and no unused-variable or shadowing regressions were introduced in cmd/baton/csv.go, cmd/baton/xlsx.go, or pkg/sync/syncer.go. No new blocking issues found.

Two items from prior reviews still apply and are not re-flagged inline: proto/c1/connector/v2/annotation_trait.proto nhi_detail now caps at max_bytes: 1024 (can reject previously-valid longer values at sync time), and pkg/sdk/version.go remains v0.16.0 despite the deprecations/validation tightening — consider a minor bump as the pre-1.0 compatibility signal.

Security Issues

None found.

Correctness Issues

None found.

Suggestions

  • .golangci.yml:105-111 — the new blanket SA1019 exclusion suppresses all staticcheck deprecation warnings in every _test.go; consider narrowing the text matcher to the specific deprecated symbols.
Prompt for AI agents
Verify each finding against the current code and only fix it if needed.

## Suggestions

In .golangci.yml:
- Around line 105-111: The added exclusion rule uses a text matcher of SA1019 scoped to path _test.go, which suppresses ALL staticcheck deprecation warnings in every test file, not just the intended trait-level profile/icon/status/created_at fields. Narrow it by matching the specific deprecated symbols in the text regex (mirroring the existing dotc1z.NewC1ZFile rule just above) so unrelated future deprecations in tests are not silently masked.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blocking issues found.

@ggreer ggreer force-pushed the ggreer/move-traits-to-resource branch from 8ec25c9 to 7143eb3 Compare July 2, 2026 00:22

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blocking issues found.

@ggreer ggreer force-pushed the ggreer/move-traits-to-resource branch from 7143eb3 to ca995ec Compare July 2, 2026 15:08
Comment thread proto/c1/connector/v2/resource.proto Outdated

message Status {
enum ResourceStatus {
RESOURCE_STATUS_STATUS_UNSPECIFIED = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: The zero value RESOURCE_STATUS_STATUS_UNSPECIFIED has a doubled STATUS_STATUS segment; every other zero value in this codebase follows <PREFIX>_UNSPECIFIED (e.g. AGENT_STATUS_UNSPECIFIED). Since this is a brand-new wire enum, the name is free to fix now but permanent once shipped — consider RESOURCE_STATUS_UNSPECIFIED. (medium confidence)

Add WithResourceProfile, WithResourceIcon, and WithResourceStatus to ResourceOption.

Deprecate old trait options, but have them still work by syncing the trait attributes to the resource.

Protofmt.
@ggreer ggreer force-pushed the ggreer/move-traits-to-resource branch from ca995ec to a461893 Compare July 2, 2026 15:50
Comment thread .golangci.yml
Comment on lines +105 to +111
# Tests intentionally exercise deprecated fields (e.g. trait-level
# profile/icon/status/created_at) to cover backwards compatibility with
# data written by older connectors.
- linters:
- staticcheck
path: _test\.go
text: "SA1019"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Suggestion: This blanket SA1019 exclusion suppresses all staticcheck deprecation warnings across every _test.go file, not just the trait-level profile/icon/status/created_at fields it's intended for. It could mask unrelated future deprecations in tests. Consider narrowing the text: to the specific deprecated symbols (as the existing dotc1z.NewC1ZFile rule above does) to keep coverage tight. (confidence: medium, non-blocking)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No blocking issues found.

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