Skip to content

refactor(events): split services/events.py into a package - #371

Merged
vidit-admin merged 16 commits into
mainfrom
claude/event-split-pr-review-acb5b8
Oct 3, 2026
Merged

vidit-admin merged 16 commits into
mainfrom
claude/event-split-pr-review-acb5b8

Conversation

@vidit-admin

@vidit-admin vidit-admin commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

What

Splits backend/app/services/events.py (1,700 lines) into a services/events/ package. Pure move: every top-level definition keeps its exact text. The package root re-exports the public API, so from app.services import events call sites stay unchanged.

Module Contents
__init__.py module map, re-exports, __all__
errors.py EventError hierarchy
coordinates.py validate_coordinates, _optional_point
source_links.py secondary source link helpers
rules.py evidence floor, proof sanitizing, source swap, tag and conflict resolvers, geolocator credit
readiness.py DETECTION_READINESS, detection_ready_predicate
create.py, request.py, geolocation.py, revision.py, batch.py, closure.py the write verbs

Imports run one way: a verb module imports shared modules, a shared module imports at most errors, and no verb imports another.

Notes

  • _publish_detection stays private to batch.py. Every citation (route docstring, lib/events.ts, its test, docs/design.md, planning/next.md, the readiness test) names it as services/events/batch._publish_detection, and api-types.ts is regenerated from the updated route docstring.
  • The batch logger name becomes app.services.events.batch (still under the configured app logger).
  • Two tests updated: a patch target in test_requests.py, a private import in test_detections_readiness.py.
  • AGENTS.md, docs/engineering.md, planning/next.md, and a few comments re-pointed at the new modules. The maintainer decided to drop the planning/next.md row "Map services/ before moving anything in it", because the package docstring and docs/engineering.md now map events/.

Supersedes #317.

Verifying the move

An AST comparison of every top-level definition against origin/main:backend/app/services/events.py found them identical. git diff -M --color-moved=dimmed-zebra origin/main...HEAD shows the moved blocks.

Checks

Backend suite 1691 passed, 3 skipped. ruff, mypy, vulture, make hygiene clean. make gen-api-types leaves no diff.

🤖 Generated with Claude Code

vidit-admin and others added 14 commits October 4, 2026 00:28
Move the module to services/events/__init__.py unchanged, so git records
the rename and later commits extract one concern at a time.

Signed-off-by: vidit-admin <admin@vidit.app>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the EventError hierarchy verbatim into a leaf module and declare the
package's public surface in __all__, so every caller's import is unchanged.

Signed-off-by: vidit-admin <admin@vidit.app>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es.py

Move validate_coordinates and _optional_point verbatim. The package
re-exports validate_coordinates, so services/events.validate_coordinates
still names the bounds check.

Signed-off-by: vidit-admin <admin@vidit.app>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ce_links.py

Move the normalize, truncate, pair and row-building helpers verbatim.

Signed-off-by: vidit-admin <admin@vidit.app>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the evidence floor checks, the proof sanitiser wrapper, the source
swap, the tag and conflict resolvers and the geolocation credit verbatim.

Signed-off-by: vidit-admin <admin@vidit.app>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nts/readiness.py

Move DETECTION_READINESS, the proof-image jsonpath and
detection_ready_predicate verbatim, with the comment blocks above them.

Signed-off-by: vidit-admin <admin@vidit.app>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move create_with_evidence verbatim.

Signed-off-by: vidit-admin <admin@vidit.app>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move ImportProvenance, stamp_provenance, create_request and update_request
verbatim. The request-edit sweep test patches sweep_keys where
update_request now looks it up, app.services.events.request.

Signed-off-by: vidit-admin <admin@vidit.app>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ation.py

Move geolocate verbatim. The module is named geolocation so the package
attribute geolocate stays the function rather than a submodule.

Signed-off-by: vidit-admin <admin@vidit.app>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vision.py

Move save_version verbatim.

Signed-off-by: vidit-admin <admin@vidit.app>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move ROW_INTERNAL_ERROR_CODE, DetectionCompletion, _assert_owns_all,
_publish_detection and complete_detections verbatim. The readiness test
imports _publish_detection from its new module.

Signed-off-by: vidit-admin <admin@vidit.app>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ckage

Move close verbatim. __init__.py now holds only the package docstring,
which maps the modules, and the re-exports. _publish_detection is
re-exported under its own name because a route docstring that flows into
the generated api-types cites services.events._publish_detection.

Signed-off-by: vidit-admin <admin@vidit.app>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
engineering.md lists the package's modules in the repository layout.
References to a symbol that no longer resolves at its old path point at its
current module: AGENTS.md (the batch floor is
services/events/batch._publish_detection), routers/tags.py,
sanitize.py, lib/coordinates.ts and two planning/next.md links. Citations
of re-exported names (services/events.validate_coordinates,
services/events.geolocate, ...) still resolve and stay as they are.

Signed-off-by: vidit-admin <admin@vidit.app>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: vidit-admin <admin@vidit.app>
vidit-admin and others added 2 commits October 4, 2026 00:55
Drop the private re-export of _publish_detection from the package root and
cite it as services/events/batch._publish_detection in the route docstring,
the readiness test, and the frontend mirror. Regenerate api-types.ts from the
updated docstring. Fix the shared-module count and the dependency direction in
the package docstring, and name the module ImportProvenance lives in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: vidit-admin <admin@vidit.app>
Indent the events/ children under their parent in docs/engineering.md, cite
services/events/batch._publish_detection in docs/design.md and the
planning/next.md batch-complete row, and link #371 in the changelog entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: vidit-admin <admin@vidit.app>
@vidit-admin
vidit-admin merged commit 14f06a3 into main Oct 3, 2026
11 of 12 checks passed
@vidit-admin
vidit-admin deleted the claude/event-split-pr-review-acb5b8 branch October 3, 2026 22:59
vidit-admin added a commit that referenced this pull request Oct 3, 2026
The union merge strategy on planning/next.md reinserted the pre-split rows
when main (#371) edited them. Restore the short next.md and apply #371's
planning edits to backlog.md instead: the services/events package links and
the dropped services map row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: vidit-admin <admin@vidit.app>
vidit-admin added a commit that referenced this pull request Oct 4, 2026
* chore(planning): prune next.md of shipped, stale and duplicate rows

Remove 38 rows from planning/next.md: 14 already shipped, 13 superseded or
no longer accurate, and 11 older split rows that a merged row already covers.
Move the Requests board triage row from P1 to P2.

Fix docs/engineering.md: the client-IP helper it cited no longer exists; the
rate limiter reaches the right-most XFF entry through rate_limit_key, and the
auth-events audit log stores no IP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: vidit-admin <admin@vidit.app>

* chore(planning): split next.md into a short next.md and a full backlog.md

next.md had grown to 145 rows and about 100 KB, too long to plan from.

- planning/backlog.md holds all 145 rows with their original text, under
  the same version, Refactors and Unscheduled candidates sections, plus
  the cross-cutting rules. The empty v0.6.4 section is dropped.
- planning/next.md keeps the v0.6 rows and the v0.7 P0 and P1 rows (14
  rows), each reduced to a one-sentence outcome that links to its full
  row in backlog.md.
- CONTRIBUTING.md states the row rule and extends the shipped and
  descoped steps to backlog.md; AGENTS.md lists backlog.md.
- References that pointed at moved content (roadmap work breakdowns,
  README, issue and PR templates, CI comments, .gitattributes union
  merge, engineering.md tree, code comments) now point at backlog.md.
- One stale link in a backlog row (OverflowMenu.tsx, removed in #293)
  is unlinked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: vidit-admin <admin@vidit.app>

* chore(planning): restore the short next.md after the main merge

The union merge strategy on planning/next.md reinserted the pre-split rows
when main (#371) edited them. Restore the short next.md and apply #371's
planning edits to backlog.md instead: the services/events package links and
the dropped services map row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: vidit-admin <admin@vidit.app>

* chore(planning): move the work tracker to the GitHub Project

The work tracker now lives in the GitHub Project (vidithq/projects/1):
issues in vidithq/vidit with a native type (Feature, Debt, Task, Bug)
and the Status, Priority, Version and Area fields. planning/next.md and
planning/backlog.md are deleted; git history keeps them.

Pointers updated:
- AGENTS.md: the tracker row names the Project, the backlog row is gone,
  doc rules 2 and 3 point tracker content and hedge prose at the Project.
- CONTRIBUTING.md: new work is an issue with type, Priority, Version and
  Area; a shipping PR says Closes #N; the row-writing rules are gone.
- README.md, planning/roadmap.md (work breakdown links filter the
  Backlog view by version), the PR and feature-request templates,
  docs/engineering.md repo tree, .gitattributes (CHANGELOG union merge
  only).
- docs/backups.md, docs/engineering.md, docs/ingestion.md and code
  comments link the matching issue (#396, #429, #475, #476, #505, #515).

docs-pairing: the job now requires a docs/ touch only (planning/ holds
only roadmap.md). Exemptions are unchanged; the check is renamed
"PR touches docs/" (not a required status check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: vidit-admin <admin@vidit.app>

---------

Signed-off-by: vidit-admin <admin@vidit.app>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant