Repository navigation
refactor: 审计阶段 0、1——护栏转绿与低风险清理 - #2
Open
SolarCrown57 wants to merge 14 commits into
Open
SolarCrown57 wants to merge 14 commits into
SolarCrown57 wants to merge 14 commits into
Conversation
基于 7f7f047(与 desktop-vnext-dev 一致)的只读审计,结论:整体不是屎山, 技术债集中在桌面主窗口上帝类、流水线参数透传、边界规则链、Web 上帝模块、 绕过护栏的改名复制,以及当前未通过的架构快照、私有 patch 上限与发布扫描。 报告给出证据、严重度、建议与分阶段重构顺序,未修改业务代码。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- test_discard_unsaved_edit_reopens_from_formally_saved_subtitle: 构造第二个窗口时用 patch.object 替换 DesktopWindow 类属性 _start_waveform, 在已有窗口存活时会让 PySide 在 _appbar 设置图标处 access violation,用例稳定崩溃; 且该 patch 只在构造期间生效,拦不到异步载入后才发生的调用。 改为构造后在实例上替换,并由 addCleanup 覆盖整个用例。 - test_explicit_seek_ignores_stale_player_position_and_playing_highlight: FakePlayer 缺少 close(),收尾关窗时 closeEvent 调用 player.close() 抛出 AttributeError, 后续 Qt 事件再进入 Python 重写时处于异常状态;补一个空的 close()。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 00d177c)
Bring the test private-patch count back to the 17 allowed by the architecture contract: - SubtitlePreviewService accepts an injectable probe_video, so the canvas test no longer patches subtitle_preview._probe_video_info. - The reopened-window test stubs waveform_cache.load_or_generate instead of the private DesktopWindow._start_waveform. - The bottom-click seek test asserts player and timeline results with a fake player instead of patching DesktopWindow._seek_to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two owner tests pinned the repository-wide top-level function count to a hand-written 1059, which already disagreed with the generated baseline (1060) and broke whenever unrelated modules gained a function. Compare with architecture_baseline.json instead: growth still has to go through a reviewed snapshot regeneration, which the CI step `architecture_snapshot.py --check` enforces, without hard-coding a volatile number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
projects.py hard-coded the maintainer's local submission folder as the fallback and re-parsed AUTOSLICE_SUBMISSION_DIR on its own. That left two defaults for one setting (the web workbench falls back to the repository `submissions` folder), showed "目录不存在" on any other machine and made scripts/scan_public_release.py fail. configured_submission_root() now delegates to runtime_config.configured_path(), the existing owner of this setting, so the precedence stays environment > autoslice.local.json > repository default, still resolved at call time. Machines that configure the folder in autoslice.local.json keep the same behaviour. Desktop docs describe the configured folder instead of a literal local path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- _split_subtitle_text_for_ass and _subtitle_display_text_size were line-for-line copies of transcription.segments.split_subtitle_text_for_display and subtitle_text_size under different names, so the duplicate-definition guard could not see them. The ASS wrapper now calls the segment owner. - save_corrected_srt and load_subtitle_edit_state built the same five structure fields (deleted, merge pairs/overrides, time overrides, split groups) independently; both now use _edit_structure_payload, keeping key order so written state files are byte-for-byte unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
autoslice.web.app and autoslice_cover.app each carried an identical after_request hook that issues the local session cookie and redacts LAN responses. Security behaviour duplicated across two apps can silently drift, so move it into SecurityPolicy.finalize_flask_response, next to the existing duck-typed authorize_flask_request helpers. Both hooks now delegate with their own bootstrap paths and JSON encoder; behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Delete functions that nothing in src/, tests/, scripts/, templates or JS references: subtitle_workflow._split_subtitle_cues, autoslice_cover.app._render_task, CueSelection.retain and runtime_config.template_defaults. SubtitleTimeline.follow_playback is also unused but is left in place because desktop-ui-opus55v2 edits it; it can go when that branch lands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- analysis/topic/analysis.py: skip malformed LLM timecodes on ValueError and IndexError only, instead of hiding every exception. - analysis/manual/timebase.py: the zip fallback for .docx timelines only swallows OSError, KeyError and BadZipFile; the outer python-docx fallback stays as designed. - llm/transport.py: bind active_prompt/active_tokens explicitly in the retry closure (B023), so a future deferred call cannot see a later loop iteration's values. - analysis/topic/normalization.py: drop duplicate items from set literals (B033); the sets' contents are unchanged. The project has no logging setup, so these keep their current silent fallbacks rather than introducing new log output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/架构重构.md requires production consumers to depend on the real owner rather than compatibility modules. web/app.py (7 call sites) and launcher.py still imported ensure_srt, funasr_public_status, optimize_manual_timeline_for_video, retry_clip_review_from_artifacts, run_pipeline, slice_from_marks and subtitle_title_services through autoslice.topic_engine. They now import from autoslice.pipeline, autoslice.slicing, autoslice.transcription.workflow and autoslice.transcription.model_runtime. Tests that drive the web tasks patch those owners instead of the facade. core.py stays a compatibility forwarder, so its tests (including the core.generate_srt case in test_app.py) keep patching topic_engine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The topic_v2 page carried a 1,061-line inline script that no CI step syntax-checked. Move it to static/topic_v2.js, following the existing subtitle_workflow.js layout: - Default directories are injected through a JSON data block instead of Jinja expressions inside the script; LAN mode still renders them empty. - The 15 inline on* attributes become addEventListener bindings, bound right after restoreWorkspacePaths() so the Node behaviour tests keep executing only the definitions. - Page tests fetch the script through the Flask static route. - CI runs node --check on topic_v2.js and subtitle_workflow.js, and the packaging smoke checks list the new resource. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The baseline on desktop-vnext-dev already lagged the code (199 modules recorded, 204 present), so architecture_snapshot.py --check failed before this branch. Regenerate it after the audit stage 0/1 changes; the private patch total stays at 17. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
These tests came with desktop-vnext-dev and never ran in CI, because the architecture snapshot check failed first. Once it passed, the Windows job exposed them: - The launcher media-tool test and the subtitle render service test compared resolved long paths with the runner's 8.3 short temp path (RUNNER~1). Resolve the temp root before building expectations. - The draft baseline test rewrites the source with content of the same byte size (42 bytes). On the runner both writes landed in one mtime tick, so the size + mtime signature did not change and the draft read back as ready. Push the mtime forward explicitly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
概要
按审计报告
docs/refactor/AUDIT.md完成阶段 0(让护栏变绿)和阶段 1(低风险清理)。不改变业务行为,每个提交只处理一项,可以单独审阅或回退。报告末尾的 §8 是逐项处理记录。提交
01706c9docs(refactor)0e98942test(desktop)f2acb63test(desktop)SubtitlePreviewService接受可选probe_video;测试改为替换waveform_cache.load_or_generate,或者用 FakePlayer 断言跳转结果。私有 patch 回到上限 17172d818test(architecture)1059015fcf7fix(desktop)runtime_config解析投稿目录,删除写死的本机路径;6 份 desktop-vnext 文档同步。发布扫描恢复通过7e171ccrefactor(subtitles)transcription.segments的唯一实现;校对状态的结构字段由_edit_structure_payload统一生成;删除未使用的_split_subtitle_cues7ca99c9refactor(security)SecurityPolicy.finalize_flask_responsead54613chore_render_task、CueSelection.retain、template_defaultsa0afcd5fixf327be1refactor(web)topic_engine;测试的 patch 目标同步修改。兼容层本身和core兼容测试保持不变8ed7860refactor(web)static/topic_v2.js;默认目录经 JSON 数据块注入(LAN 模式下仍为空);15 个on*属性改为addEventListener;CI 对topic_v2.js和subtitle_workflow.js跑node --check;打包冒烟清单加入新文件dbb899cchore(architecture)b0f16c5docs(refactor)75ee9e6testRUNNER~1)和 resolve 后的长路径比较;1 条“外部修改”写入的内容与原文同为 42 字节,两次写入落在同一个 mtime 刻度内,大小加 mtime 的指纹没变。都在测试侧修复需要维护者留意
AUTOSLICE_SUBMISSION_DIR。如果本机的autoslice.local.json已经为 Web 字幕工作台配置了这个键,桌面端行为不变;否则请加上:{ "AUTOSLICE_SUBMISSION_DIR": "<本机投稿目录>" }未包含
DesktopWindow、M6 迁出预览包):会大面积改动window.py,需要先和desktop-ui-opus55v2约定合并顺序。follow_playback:暂时保留,避免和 UI 分支冲突。logging,只收窄了异常类型,没有加日志。验证
python -B scripts/run_hermetic_tests.py:共 1575 条,失败 5 条,跳过 5 条(本地 Windows、Python 3.12)。其中 4 条test_migrated_source_and_ast_hashes_are_exact只在 3.12 下失败(ast.dump多了type_params字段),用 CI 的 Python 3.10 复跑通过;另 1 条test_playhead_full_height_blank_scrub_and_cue_priority在 dev 的7f7f047上就已失败,和本 PR 无关。scripts/architecture_snapshot.py --check、scripts/validate_public_docs.py、scripts/scan_public_release.py、compileall、git diff --check均通过;改动文件 ruff 无新增告警。🤖 Generated with Claude Code