Skip to content

perf(test): make Workshop contention deterministic - #124440

Merged
steipete merged 1 commit into
mainfrom
perf/skill-workshop-contention-tests
Aug 16, 2026
Merged

steipete merged 1 commit into
mainfrom
perf/skill-workshop-contention-tests

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two Skill Workshop contention regressions spend almost ten seconds near production lease deadlines: the list-tool test holds a collection lock for 4.6 seconds to detect accidental parallel reconciliation, and the real lease-timeout test waits the full five-second acquisition budget.

Why This Change Was Made

Split the invariants at their actual owners:

  • The list-tool test now wraps the existing Workshop lock module with an exact test factory that rejects overlapping commit-lock entries. It still creates and reconciles all 51 real proposals, preserves pagination and stale-status assertions, and deterministically proves that listSkillProposals processes reconciliations serially.
  • The collection test still holds the real SQLite collection lease and invokes both real proposal read paths. It advances only the monotonic acquisition clock past the five-second deadline so both callers return the real typed OPENCLAW_STATE_LEASE_TIMEOUT without sleeping.

Real lock blocking, rollback serialization, and cross-process lease behavior remain covered by the collection and plugin lifecycle suites. Production code and lease policy are unchanged.

User Impact

Maintainer Skill Workshop test feedback is substantially faster and the serialization regression now fails immediately rather than indirectly near a deadline.

Evidence

Controlled same-Testbox A/B on tbx_01m04g95378a8095c9gtat86j4, one excluded warmup plus two retained samples per state, the same two-file command, one worker, distinct filesystem module caches, import diagnostics, and /usr/bin/time -v:

Metric Before After Gain
Wall 27.22s 17.44s -9.79s (-35.9%)
Summed Vitest 21.78s 11.90s -45.4%
Test body 13.23s 3.42s -74.2%
Imports 7.34s 7.26s effectively flat

CPU and peak RSS were effectively flat, so this PR makes no resource-usage claim.

Validation:

  • 32/32 Workshop list, collection reconciliation, and plugin lifecycle lease tests.
  • Full core changed gate on the retained Testbox, including assertion-safety, core-test typecheck, and targeted lint.
  • Fresh post-rebase Codex autoreview: no accepted/actionable findings.
  • Mutation: restoring Promise.all in listSkillProposals fails immediately with skill proposal reconciliations overlapped.
  • Real SQLite timeout assertions still return OPENCLAW_STATE_LEASE_TIMEOUT for both list and inspect callers.
  • Production LOC: +0/-0; test LOC: +55/-47.

Testbox hydration run: https://github.com/openclaw/openclaw/actions/runs/31928815959

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 05:42
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head c42e966771c6a87fb3df86009643d1f0ac540ca0:

  • Controlled same-Testbox A/B on tbx_01m04g95378a8095c9gtat86j4, with one excluded warmup and two retained one-worker samples per state: wall 27.22s → 17.44s (-35.9%), summed Vitest 21.78s → 11.90s (-45.4%), and test body 13.23s → 3.42s (-74.2%). Imports, CPU, and peak RSS were effectively flat.
  • Focused owner/sibling proof: 32/32 tests passed across the Workshop list tool, collection reconciliation, and plugin lifecycle lease suites.
  • Full core changed gate passed on the retained Testbox, including assertion-safety, core-test typecheck, targeted lint, formatting, coercion, dependency, and boundary guards.
  • Mutation proof: changing proposal reconciliation back to Promise.all fails immediately with skill proposal reconciliations overlapped.
  • Real SQLite lease coverage remains: both list and inspect callers return OPENCLAW_STATE_LEASE_TIMEOUT through the production acquisition path.
  • Fresh post-rebase Codex autoreview found no accepted/actionable findings.
  • Exact-head CI is green: https://github.com/openclaw/openclaw/actions/runs/31929649302
  • Production LOC: +0/-0; test LOC: +55/-47.

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Aug 16, 2026
@steipete
steipete merged commit e495270 into main Aug 16, 2026
255 checks passed
@steipete
steipete deleted the perf/skill-workshop-contention-tests branch August 16, 2026 05:50
@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 1:49 AM ET / 05:49 UTC.

ClawSweeper review

What this changes

The PR replaces timing-based Skill Workshop contention tests with deterministic checks for serialized reconciliation and lease-timeout results.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer-labeled PR open for normal review: the test-only patch preserves the real lease boundary while replacing scheduler-dependent waits with deterministic assertions, and no blocking correctness or security issue was found.

Priority: P3
Reviewed head: c42e966771c6a87fb3df86009643d1f0ac540ca0

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused test-only patch with source-aligned deterministic assertions and no blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, test-only PR is outside the external-contributor real-behavior-proof gate; its body supplies Testbox validation context.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, test-only PR is outside the external-contributor real-behavior-proof gate; its body supplies Testbox validation context.
Evidence reviewed 6 items Serial reconciliation owner: The list operation iterates pending create proposals and awaits each reconciliation, so the proposed overlap-detecting factory protects the actual serialization invariant.
Lease timeout owner: Collection and proposal commit locks use the shared SQLite lease with a 5-second wait budget; the lease implementation samples its monotonic deadline before and after acquisition.
Changed list test: The branch replaces a 4.6-second held real lock with a mock factory that yields once while active, fails overlapping commit-lock entries, and verifies all 51 reconciliations completed.
Findings None None.
Security None None.

How this fits together

Skill Workshop lists and inspects proposed workspace skills, reconciling pending proposals under collection and target locks. The changed tests cover the tool-facing list path and the SQLite lease path that prevents reads from racing collection changes.

flowchart LR
  A[Workspace proposals] --> B[Skill Workshop list or inspect]
  B --> C[Pending proposal reconciliation]
  C --> D[Collection and target leases]
  D --> E[SQLite state]
  E --> F[Proposal result or timeout]
Loading

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch behind current main; refresh focused validation on the exact merge head before landing.
  • Complete next step (P2) - No repair is indicated; the maintainer-labeled PR needs ordinary human merge handling and an exact-head refresh if rebased.
Agent review details

Security

None.

PR surface

Tests +8. Total +8 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 55 47 +8
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 55 47 +8

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +55/-47 The patch changes only test timing and assertions, leaving runtime lease policy and Workshop behavior untouched.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the deterministic overlap factory and real SQLite timeout coverage, then refresh the branch and its focused Workshop validation against current main.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the deterministic overlap factory and real SQLite timeout coverage, then refresh the branch and its focused Workshop validation against current main.

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

Not applicable: this PR improves deterministic test execution rather than reporting a user-facing defect.

Is this the best way to solve the issue?

Yes. It tests list serialization at its reconciliation boundary while retaining the real SQLite lease path for timeout behavior; retaining wall-clock sleeps would be less reliable.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6aa27d6ecd8f.

Labels

Label changes:

  • add P3: This is a bounded test determinism and feedback-speed improvement with no production behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, test-only PR is outside the external-contributor real-behavior-proof gate; its body supplies Testbox validation context.

Label justifications:

  • P3: This is a bounded test determinism and feedback-speed improvement with no production behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, test-only PR is outside the external-contributor real-behavior-proof gate; its body supplies Testbox validation context.

Evidence

What I checked:

Likely related people:

  • steipete: Current-source blame attributes the reconciliation, lock, and adjacent test lines to Peter Steinberger; this PR also continues that area work. (role: recent area contributor; confidence: high; commits: 4b8ca98a940a, c42e966771c6; files: src/skills/workshop/service-query.ts, src/skills/workshop/target-lock.ts, src/agents/tools/skill-workshop-tool.list.test.ts)
  • Ziyang Guo: Commit 220b2dc introduced the manually-created proposal reconciliation behavior exercised by these tests. (role: feature introducer; confidence: medium; commits: 220b2dcec763; files: src/skills/workshop/service-query.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • If rebased, rerun the focused Workshop tests and changed gate on the exact resulting head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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