Repository navigation
[ENG-21229] fix(agents): re-derive memory flush path across a midnight rollover - #284
Conversation
…t rollover The memory-flush append-only write guard pinned its allowed relative path (memory/YYYY-MM-DD.md) when the tool set was built. If actual tool execution happened later than that — provider fallback/retry backoff, or a long-running flush turn — real wall-clock time could cross midnight before the write, and the guard rejected the (correct) current-date path with "Memory flush writes are restricted to memory/<yesterday>.md". Hit 6 times across 2 customer sessions on jaynes on 2026-10-08 (OPENCLAW-FLEET-16N). wrapToolMemoryFlushAppendOnlyWrite now re-resolves the flush plan at execute() time (same timezone-aware date-stamp logic the flush prompt itself uses) and accepts either the originally pinned path or the freshly-derived current one, closing the gap without weakening the single-file restriction. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
cubic analysis
All reported issues were addressed across 3 files
Linked issue analysis
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Re-derive the allowed flush path at execution time | The write guard calls resolveMemoryFlushPlan during execute(), using the current time and supplied config. |
| ✅ | Accept the current-date path after a midnight rollover | The guard accepts the freshly resolved path alongside the pinned path; a regression test writes to the new date. |
| ✅ | Use timezone-aware date resolution for the current path | Execution-time resolution uses the same plan resolver and timezone-aware date logic as the flush prompt. |
| ✅ | Add a regression test for date rollover | The test registers a new-date plan and verifies a tool built with the prior date can write successfully. |
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
- Fix the "same-day retries" test: it was writing to an unrelated path and asserting rejection, never actually exercising the resolver-present case where the pinned path is accepted. - Correct the cfg doc comment: the real fallback trigger is "no flush-plan resolver registered", not "cfg omitted" — a registered resolver can still derive a plan without cfg. - Trim the execute()-time comment to repo convention (1-3 lines, no Linear ticket reference).
…ions security-fast's pnpm-audit-prod flagged 6 high/critical advisories across these transitive production deps: - simple-git <=3.36.0 (GHSA-v5rq-49vh-5v5c, GHSA-x6jw-m9v5-85vh, GHSA-g4wm-2vf7-vfgr, GHSA-858h-whjf-mvg5) — unsafe-operation guard gaps allowing command execution. No fix on the 3.x line; pinned to 4.0.2. Only pulled in by node-llama-cpp's build tooling, never imported directly. - proxy-addr <2.0.8 (GHSA-jqcg-44mw-7w3h) — IP spoofing via IPv4-mapped IPv6 trust-subnet bypass. Transitive dep of express. - source-map-js <1.2.2 (GHSA-68fv-2mgg-jv7q) — event-loop DoS. Transitive dep of postcss/css-tree/magicast. Pinned via pnpm-workspace.yaml:overrides, following the existing "Security-audit bumps" pattern already used for @grpc/grpc-js, brace-expansion, postcss, etc. Verified clean with scripts/pre-commit/pnpm-audit-prod.mjs locally.
Dependency GuardThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
Dependency graph changes notedThis PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin or a member of
Security review is still recommended before merge when the dependency graph change is intentional. |
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
…bump
checks-node-core-tooling's test/package-manager-config.test.ts asserts every
npm-shrinkwrap.json package version also exists in pnpm-lock.yaml. Bumping
proxy-addr/simple-git/source-map-js via pnpm-workspace.yaml:overrides (prior
commit) left the committed shrinkwraps pointing at the old, now-absent
versions, so the test failed on CI.
The repo's own shrinkwrap generator (scripts/generate-npm-shrinkwrap.mjs)
currently can't regenerate cleanly here — it throws on a pre-existing,
unrelated drift between the committed root shrinkwrap and pnpm-lock.yaml for
@sentry/node's nested @opentelemetry/resources and sdk-trace-base (the same
registry-resolution nondeterminism ci.yml's check-shrinkwrap step already
documents as allowed to drift on this fork). Hand-patched just the affected
entries instead of running the generator:
- npm-shrinkwrap.json, extensions/{acpx,msteams,slack}/npm-shrinkwrap.json:
proxy-addr 2.0.7 -> 2.0.8
- extensions/llama-cpp/npm-shrinkwrap.json: simple-git 3.36.0 -> 4.0.2,
@simple-git/argv-parser 1.1.1 -> 2.0.1, @simple-git/args-pathspec
1.0.3 -> 1.0.4 ([email protected]'s own declared sub-dependency versions)
Verified with `npx vitest run test/package-manager-config.test.ts` (12/12
passing, including the previously-failing assertion) and a JSON-validity
check on every edited file.
There was a problem hiding this comment.
Code Review Summary
Verdict: APPROVE (covers commit cfea545e5416673eedba690cb7e062fc3b692944 specifically)
Analysis & Correctness
-
Root Cause & Date Rollover Resolution:
wrapToolMemoryFlushAppendOnlyWritepreviously pinnedrelativePath(memory/YYYY-MM-DD.md) during tool instantiation. If execution occurred after midnight (due to provider fallback, retry backoff, or extended turn latency), the agent used the current date's path while the guard enforced yesterday's pinned path (OPENCLAW-FLEET-16N/ ENG-21229).- The fix re-evaluates
resolveMemoryFlushPlan({ cfg: options.cfg, nowMs: Date.now() })dynamically atexecute()time. - When a plan exists and differs from the pinned path, both the original and current-date paths are recognized as valid candidates (
candidates = [{ relativePath, absolutePath }, ...]). - If the write targets any other path, it throws with an explicit message naming the allowed candidate(s):
Memory flush writes are restricted to ${allowedDescription}; use that path only.. options.configis passed through insrc/agents/agent-tools.ts(cfg: options?.config), ensuring the resolver uses the configured user timezone (formatDateStampInTimezone(nowMs, userTimezone)viaresolveCronStyleNow).- If no resolver is registered (or
resolveMemoryFlushPlanreturns null), the guard cleanly falls back to the original pinned single-path restriction.
-
Security & Dependency Audit:
- The single-file append-only restriction remains intact: arbitrary writes and traversal remain strictly blocked.
- Resolves 6 high/critical security advisories via exact version pins in
pnpm-workspace.yaml:overrides:simple-git:4.0.2(GHSA-v5rq-49vh-5v5c, GHSA-x6jw-m9v5-85vh, GHSA-g4wm-2vf7-vfgr, GHSA-858h-whjf-mvg5)proxy-addr:2.0.8(GHSA-jqcg-44mw-7w3h)source-map-js:1.2.2(GHSA-68fv-2mgg-jv7q)
- Synchronized across
pnpm-lock.yaml, rootnpm-shrinkwrap.json, and extension shrinkwraps (extensions/{acpx,llama-cpp,msteams,slack}/npm-shrinkwrap.json). - Verified with
node scripts/pre-commit/pnpm-audit-prod.mjs(0 high/critical advisories found).
-
Code Quality & Review Threads:
- All 4 Cubic AI review threads are addressed and verified:
- Unit test updated to assert write success on
STALE_RELATIVE_PATHbefore asserting rejection of unrelated paths. - Config doc comment in
src/agents/agent-tools.read.tscorrectly reflects that fallback is triggered when no flush-plan resolver is registered. - Inline comments adhere to repo guidelines (concise 1–3 line rationale, no Linear ticket references in source).
- Shrinkwraps synced with overrides.
- Unit test updated to assert write success on
- Oxlint passed cleanly on touched files.
- All 4 Cubic AI review threads are addressed and verified:
-
Testing & CI Verification:
src/agents/agent-tools.read.memory-flush-write.test.ts: 4/4 passing (covers pinned-path regression, post-midnight rollover acceptance, rejection of unrelated path naming both candidates, and same-day retries).src/agents/embedded-agent-runner/run/attempt.memory-flush-forwarding.test.ts: 3/3 passing.test/package-manager-config.test.ts: 12/12 passing (verifies shrinkwrap vs lockfile alignment).- CI check runs on
cfea545e5416673eedba690cb7e062fc3b692944: all green (includingcheck-shrinkwrap,check-dependencies,check-guards,check-prod-types,check-test-types,security-fast, and all node agentic/tooling shards).
Drives the real production call chain (createOpenClawCodingTools building and wrapping the write tool, through to an actual filesystem write) with only the wall clock faked, rather than calling the wrapper function in isolation as the earlier unit tests do. Proves the full wiring (agent-tools.ts -> wrapToolMemoryFlushAppendOnlyWrite -> resolveMemoryFlushPlan) is correct, not just the wrapper's own logic. Verified this test actually exercises the regression: temporarily reverted agent-tools.ts/agent-tools.read.ts to the pre-fix baseline (ecf05cc) and confirmed the rollover case fails with the exact error from the Sentry report (OPENCLAW-FLEET-16N) — "Memory flush writes are restricted to memory/2026-10-07.md" — while the no-resolver-registered regression case still passes either way. Restored the fix and reran clean.
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/agents/agent-tools.memory-flush-rollover.e2e.test.ts">
<violation number="1" location="src/agents/agent-tools.memory-flush-rollover.e2e.test.ts:67">
P2: The resolver closes over `cfg` instead of using `params.cfg`, so this test passes even if the wrapper stops forwarding config. Use `params.cfg` and a timezone/date pair that differs from the host default.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| systemPrompt: "flush", | ||
| relativePath: `memory/${dateStampInTimezone( | ||
| params.nowMs ?? Date.now(), | ||
| cfg.agents?.defaults?.userTimezone, |
There was a problem hiding this comment.
P2: The resolver closes over cfg instead of using params.cfg, so this test passes even if the wrapper stops forwarding config. Use params.cfg and a timezone/date pair that differs from the host default.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/agents/agent-tools.memory-flush-rollover.e2e.test.ts, line 67:
<comment>The resolver closes over `cfg` instead of using `params.cfg`, so this test passes even if the wrapper stops forwarding config. Use `params.cfg` and a timezone/date pair that differs from the host default.</comment>
<file context>
@@ -0,0 +1,158 @@
+ systemPrompt: "flush",
+ relativePath: `memory/${dateStampInTimezone(
+ params.nowMs ?? Date.now(),
+ cfg.agents?.defaults?.userTimezone,
+ )}.md`,
+ }));
</file context>
E2E & regression testing reportFull test methodology and results for the ENG-21229 fix, beyond the inline unit tests already in the diff. What was tested and howNew e2e test: Two cases:
Proof the test actually catches the regressionTo confirm the e2e test isn't a false positive, I temporarily reverted just That is the exact error string from the Sentry report (OPENCLAW-FLEET-16N) that triggered this ticket. The regression-guard case passed either way, as expected. I then restored the fix and reran — both cases passed. This confirms the new test exercises the real bug, not an artifact of the test's own setup. Full verification run (fix restored)
CI (full matrix, head
|
| Layer | Coverage |
|---|---|
| Unit (isolated wrapper) | 4 cases: regression, rollover-accept, reject-both, same-day-reassert |
| Integration/e2e (real call chain) | 2 cases: rollover-accept via real createOpenClawCodingTools, no-resolver regression guard |
| Negative proof | Confirmed test fails against pre-fix code with the exact production error string |
| CI | 116/116 applicable checks green on the final commit |
Manual e2e verification (live, not vitest)Follow-up to the earlier automated e2e report. Per a request to go beyond vitest and manually verify the fix behaves correctly in a real running environment, I did the following. Local environment checkChecked for a running local OpenClaw instance on this machine. Found Manual live test insteadRan the actual fix-branch source directly via
With the fix (current branch head): I With the fix temporarily reverted (same unmodified script, That is the exact error string from the original Sentry report (OPENCLAW-FLEET-16N). Restored the fix ( Net result
This is in addition to (not a replacement for) the earlier automated e2e test ( Did not touch the live local gateway (v2026.6.11-boon.42, currently stopped) since it's a real personal daily-use instance — happy to do a full live-gateway test (swap the npm package with a build of this branch, restart, trigger a real flush through an actual chat turn) if wanted, but that needs an explicit go-ahead since it affects a running personal assistant. |
…npm-lock.yaml Two independent merges (upstream v2026.6.35 sync + boon PR #282/#284) each added their own simple-git/proxy-addr/source-map-js CVE overrides without textually overlapping, so git's line-based merge kept all copies instead of flagging a conflict. The resulting duplicate YAML mapping keys broke CI's strict-mode lockfile parse at the "Resolve pnpm store path" step. Consolidated to one override per package (same resolved versions throughout, so no shrinkwrap changes). Co-Authored-By: Claude Sonnet 5 <[email protected]>
…ide keys (#285) PR #284's security-bump commit added a second overrides block for simple-git, proxy-addr, and source-map-js without noticing all three were already pinned a few lines above with the same versions. The duplicate YAML mapping keys crash `pnpm store path` during CI's setup-node-env step, failing every job on every PR against boon instantly (10-20s, before any job-specific work runs) — confirmed across multiple unrelated open PRs. Removed the duplicate block from both pnpm-workspace.yaml and pnpm-lock.yaml (which mirrors the same overrides section). No effective version changes: both blocks pinned identical versions, and `pnpm install --frozen-lockfile` now succeeds with zero resolution changes. Co-authored-by: Claude Sonnet 5 <[email protected]>
Cut the fork release that ships the six commits on boon since v2026.6.34-boon.6: - #286: decouple Rastermill's image decode and output pixel budgets so a source image above 25 megapixels downscales instead of being rejected outright; plus HEIC/data-URL pixel-guard and error-detail fixes. - #283 (ENG-21233): classify a caller's external timeout abort as a clean interruption instead of leaking DOMException's TimeoutError code as "Turn budget exceeded | 23" on agent_end. - #284 (ENG-21229): re-derive the memory-flush write guard's allowed path at execute time so a flush crossing midnight no longer rejects the correct current-date path. - #282 (ENG-21225): web_fetch 403/404/429 no longer page Sentry as unhandled exceptions; 429 now retries with bounded backoff honoring Retry-After. - #285: remove a duplicate simple-git/proxy-addr/source-map-js overrides block that crashed pnpm store path on every PR against boon. - #275: bump music-metadata 11.12.3 -> 11.16.0. Bump root package.json and npm-shrinkwrap.json, all 136 plugin manifests, and the version/peer floor in every extension npm-shrinkwrap.json via pnpm release:prep. The npm-shrinkwrap generator can't regenerate cleanly on this fork (pre-existing, unrelated @sentry/node nested @opentelemetry/resources / sdk-trace-base registry-resolution drift, verified present on unmodified origin boon); hand-patched the affected shrinkwrap version/peer-floor fields instead, verified against test/package-manager-config.test.ts (12/12 passing). Add the 2026.6.34-boon.7 CHANGELOG.md section and the generated extensions/matrix/CHANGELOG.md entry. No config schema, plugin-SDK surface, or plugin source/dependency change in slack/msteams/diagnostics-prometheus; this is a gateway-only roll. Co-authored-by: Claude Sonnet 5 <[email protected]>
Summary
wrapToolMemoryFlushAppendOnlyWritepinned its allowedmemory/YYYY-MM-DD.mdpath when the memory-flush tool set was built. Actual tool execution can happen later (provider fallback/retry backoff, a long-running flush turn), so real wall-clock time could cross midnight before the write — and the guard rejected the (correct) current-date write withMemory flush writes are restricted to memory/<yesterday>.md.jayneson 2026-10-08 (OPENCLAW-FLEET-16N).execute()time — same timezone-aware date-stamp logic the flush prompt itself uses — and accepts either the originally pinned path or the freshly-derived current one. Falls back to the original single-path behavior when no plan is registered/resolvable, so this is purely additive.Linear
ENG-21229
Test plan
src/agents/agent-tools.read.memory-flush-write.test.ts: pinned-path regression, accepts today's path when the pinned path is stale from before a rollover, still rejects an unrelated path (naming both allowed candidates), and same-day retry still restricts to the single plan path.npm test -- src/agents/agent-tools.read.memory-flush-write.test.ts src/agents/embedded-agent-runner/run/attempt.memory-flush-forwarding.test.ts— 7/7 passing.pnpm tsgo:core— clean.node scripts/run-oxlint.mjson changed files — clean.Fleet-Impact: none (openclaw gateway source change, ships via the normal version roll — not a
setup/scripts/**/packer/scripts/**fleet artifact).🤖 Generated with Claude Code
Summary by cubic
Fixes the memory-flush append-only guard rejecting valid writes after a midnight rollover (ENG-21229, Sentry OPENCLAW-FLEET-16N). The allowed path was pinned when the flush tool set was built, so a flush that executed later — after provider retry backoff or a long-running turn — could cross midnight and be rejected for using the correct current-date path. The guard now re-derives today's flush path at execution time and accepts either the pinned path or the freshly-derived one; unrelated paths are still rejected, so the single-file restriction is unchanged.
Bug Fixes
execute()time using the same timezone-aware date logic the flush prompt uses.Dependencies
simple-gitto 4.0.2,proxy-addrto 2.0.8, andsource-map-jsto 1.2.2 viapnpm-workspace.yamloverrides to clear 6 high/critical advisories flagged by the prod audit; all three are transitive deps never imported directly.npm-shrinkwrap.jsonfiles with the bumped versions so the package-manager-config test passes.Written for commit 74317f6. Summary will update on new commits.