Repository navigation
Conversation
|
The Main CI Pipeline for the current head Could a maintainer approve the pending fork workflows so the implementation and regression tests can receive CI validation? Prepared with AI coding assistance. |
There was a problem hiding this comment.
1 inline suggestion at 4ed3518c1c, from a rule learned from earlier reviews in this repository. Reply on the comment if it is wrong.
dify-codereview
| class CreationStore: | ||
| """In-memory implementation of the creation path's persistence capability.""" | ||
|
|
||
| rows: dict[SegmentRef, Mapping[str, object]] = field(default_factory=dict) |
There was a problem hiding this comment.
Parse, don't validate (https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/): model this data once at the boundary as a pydantic model / dataclass / TypedDict (Model.model_validate(raw)), and pass the typed value on, instead of passing dicts around and re-checking keys and types where they are used. In a test, don't build this as an ad hoc dict[str, object]: define the shape (TypedDict / model) in the production code and import it here.
dify-codereview · parse-dont-validate Learned from an earlier review. Reply here if this is wrong.
Refs #39022 (the single-request versus Service API batch creation case).
Single segment creation and
SegmentService.multi_create_segmentcurrently use different per-document Redis keys. A single creation can therefore reach its persistence port while the batch creation lease for that document is held. Both paths allocate the next position and update the document's word count.Make single creation use the existing batch lease name. This keeps the Service API batch path's key unchanged and serializes these two creation paths for the same document. Creation for another document stays independent.
Validation:
DID NOT RAISE DocumentBusyErrorwhile the batch lease was held).test_application.py: 25 passed. Tests execute the actual application service with in-memory persistence/index ports and standard-library mutual exclusion; they cover contention, different documents, and release after a failed write.Test command (Python 3.13.7, isolated dependency environment):
This does not cover CSV imports or old single-request workers during a rolling deployment. The existing 600-second lease and batch indexing scope are unchanged. Real Redis/SQL concurrent integration tests and the complete backend suite were not run locally.
AI assistance was used for investigation, implementation, and review.
Checklist
make lint && make type-checkcommands (scoped checks were run instead).