Skip to content

fix: restore macOS cron maintenance tests - #206779

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-cron-maintenance-macos-platform-mock-20260919
Nov 27, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-cron-maintenance-macos-platform-mock-20260919

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two cron retention tests on macOS fail with a SQLite offline-maintenance error introduced by #200180. The fixture reports Linux while it opens a real SQLite worker, so the writer cannot publish a usable macOS process namespace.

User Impact

Developers can run the cron retention suite on macOS and get a verdict on retention and memory pressure. This is a test-only change with production LOC 0.

Why This Change Was Made

The fixture uses the existing withMockedPlatform helper around the real synchronous memory-pressure decision. The SQLite writer and worker use the native platform. All existing assertions and the synthetic low-memory inputs still run.

Evidence

  • On clean macOS origin/main at 4d7e00b86313, the pressure=none and pressure=process cases both failed with SQLite offline maintenance. The same command passed both cases with the fix in 14.92 s wall.

    node scripts/run-vitest.mjs src/cron/maintenance.test.ts -t 'runs Gateway retention after memory pressure clears \(pressure=(none|process)\)$' --maxWorkers=1 --reporter=verbose
  • OPENCLAW_VITEST_RUNTIME=node pnpm test src/cron/maintenance.test.ts --maxWorkers=1 --reporter=verbose passed all six cases in 27.76 s wall, including pressure=host.

  • A temporary change from 20% to 10% in both pressure thresholds caused pressure=process and pressure=host to fail at the existing zero-admissions assertion. Each observed one cron:maintenance admission. Restoring the thresholds left a fixture-only diff.

  • pnpm check:changed passed format, lint, cron typechecking, and the remaining checks. Its sole failure, the production Knip finding for src/infra/restart.ts: hasPendingGatewayRestart, reproduced on clean 4d7e00b86313. improve: keep Gateway restart controls out of local model preparation #206739 moved the last production caller to restart-pending.ts and retained the old re-export.

  • The scoped rerun of pnpm check:changed passed with only the reproduced dead-export scan omitted.

  • Codex autoreview found no actionable P0–P2 issues in the fixture diff against 4d7e00b86313.

@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review November 27, 2026 15:37
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T15:38:18.979703Z c895092 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added the P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. label Nov 27, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review the current head. The macOS fixture proof, local review, and exact-head CI are complete.

@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR scopes the Linux platform mock to the memory-pressure check so real SQLite workers retain their native platform identity.

Example: Run the cron maintenance pressure=process case on macOS with 128 MiB available against a 1 GiB process limit.

  • Before: The fixture reports Linux during SQLite setup and encounters an offline-maintenance error.
  • After: SQLite uses macOS identity while the real memory-pressure decision still defers maintenance until memory recovers.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A minimal test-fixture repair supported by reported macOS before/after results, pressure mutation checks, and passing exact-head CI.
Proof confidence 🐚 platinum hermit (4/6) No shipped behavior changes; the reported macOS reproduction exercises the changed fixture with real SQLite workers and preserves mutation-sensitive pressure assertions.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Developers on macOS receive a SQLite fixture error instead of a meaningful cron retention test result.
Reason: The maintainer-authored repair restores a supported development workflow without weakening pressure or retention coverage.

Regression provenance

Regression provenance — suspected predecessor, not a causality claim: source commit 67ecf6bf352d by Vincent Koc; no PR verified.

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

This PR restores useful macOS test coverage with a focused fixture repair; no actionable correctness or security defects were found.

Reviewed head: c895092aa46f71f0820c175decfc5a02bca26e41

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway cron maintenance checks memory pressure before admitting retention work; this test combines a controlled scheduler and memory inputs with real SQLite-backed history and session maintenance.

flowchart TD
  A[Controlled scheduler] --> B[Cron maintenance]
  B --> C[Real memory pressure decision]
  C --> D[Scoped Linux platform mock]
  B --> E[Retention and session maintenance]
  E --> F[SQLite with native platform identity]
Loading

Technical review

Best possible solution:

Retain this fixture repair so memory-pressure coverage uses the real decision while SQLite observes the native platform.

Do we have a high-confidence way to reproduce the issue?

The fixture-wide platform mock and platform-sensitive namespace reader establish the failure path, supported by the author's macOS base-fail/head-pass report; this read-only review ran no tests.

Is this the best way to solve the issue?

The change uses an existing scoped helper, preserves the real memory-pressure calculation and every assertion, and avoids changing production SQLite or maintenance behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8052dd7cffb7.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Focused introduced diff: The pinned introduced diff changes only the fixture import, platform-mock scope, and corresponding restoration; all existing inputs and assertions remain. (src/cron/maintenance.test.ts:58, c895092aa46f)
  • Synchronous restoration preserves native identity: withMockedPlatform delegates to withRestoredMocks, which restores the platform immediately after the synchronous memory-pressure callback, including when it throws. (src/test-utils/vitest-spies.ts:33, c895092aa46f)
  • Platform-sensitive namespace boundary: Process namespace discovery selects platform-specific boot identity and reads Linux PID namespace information from /proc; failures return null, explaining why a fixture-wide Linux mock is unsuitable on macOS. (src/infra/gateway-lock-payload.ts:31, c895092aa46f)
  • Regression provenance and current main: fix(runtime): defer optional work on low-memory Linux hosts #200180 introduced the fixture-wide Linux mock while expanding process and host pressure coverage; fetched main still contains that mock. (src/cron/maintenance.test.ts:57, 9f50802605b4)
  • Reported macOS validation: The full PR body reports the two affected cases failing on the base and passing with the fix, all six Node cases passing, and threshold mutations making both pressure variants fail at the existing zero-admissions assertion. (src/cron/maintenance.test.ts:42, c895092aa46f)
  • Exact-head CI: The reviewed head has successful openclaw/ci-gate, changed Node tests, boundary tests, lint, and test-type checks; canceled earlier dispatch and evidence runs have successful counterparts. (c895092aa46f)

PR surface

Tests +5. Total +5 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 7 2 +5
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 7 2 +5

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 27, 2026, 10:52 AM ET / 15:52 UTC.

@steipete
steipete merged commit 76f14c3 into main Nov 27, 2026
184 of 186 checks passed
@steipete
steipete deleted the steipete/perf-micro-cron-maintenance-macos-platform-mock-20260919 branch November 27, 2026 15:55
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
(cherry picked from commit c8e6d12)

Companion audit: #204622 (1ee3caa) is not applicable: its keep-warm config is absent from the baseline and this test fails schema validation with it. #200180 (9f50802) is separately selected later in this lane; #206779 (76f14c3) targets that later pressure macOS simulation.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
* fix(runtime): defer optional work under host memory pressure

* style(infra): format memory pressure admission

* style(gateway): format the deferred prewarm check

(cherry picked from commit 9f50802)

Companion audit: #207993 selected later for publication fixture isolation. #206779 required if the new Cron host-memory fixture spoofs platform: preserve native SQLite namespace. #206041/#206230/#206308/#206746 are separate cgroup detection and optimization changes; #206322 is service-aware cron run budget, #206483 forks chat and #206384 changes a main-only warmer.

Release adaptation: Extend the stable optional-memory owner and its existing callers only. Preserve cgroup/Bun/macOS behavior and upstream threshold cases; omit main-only prompt warmer, cgroup diagnosis, and Cron platform-spoof changes.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant