Skip to content

feat: add discoverable asset fieldsets - #1

Merged
bryansray merged 4 commits into
mainfrom
feat/discoverable-asset-fields
Aug 28, 2026
Merged

feat: add discoverable asset fieldsets#1
bryansray merged 4 commits into
mainfrom
feat/discoverable-asset-fields

Conversation

@bryansray

@bryansray bryansray commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • update package metadata to the corva-ai/python-api-client repository
  • replace the expensive default fields=* asset search with a compact summary fieldset
  • expose typed asset, relationship, company, viewer-pad, and viewer-line field enums
  • retain arbitrary strings plus explicit *, all, and server-default behavior
  • document the behavioral change and field-selection patterns
  • add just check-asset-fields to detect drift from the Rails serializers and relationship whitelist

Payload measurement

For 100 otherwise identical production asset results:

Fieldset Serialized size Elapsed time Included records
compact 14,056 bytes 0.657 s 0
* 435,118 bytes 3.887 s 127

The compact response was 96.8% smaller (approximately 31x). Timings are a single observational sample and may vary.

Validation

  • just check
  • just check-dist
  • just check-asset-fields /Users/bryanray/Projects/Work/Corva/corva-api
  • 54 tests passing

Behavioral change

Asset search now defaults to asset.name,asset.asset_type,asset.status. Callers that require the previous full response can pass fields="*" explicitly.

@bryansray bryansray self-assigned this Aug 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the SDK’s asset search behavior to default to a compact, discoverable sparse fieldset (instead of fields=*) to significantly reduce payload size and latency, while exposing typed enums for supported asset fields/relationships and documenting field-selection patterns for consumers.

Changes:

  • Default AssetsClient.search() to a compact fieldset (asset.name,asset.asset_type,asset.status) and add field/relationship enums plus serialization support.
  • Add a drift-check script + just check-asset-fields recipe, and expand formatting/linting to include scripts/.
  • Update consumer-facing docs and metadata (README, changelog, repository URLs) to reflect the new behavior and project location.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_assets_resource.py Updates expectations for the new default fieldset and adds coverage for enum/list-based field serialization and explicit full fieldsets.
src/corva_api_client/resources/assets.py Introduces field/relationship enums, default compact fieldset, and serialization logic for fields in asset search.
src/corva_api_client/resources/init.py Re-exports new asset field/relationship enums and defaults for public consumption.
scripts/check_asset_fields.py Adds a script to compare SDK enums against Rails serializers/relationship whitelist to detect drift.
README.md Documents the new default asset fieldset and how to select additional fields/relationships safely.
pyproject.toml Updates project URLs to the corva-ai/python-api-client repository.
justfile Includes scripts/ in ruff commands and adds check-asset-fields recipe.
CHANGELOG.md Records the behavioral change and the introduction of discoverable field enums.
.github/workflows/ci.yml Updates CI quality checks to include scripts/ in ruff formatting/linting.
Suppressed comments (1)

scripts/check_asset_fields.py:45

  • _asset_relationships() uses chained split(...)[1] indexing; if the controller layout changes (missing "def show", different ordering, etc.) this will raise IndexError with a non-actionable message. Convert this into a guarded parse that raises a clear ValueError, and read the controller using an explicit UTF-8 encoding.
def _asset_relationships(path: Path) -> set[str]:
    source = path.read_text()
    index_action = source.split("def index", maxsplit=1)[1].split("def show", maxsplit=1)[0]
    serializer_call = index_action.split("serializer_options", maxsplit=1)[1]
    match = re.search(r"%i\[([^]]+)]", serializer_call, flags=re.DOTALL)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/corva_api_client/resources/assets.py Outdated
Comment thread scripts/check_asset_fields.py Outdated
@bryansray
bryansray merged commit 2684e2e into main Aug 28, 2026
2 checks passed
@bryansray
bryansray deleted the feat/discoverable-asset-fields branch August 28, 2026 17:40
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.

2 participants