MiniMax-AI / MiniMax-AI/minimax-code
[Feature Request] Add createdAt field to mavis cron task schema
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 141
- Avg merge
- 2h 45m
- Merged PRs (30d)
- 46
Description
GitHub Issue: Add createdAt field to mavis cron task schema
目标仓库:
<mavis 团队 GitHub repo URL>(请用户根据 mavis 项目实际情况填入)
作者:通过 MiniMax Code 提交(用户:Sixone-L)
时间:2026-06-26
相关 issue/PR:(首次提交,搜索历史无重复)
Title
[Feature Request] Add createdAt field to mavis cron task schema for audit and lifecycle tracking
Summary
mavis 的 cron 任务配置 schema 目前不记录任务创建时间(createdAt)。当用户问"这 cron 什么时候配的 / 谁加的"时,无法给出准确答案——只能反推文件 mtime 或 sessions.json 的"首次跑"时间(不准,且 sessions.json 在 cron 从未跑过时不存在)。
提议:在 cron 任务配置(crons/<name>.md 或等价的存储)增加 createdAt 字段(ISO 8601 时间戳),由 mavis 在 cron create 时自动填。
Problem
场景 1:用户问"这 cron 什么时候建的?"
- 用户的 mavis 配置了多个 cron 任务(6-10 个常见)
- 用户某天发现
realtime-chat-archive在跑,但不记得什么时候配的 - 用户问 mavis / 翻配置文件都查不到 createdAt
- 只能通过文件 mtime 估算,但 mtime 不可靠(如果 mavis 升级或 schema 迁移会重写文件)
场景 2:审计 / 多人协作
- 团队多人都能配 cron
- 出问题排查时需要"谁加的 / 什么时候加的"
- 现在只能从 git blame + 文件 mtime 推,不准确也不直接
场景 3:清理孤儿 cron
- 维护时想删"很久没跑过的 cron"
- 没有 createdAt,无法判断"这 cron 是 1 周前新加的"还是"3 个月前历史遗留"
- 误删可能引发数据丢失
数据(真实场景)
2026-06-26:用户
Sixone-L在 MiniMax Code 里发现 6 个 mavis 默认 cron 任务,问"什么时候建的"。mavis 提供的信息:
mavis cron info输出没有createdAt字段- 配置文件 schema
crons/<name>.md没有createdAt字段- 用户被迫查
crons/<name>.sessions.json的 first session 推断(不准——cron 从未跑过时不存在)- 也可查文件 mtime 推断(不准——文件被改过就丢)
真实数据:6 个 cron 的 first session 时间分布在 2026-06-25 19:30 UTC ~ 2026-06-26 07:06 UTC(跨 12 小时),说明不是同一次触发——没有 createdAt 字段就只能猜。
Proposed Solution
Schema 变更
在 crons/<name>.md 的 YAML frontmatter 增加一个字段:
---
name: realtime-chat-archive
schedule: '* * * * *'
timezone: Asia/Shanghai
createdAt: 2026-06-26T15:06:00+08:00 # ← 新增
createdBy: user:sixone-l # ← 可选:审计用
report_to_root: false
---
Run: node M:\MiniMax\ObsidianVault\.scripts\realtime-monitor.js
CLI 行为变更
# 现在
$ mavis cron info mavis realtime-chat-archive
{
"cronName": "realtime-chat-archive",
"schedule": "* * * * *",
"timezone": "Asia/Shanghai",
"enabled": true,
"prompt": "...",
"status": "idle",
"lastRun": ...,
"lastResult": "success",
"nextRun": ...
}
# 提议
$ mavis cron info mavis realtime-chat-archive
{
"cronName": "realtime-chat-archive",
"schedule": "* * * * *",
"timezone": "Asia/Shanghai",
"enabled": true,
"createdAt": "2026-06-26T15:06:00+08:00", # ← 新增
"createdBy": "user:sixone-l", # ← 可选
"prompt": "...",
"status": "idle",
"lastRun": ...,
"lastResult": "success",
"nextRun": ...
}
# 现在
$ mavis cron list mavis
NAME SCHEDULE ENABLED STATUS
...
# 提议(可选加 CREATED 列)
$ mavis cron list mavis
NAME SCHEDULE ENABLED CREATED STATUS
realtime-chat-archive * * * * * yes 2026-06-26T15:06:00 idle
...
Implementation Notes(思路,不强求)
- 存储:在
crons/<name>.md的 frontmatter 加createdAt字段(无需新文件) - 写入:在
cron create命令执行时,由 mavis 自动写当前时间(ISO 8601 with timezone) - 读取:
cron info/cron list直接读 frontmatter 字段 - 可选:
createdBy字段(用户/agent/系统),审计场景用 - 不需要 new API endpoint——现有 schema 增量扩展
Migration(向后兼容)
已有 6+ 个原 cron 怎么办?
方案 A(推荐):mavis 启动时检查——如果 frontmatter 没有 createdAt,用 crons/<name>.md 的文件 mtime 或 sessions.json 的 first createdAt 估算,自动回填。
方案 B:在 mavis cron 加一个 migrate 子命令(一次性),由用户手动跑。
方案 C:不迁移,已有任务不补 createdAt,新增任务才有。
推荐 A——零用户操作 + 估算值比"没值"好。
迁移逻辑伪代码
def migrate_cron_config(cron_md_path):
fm = read_frontmatter(cron_md_path)
if 'createdAt' in fm:
return # already migrated
# 优先级 1: sessions.json first createdAt
sessions_json = cron_md_path.with_suffix('.sessions.json')
if sessions_json.exists():
first = read_json(sessions_json)['sessions'][0]
fm['createdAt'] = format_iso8601(first['createdAt'])
# 优先级 2: 文件 mtime(cron 从未跑过的情况)
else:
fm['createdAt'] = format_iso8601(os.path.getmtime(cron_md_path))
write_frontmatter(cron_md_path, fm)
Use Cases(实施后解锁的能力)
- 审计:查看"过去 30 天新增的 cron"(
mavis cron list --since 30d) - 清理:识别"超过 1 年没碰的孤儿 cron",提醒用户确认删除
- 协作:明确"这 cron 是哪个 session 加的"
- 用户视角:"数据管理员每 30 分钟整理一次数据"——管理员能精确说"这个 cron 配了多久"
- 未来扩展:可加
updatedAt字段追踪"上次修改",进一步丰富审计
Why Now
- mavis 已成熟使用(MiniMax Code 用户群),cron 任务越来越多
- 用户真实遇到问题(2026-06-26 用户提问"第一个什么时候创建的",无解)
- 字段轻量——只是 schema 增量,不需要破坏性变更
- 迁移成本低(自动估算回填)
Priority
Medium——不是紧急 bug,但影响所有 mavis 重度用户的运维体验。建议排到下个 minor release。
Labels (建议)
enhancementarea/crongood first issue(实现简单,适合新人)
Related
- 用户工作流参考:
<贴用户 vault 的 created-at 索引文件链接> - 实际场景日志:2026-06-26 用户
Sixone-L在 MiniMax Code 里发现 6 个原 cron 没法查 createdAt - 相关讨论:(首次提交,无相关 issue)
Checklist (for maintainers)
- 决定
createdAt字段名(建议createdAt,与生态对齐) - 决定是否加
createdBy(可选字段) - 决定迁移策略(A/B/C)
- 实现
cron create自动写createdAt - 实现
cron info/cron list读createdAt - 实现迁移工具(自动回填)
- 更新 mavis 文档(crons 配置章节)
- 在 release notes 标注 schema 变更
- 通知用户"可以删 vault 内的伪索引文件了"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the cron create, cron info, and cron list entry points, then inspect the crons/<name>.md frontmatter and related .sessions.json data. Confirm how cron fields are stored and displayed, and determine how the proposed migration behavior fits existing configuration handling. Done means newly created tasks expose createdAt, the relevant CLI output includes it, and the selected backward-compatibility behavior is covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100