feat: add memory file count hard limit (500) and archive cap (20)

Prevents memory/ from growing unbounded by capping STATE_ARCHIVE
files at 20 per type and enforcing a 500-file hard limit on the
entire memory directory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 12:02:17 +10:00
co-authored by Claude Opus 4.6
parent 9ad4f0be03
commit cfb2de72d6
4 changed files with 114 additions and 25 deletions
+18 -20
View File
@@ -1,33 +1,31 @@
# Current State
> Last updated: 2026-03-13T07:02:00+10:00
> Last updated: 2026-03-21T02:00:58.027Z
## Objective
Validate the memory-continuity lifecycle plugin path safely after upgrade.
但是文件数目不可以超过500条
## Current Step
Startup-injection testing is confirmed on multiple resident subagents after the upgrade; Discord main/channel/thread paths have now been tested and are not currently supported for reliable continuity recovery; compaction-path testing is now being prepared on `travel_assistant` as the disposable session.
Conversation ended after 181 messages
## Key Decisions
- Keep `SKILL.md + standard lifecycle plugin` as the primary architecture.
- Treat ContextEngine as a future option, not the v1 default.
- Do not force compaction on the main live session just to test Experiment C.
- Use disposable resident subagent sessions for future compaction-path testing.
- `travel_assistant` is now a valid sample again after removing the old wrong workspace and fixing its `AGENTS.md` startup rule to read `memory/CURRENT_STATE.md`.
- Alpha support boundary is now explicit: resident subagent startup continuity is supported; Discord main/channel/thread continuity is not yet supported in `v0.3.0-probe`.
- Auto-extracted from conversation
## Next Action
Two-track next step:
1. If continuing active testing, use `travel_assistant` as the sacrificial session, reload the updated probe logging, then force/accelerate a real compaction event and compare hook behavior against the failure chain seen on main.
2. If pausing for upstream uncertainty, keep the fallback-continuity GitHub issue open and wait for OpenClaw feedback before spending more effort on the main-session fallback path.
Continue from where we left off
## Blockers
- Experiment C still lacks a real compaction event, so compaction-hook behavior remains unproven.
- New upstream-suspected blocker: fallback continuity failure may be caused by OpenClaw providing incomplete plugin runtime (`workspaceDir=<missing>`) on fallback/new-session recovery path.
None
## Unsurfaced Results
- Experiment A is now confirmed on multiple resident subagents.
- `tech_geek` recovered plugin-injected startup continuity state without using `read`.
- `travel_assistant` also recovered the correct upgraded smoke-test state after fixing its old workspace pollution and startup rule.
- Fresh Discord main/channel/thread tests failed to preserve short facts or concrete working-state recovery across new sessions; treat Discord main continuity as unsupported for this alpha.
- New execution-model finding: main can successfully dispatch and consume results from temporary subagents (single, follow-up, and parallel two-worker tests all succeeded).
- New ACP finding: Codex ACP worker is validated as a usable execution worker for main; Claude ACP today remains an invalid sample because Tao confirmed Claude was already in timeout/overuse state, so do not classify that failure as product/runtime evidence.
🦞 大内总管: 已加硬上限。
**改动:**
- `MAX_MEMORY_FILES = 500`
- 每次 archive 后检查 `memory/` 总文件数
- 超过 500 → 自动删最旧的可删文件,降到 450(留 50 个余量)
- **不会删的**`CURRENT_STATE.md``MEMORY.md``INDEX.md`、主题文件、JSON 状态文件
**三层防护:**
1. 单类 archive 上限 20 个
2. 总文件数硬上限 500
3. 清理时按修改时间排序,从最旧的开始删