Repository navigation
refactor(events): split services/events.py into a package - #317
Closed
vidit-admin wants to merge 8 commits into
Closed
vidit-admin wants to merge 8 commits into
vidit-admin wants to merge 8 commits into
Conversation
The merge pass that fused related rows in the Refactors and Unscheduled tables added the fused rows without deleting the originals. One topic now has one row, kept at the position of the earliest duplicate. Same cleanup in the v0.6 table (re-home attribution, clickable handles, the fulfilled request notification row subsumed by the notifications feed row). Corrections carried while merging: analyst-helper@vidit.app does not exist under video/, ArchiveSourceField is really ArchiveSnapshotField, and three facts the docs fusion had dropped are restored. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Pure move, no code change: the module becomes services/events/__init__.py so the write verbs and the shared rules can be split into submodules behind the same import surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Three leaf modules out of the package root, code moved verbatim: the typed failures, the coordinate bounds check plus the optional point, and the secondary source link normalization. The package root re-exports them, so every caller keeps importing from app.services.events. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
rules.py takes the evidence floor helpers, the proof sanitiser wrapper, the source-media swap, the tag / conflict resolvers, the geolocation credit and the SQL readiness predicate, moved verbatim out of the package root. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
close.py holds the terminal withdraw / reject / retract, batch.py the per-row detection completion and its module logger. The readiness test takes the private _publish_detection from its new home and keeps the public predicate from the package root. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The last three write verbs leave the package root, which is now the package docstring, a module map, the re-exports and __all__. save_version lands in revise.py, since services/versions.py already holds that name. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AGENTS.md names the batch floor as services/events/batch._publish_detection, design.md points the readiness mirror at batch.py and rules.py, engineering.md states the package shape under the layering section, and next.md records the split plus the two rows that linked the old file. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The batch floor is named services/events/batch._publish_detection at each of its five mirrors (the detections router docstring and the api-types it generates, lib/events.ts, lib/events.test.ts, the readiness suite, and the next.md removal row), the tag floor points at services/events/rules.py and the coordinate bounds at services/events/coordinates.py. The package docstring counts four shared modules, and the changelog records the split. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Member
Author
|
Superseded by #371, rebuilt against the current events.py. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Splits `backend/app/services/events.py` (1,493 lines, the largest service module) into a `services/events/` package: one module per write verb plus shared rule modules, with the public API re-exported from the package root so every existing `from app.services import events` import stays unchanged.
How
Pure move: the first commit is a `git mv` so git records a rename, then one extraction per commit with the events test suite green at each step. Code moved verbatim; only import headers, module docstrings, and the `init` re-exports are new text. Dependency direction is one-way (`errors` → shared rules → verbs), no circular imports.
One external import changed: `tests/events/test_detections_readiness.py` reaches the private `_publish_detection` from `app.services.events.batch` directly.
Also in this PR
Checks
Full backend suite 1,420 passed, 3 skipped. `ruff`, `mypy`, `vulture`, jscpd (0.21%) all clean. `services/events.validate_coordinates` and the generated route docstring in `api-types.ts` stay true via re-export, so the api-types drift gate is untouched.
🤖 Generated with Claude Code