refactor(webapistore): resolve base service names from BaseModel meta#189
Conversation
- Resolve IsBaseService names from abstract BaseModel by path instead of a hardcoded map. - Fail generation when BaseModel meta is missing or has no conventional services. - Document that the FE base surface remains the hand-written WebModelStore service section. Co-authored-by: Cursor <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughWebApiStore generation now resolves conventional BaseModel services from persisted metadata instead of a hardcoded list. Tests seed BaseModel metadata and cover filtering, missing records, empty conventional services, invalid model state, and non-conventional-only services. ChangesBaseModel service resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Generator
participant Resolver
participant Metadata
participant WebModelStore
Generator->>Resolver: Resolve BaseModel service names
Resolver->>Metadata: Load abstract BaseModel and Services
Metadata-->>Resolver: Return service metadata
Resolver-->>Generator: Return conventional service map
Generator->>WebModelStore: Apply base-service filtering
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/module/artifact/generate/webapistore.go`:
- Around line 385-387: Move the resolveBaseServiceNames call in the web API
generation flow before the zero-model early-return guard, so BaseModel metadata
is validated even for empty applications. Preserve successful behavior for valid
empty apps and propagate metadata resolution errors; add a regression test
covering an empty application with invalid BaseModel metadata.
- Around line 344-351: Update the IrModel lookup query in the model-loading flow
to add an abstract = true predicate alongside the existing path conditions,
ensuring Take(&model) selects the abstract base model before preloading
Services. Preserve the existing path matching and ordering behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ba0380e7-9fe8-4a5f-a953-05b9c50b1766
📒 Files selected for processing (4)
internal/module/artifact/generate/generator_test.gointernal/module/artifact/generate/webapistore.gointernal/module/artifact/generate/webapistore_test.gomodules/web/web/stores/modelStore.ts
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…ames - Constrain the BaseModel path lookup with abstract=true so a concrete model at the same path cannot supply IsBaseService names. - Add a regression test covering a non-abstract model at the BaseModel path. Co-authored-by: Cursor <cursoragent@cursor.com>
|
/improve |
PR Code Suggestions ✨Latest suggestions up to 0a98bbf
Previous suggestionsSuggestions up to commit d153735
|
- Extract path/services helpers so empty path, nil services, and non-NotFound load errors are unit-testable. - Add nil-context generate coverage for the resolve wiring path. Co-authored-by: Cursor <cursoragent@cursor.com>
User description
Summary
baseServiceNamesmap inwebapistore.gowithresolveBaseServiceNames, which loads conventional service names from the abstractBaseModelIrModel byBaseModelModuleSpecpath.WebModelStoreservice section; add a contract comment so new BaseModel RPCs are declared there (not in a Go name list).Test plan
go test ./internal/module/artifact/generate/ -count=1XxxStoreinterface omits Search/NameSearch/Copy while still binding them at runtimeMade with Cursor
PR Type
Enhancement, Tests, Documentation
Description
Go core: dynamically resolve base service names from abstract
BaseModelmetadata instead of hardcoded map.Go core: fail store generation when
BaseModelmetadata is missing or contains no conventional services.Go core: add Go unit tests covering base service interface filtering and error cases.
TS modules: add contract comment in
modules/web/web/stores/modelStore.tsfor declaring new base RPCs.File Walkthrough
generator_test.go
add abstract BaseModel test helper for generator testsinternal/module/artifact/generate/generator_test.go
seedAbstractBaseModelhelper function to seed abstractBaseModeland its services in test DB.
BaseModel.webapistore_test.go
add unit tests for BaseModel service name resolution and filteringinternal/module/artifact/generate/webapistore_test.go
BaseModelacross existing web API store generator tests.PartnerStoreinterface.BaseModeland non-conventional/emptyservice lists.
webapistore.go
resolve base service names dynamically from BaseModel metainternal/module/artifact/generate/webapistore.go
baseServiceNamesmap withresolveBaseServiceNames.BaseModelby module path spec and collect conventional modelservices.
BaseModelis missing or has no conventionalservices.
modelStore.ts
document WebModelStore RPC contract for BaseModel servicesmodules/web/web/stores/modelStore.ts
based on
BaseModelmeta.WebModelStore.Summary by CodeRabbit