Skip to content

refactor(docx): move the DOCX export entry point and edit conflicts into lib/services/docx - #896

Merged
CarlosBonetti merged 1 commit into
devfrom
tower/zequinha-26
Oct 16, 2026
Merged

CarlosBonetti merged 1 commit into
devfrom
tower/zequinha-26

Conversation

@CarlosBonetti

Copy link
Copy Markdown
Collaborator

Summary

This moves two DOCX-export modules from the flat lib/services/ folder into lib/services/docx/, where the rest of the export code lives. It is a pure move: both files are 100% renames, and only import lines change. Behaviour is unchanged.

lib/services/docx_workflow_service.py  ->  lib/services/docx/service.py
lib/services/edit_conflicts.py         ->  lib/services/docx/edit_conflicts.py

Motivation

This is a code-health structure pass on lib/services/, which holds about 40 flat modules next to a handful of domain subpackages. Both files belong to docx/ but sat outside it:

  • docx_workflow_service.py changed together with docx/ in 10 of its 13 commits since March.
  • edit_conflicts.py changed together with docx/ in all 6 of its commits. Outside the tests, only docx/edit_export.py and docx/tracked_changes_planning.py import it.

The entry point is now service.py, the name admin_dashboard/, annotations/ and preflight/ already use.

Target layout. Each domain becomes a subpackage of lib/services/ with its entry point in service.py. Flat modules stay only for small helpers that several domains share (text_location, markdown_text, …). The move is one cluster per change. Candidates for later:

  1. The workflow_* modules could become lib/services/workflow_runs/. They are about 2,000 lines with about 56 reference sites, and show weaker co-change evidence.
  2. file.py (the FileDocument model) sits next to files.py (the file service). It belongs with file_finalization, file_images and file_artifacts_service/ in a files/ package.
  3. lib/api/services/workflow_runner.py is a lone file in a third "services" location.

Layering issues noticed and left alone:

  • 24 service modules import from lib.workflows, for example docx/edit_conflicts.py → simple_deep_agent/edit_anchoring.normalize_whitespace.
  • docx/service.py imports the private projects._get_project_by_id.

What's Changed

Backend

  • lib/services/docx_workflow_service.py → lib/services/docx/service.py: moved, contents unchanged.
  • lib/services/edit_conflicts.py → lib/services/docx/edit_conflicts.py: moved, contents unchanged.
  • lib/api/routers/projects.py and lib/api/mcp/tools/files.py: import generate_docx and DocxManipulatorType from the new path.
  • lib/services/docx/edit_export.py and lib/services/docx/tracked_changes_planning.py: import from lib.services.docx.edit_conflicts. Ruff re-sorted the import blocks.
  • tests/unit/services/test_docx_generation.py: new import path, and the _SERVICE patch-target string updated.
  • tests/unit/services/test_edit_conflicts.py and tests/unit/services/tracked_changes_support.py: new import path.

The tests stay flat in tests/unit/services/, alongside the other DOCX tests.

Frontend

None.

Risks and Mitigations

  • A missed reference to the old module paths, such as a string patch target or a dynamic import. A grep over code, docs, CI, k8s, evals and the frontend finds none, and an independent reviewer repeated the search with the same result. Importing the full app (import lib.api.main) succeeds, which covers both runtime callers.
  • The logger name changes to lib.services.docx.service. Nothing filters on the old name.
  • Checks: ruff format, ruff check, mypy . (0 errors) and pytest tests/unit (2383 passed). No integration test imports either module.

🤖 Generated with Claude Code

https://claude.ai/code/session_01T9eqHq49ncKxbGg8kneoQm

…nto lib/services/docx

docx_workflow_service.py and edit_conflicts.py sat beside lib/services/docx/
but change with it: since March, 10 of docx_workflow_service's 13 commits
and all 6 of edit_conflicts' commits also touched docx/, and only docx/
imports edit_conflicts. Move them in, naming the entry point service.py
as admin_dashboard/, annotations/ and preflight/ do, and update every
import and patch target. No behaviour change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T9eqHq49ncKxbGg8kneoQm
Copilot AI balanced review requested due to automatic review settings October 16, 2026 21:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T21:37:29.469029Z 0e212ad PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The behavior-preserving relocation consistently updates callers and test patch targets, with no unresolved findings.

No open issues 🎉

What changed in this PR

Consolidates DOCX export code under lib/services/docx/ without changing behavior.

Changes:

  • Moves the export entry point and edit-conflict resolver into the DOCX package.
  • Updates runtime imports, test imports, and mock patch targets.
File Description
tests/​unit/​services/​tracked_changes_support.py Updates conflict-resolver import.
tests/​unit/​services/​test_edit_conflicts.py Updates imports for the moved module.
tests/​unit/​services/​test_docx_generation.py Updates imports and mock patch targets.
lib/​services/​docx/​tracked_changes_planning.py Uses the relocated conflict resolver.
lib/​services/​docx/​service.py Relocates the unchanged export entry point.
lib/​services/​docx/​edit_export.py Uses the relocated conflict resolver.
lib/​services/​docx/​edit_conflicts.py Relocates unchanged conflict-resolution logic.
lib/​api/​routers/​projects.py Updates the export-service import.
lib/​api/​mcp/​tools/​files.py Updates the export-service import.

Review effort: Balanced

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.82%. Comparing base (d81d8d9) to head (0e212ad).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #896   +/-   ##
=======================================
  Coverage   88.82%   88.82%           
=======================================
  Files         542      542           
  Lines       34702    34702           
  Branches     2069     2069           
=======================================
  Hits        30825    30825           
  Misses       3618     3618           
  Partials      259      259           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants