feat(shipping-notice): 落地 XFA 统一视觉拆分确认门禁与处理投影收敛
闭合拆分预览令牌单次消费、样本 checksum 绑定与确认审计;正式提取改为 bindings-only。 同步统一标注工作台交互,并补齐进度投影/任务中心与迁移文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d2b3d74def
commit
84a881b554
195 files changed
+20269
-3463
No files matched your search
@@ -0,0 +1,47 @@
|
||||
"""
|
||||
backend/xfa_regex_worker.py
|
||||
|
||||
用途:restricted re 匹配的隔离子进程 worker(仅标准库 re,不导入 app 包)。
|
||||
依赖:re、dataclasses。
|
||||
逻辑:由 xfa_safe_regex 经 ProcessPoolExecutor spawn 调用;独立模块避免 Windows 下重载 app/__init__ 挂死。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class MatchSnapshot:
|
||||
"""子进程 re.search 结果快照,供父进程重建 Match 最小接口。"""
|
||||
|
||||
groups: tuple[str, ...]
|
||||
lastindex: int | None
|
||||
|
||||
|
||||
def run_restricted_search(pattern: str, flags: int, haystack: str) -> MatchSnapshot | None:
|
||||
"""
|
||||
在 pool worker 进程内执行 re.search 并返回快照。
|
||||
|
||||
核心逻辑:编译 pattern → search → 序列化分组;无匹配时返回 None。
|
||||
|
||||
Args:
|
||||
pattern: 已通过 validate 的正则 pattern。
|
||||
flags: re 编译 flags。
|
||||
haystack: 待搜索文本。
|
||||
|
||||
Returns:
|
||||
MatchSnapshot 或 None。
|
||||
|
||||
Raises:
|
||||
re.error: pattern 编译失败(子进程内不应出现,validate 已拦截)。
|
||||
"""
|
||||
compiled = re.compile(pattern, flags)
|
||||
match = compiled.search(haystack)
|
||||
if match is None:
|
||||
return None
|
||||
groups: list[str] = [match.group(0)]
|
||||
for idx in range(1, compiled.groups + 1):
|
||||
groups.append(match.group(idx) or '')
|
||||
return MatchSnapshot(groups=tuple(groups), lastindex=match.lastindex)
|
||||
Reference in new issue
Block a user