Enhance API docs, refactor models, and remove deprecated scripts#660
Conversation
- Introduced typed arms for Create, Update, and Delete requests in Information Block API models to enhance validation and clarity. - Implemented a `_coerce_payload` function to streamline payload validation against request models, ensuring typed payloads are returned as-is while untyped payloads are validated at dispatch time. - Updated tests to validate the new discriminated union structure, ensuring unknown block types are rejected at construction, providing clearer error messages. - Enhanced OpenAPI schema examples for Create and Update requests to improve developer experience. - Adjusted operations in the roboledger and roboinvestor routers to reflect the new response types for information block operations.
…d descriptions and examples
…ponse Structures - Added detailed docstrings to various API models including FiscalPeriodSummary, PeriodCloseItemResponse, LedgerSummaryResponse, and others to improve clarity on their purpose and usage. - Updated request and response models in journal entries, taxonomies, transactions, and trial balance to include descriptions for fields, enhancing the API documentation. - Introduced examples in model configurations for better understanding of expected input and output formats. - Refactored agent-related operations to use LedgerAgentResponse for consistency across the API. - Implemented a new helper function to auto-fill GraphQL type descriptions from Pydantic model docstrings, improving the integration between Pydantic and Strawberry GraphQL. - Adjusted error messages in operation handlers to provide clearer guidance on available actions and workarounds.
…nsition from automated seed generation to manual curation. Deleted `import_upstream_seeds.py`, `load_fac_taxonomy.py`, and `sec_extractor_benchmark.py` scripts. Updated `__init__.py` and `README.md` to clarify that seeds are now curated by hand and no longer regenerated from scripts.
…ct properties; update robosystems-client version to 0.3.22
|
@claude please review this PR |
|
Claude finished @jfrench9's task in 2m 40s —— View job PR Review: Enhance API docs, refactor models, and remove deprecated scriptsTasks:
This is a large, well-structured PR. The core themes — typed OpenAPI envelopes, discriminated-union request models, and Pydantic-docstring auto-propagation to GraphQL — are all directionally correct. A few items below warrant attention before merging. Strengths
Discriminated-union information block requests: Refactoring Drift tests (
Docstring coverage: The field-level Issues1. # robosystems/models/api/extensions/investor.py:7
__all__ = ["DeleteResult"] # re-exported for back-compat with existing imports
# At the bottom of investor.py, after DeleteResult is imported:
DeleteResult = DeleteResult # re-exported for back-compatOr simply remove 2. After the refactor, fails = summary.get("fail", 0) + summary.get("error", 0)
3.
4. The docstring correctly states "always 5. The promotion checklist in # To promote a value to its own typed arm:
# (1) add a `_Create<Block>Arm` ...
# (2) drop the value from `_LEGACY_BLOCK_TYPES`,
# (3) add the new arm to `_CreateInformationBlockArms`.
# The `test_create_arm_union_covers_registry` drift test enforces that
# every registry entry remains covered.The drift test catches step (3) being missed. It does not catch step (2) being missed — i.e., a new arm added but the literal not removed from Minor Observations
SummaryApprove with the |
…verlap with typed arms
| from robosystems.models.api.common import ( # noqa: F401 DeleteResult re-exported | ||
| DeleteResult, | ||
| PaginationInfo, | ||
| ) |
…or clarity; adjust validation and service source fields to align with demo pedagogy
…ry extraction in _Validator class
…n errors across API endpoints
|
@claude can you review the changes since the last review |
|
Claude finished @jfrench9's task in 3m 12s —— View job Review: Changes Since Last Review6 commits added after the initial review (2026-05-07 ~15:16 CDT):
Fixes from the Previous ReviewIssue #1 ( Nit #5 (no test for Issue #2 ( Issues1.
def _typed_arm_block_types(self, union_alias) -> set[str]:
legacy_values = set(get_args(_LEGACY_BLOCK_TYPES))
return _arm_block_types(union_alias) - legacy_values # ← subtracts legacy first
def test_create_arms_disjoint_from_legacy(self) -> None:
legacy = set(get_args(_LEGACY_BLOCK_TYPES))
typed = self._typed_arm_block_types(...) # already has legacy subtracted out
overlap = legacy & typed # ← can never be non-empty
assert not overlap # always True
The test needs to identify typed-arm literals independently of def _typed_arm_block_types(self, union_alias) -> set[str]:
"""Block types from arms whose discriminator is NOT _LEGACY_BLOCK_TYPES."""
from typing import Annotated, Literal, Union, get_args
from robosystems.models.api.information_block import _LEGACY_BLOCK_TYPES
typed = set()
for arm in get_args(get_args(union_alias)[0]): # unwrap RootModel[Annotated[Union[...]]]
for field in arm.model_fields.values():
annotation = field.annotation
if annotation is _LEGACY_BLOCK_TYPES:
continue # skip the catch-all legacy arm
if hasattr(annotation, "__args__"):
typed.update(a for a in get_args(annotation) if isinstance(a, str))
return typed(Exact introspection depends on how 2.
# 4xx HTTPException pass-through — ...
@app.exception_handler(StarletteHTTPException)
async def http_exception_handler(...):
Strengths
Dynamic period computation in
SummaryApprove pending the |
…tity across tests
Summary
This PR delivers a broad set of improvements focused on API model documentation, codebase cleanup, and structural refinements across the platform. It enhances the developer experience by adding comprehensive docstrings, examples, and descriptions to API models, removes deprecated seed generation scripts in favor of manual curation, and refactors several core components for consistency.
Key Accomplishments
📖 API Model Documentation & Enhancement
DeleteResultmodel inmodels/api/common.pyfor consistent delete response handling across endpoints🧹 Deprecated Script Removal
build_fac_calculations_seed,build_fac_presentation_seed,build_rs_gaap_seed,curate_fac_axes,import_upstream_seeds,load_fac_taxonomy,sec_extractor_benchmark)__init__.pyand seedsREADME.mdto document the transition from automated seed generation to manual curation🔧 Refactoring & Dependency Updates
_pydantic.pyutility module for GraphQL type helpersmain.py,validate.py) to use dot notation for object property access instead of dictionary-style accessrobosystems-clientfrom main dependencies (moved or no longer needed)Breaking Changes
robosystems-clienthas been removed from main project dependencies; downstream consumers relying on it as a transitive dependency should add it explicitlyTesting Notes
conftest.pyto align with model changesInfrastructure Considerations
uv.lock) has been updated to reflect dependency changes; environments should be refreshed accordinglyDeleteResultmodel should be adopted by any future delete endpoints for consistency🤖 Generated with Claude Code
Branch Info:
feature/ops-docsmainCo-Authored-By: Claude noreply@anthropic.com