feat(scheduler): QZone 日常发布多样性引擎 — 灵感种子 / 反重复 post-log / 多样性 tail / 发布抖动 (PR-B4)#155
Merged
Merged
Conversation
反死板改造主件(PR-B4):让 QQ 空间日常「说说」不再每天都是那点东西。 - 4a 灵感种子:每次跑注入一次 persona_life_event_seed(kind=freeform) 抽取结果为「## 今日灵感种子」块;lazy+try/except 的 server→agent import, 失败即省略(无存储 IO,便宜)。 - 4b 反重复 post-log:新建轻量 sidecar <DATA_DIR>/qzone_post_log/<persona_id>.json(slug 校验防穿越、原子写、 留最近 30 条、text 截 500 字)。发布成功后追加一条;组 prompt 时读最近 N 条列为「## 最近已发过的说说(禁止重复主题/场景/句式)」。metadata 可选 recent_posts_n(1-14,默认 7)。有意不用 scheduler history/diary/live feed。 - 4c 多样性 tail + 组装顺序:persona body → 生活块 → 种子块 → 最近说说块 → 新 tail(主题/场景/句式必须不同、至少换一个新切入点、⚠ 生活节奏提醒优先并 用 persona_life_set_state/event_seed 推进)。metadata diversity(默认 true) 为 false 时整体回退旧行为,post-log 也不写。 - 4d 发布时间抖动(默认关,runner 级):JobSpec.jitter_secs + _run_job_loop 算完 wait_secs 后 += random.uniform(0, jitter_secs); _scheduler_lib 从 job metadata 的 jitter_minutes(0-180,非法忽略)换算, 不给 NewJobBody/EditJobBody/JobOut 加顶层字段。 不改 _harvest_envelope / _resolve_life_block 逻辑,仅在组装处衔接。所有新 metadata 字段可选带默认;server→agent import 一律 lazy + try/except;builtin 永不抛异常。mypy strict + ruff + import-linter 全绿。
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
sweetcornna
added a commit
that referenced
this pull request
Jul 18, 2026
…r_minutes 全链路 (#157) NewJobBody/EditJobBody/JobOut 新增可选顶层字段 image_ref_labels / jitter_minutes; _compose_metadata 用显式赋值让顶层字段权威覆盖 metadata 旧值(None 时不覆盖); _validate_qzone_daily 校验 label 形状([a-z0-9_-]{1,64})+数量≤8、jitter 0-180 → 422; JobOut 从 metadata 读回回显;PATCH 合并透传,jitter 变更经 _apply_enabled_state 重建 runner loop 的 jitter_secs(复用 #155 _jitter_secs_from_metadata)。 builtin 组 system prompt 时读 image_ref_labels,在普通/多样性两种 tail 后追加 参考图指令段(best-effort,形状不对即省略,永不抛)。 上传通道复用现有 persona-asset 路由(kind=reference),调度侧只存 label 字符串。 Co-authored-by: Cornna <[email protected]>
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.
目标
反死板改造主件(PR-B4):解决「QQ 空间日常说说不要每天都是那点东西」。基于最新 main(已含 #150 payload 转发的 audit
text字段 + #152 生活节奏信号)。实现(主战场
scheduler/builtins/qzone_daily.py,每个成分 best-effort,失败即省略)4a 灵感种子
persona_life_event_seed(kind=freeform)抽取 → system prompt 加「## 今日灵感种子(至少换一个新切入点)」块。dispatch_persona_life_event_seed),沿用_life_signals/persona_life_advance的先例;无存储 IO,便宜。4b 反重复 post-log(新建轻量 sidecar)
<DATA_DIR>/qzone_post_log/<persona_id>.json;persona_id 过 slug 校验(防路径穿越,非法即跳过整个功能)。{version: 1, posts: [{ts, job, tid, qzone_url, text(截 500 字)}]},留最近 30 条,原子写(tmp.new+ rename)。recent_posts_n(1-14,默认 7)。4c 新 tail + 组装顺序
persona_life_set_state/persona_life_event_seed推进 persona 状态。diversity(默认 true):false 时整体回退旧行为(无种子/最近说说块、旧 tail、post-log 也不写)。4d 发布时间抖动(默认关,runner 级)
runner.py::JobSpec加jitter_secs: int = 0;_run_job_loop算完wait_secs后+= random.uniform(0, jitter_secs)(不做 builtin 级 sleep,避免卡住手动 trigger 的 HTTP 请求)。_scheduler_lib.py:从 job metadata 的jitter_minutes(0-180,非法忽略)换算jitter_secs传给runtime_job_spec;不给NewJobBody/EditJobBody/JobOut加顶层字段(留给下个 PR)。约束遵守
_harvest_envelope/_resolve_life_block逻辑,仅在组装处衔接。测试
.new。JobSpec.jitter_secs采样落在[0, jitter_secs](patchrandom.uniform)+ 0 时不调用;jitter_minutes非法值(负/超 180/非数字/None/bool)被忽略。验证
ruff check(改动文件):clean(models.py的 I001 是 main 上已存在的问题,非本 PR)mypy python/packages/:Success(609 files)lint-imports:2 kept / 0 brokenpytest tests/scheduler/ tests/test_admin_scheduler_qzone.py:152 passed