Skip to content

refactor: consolidate bounded concurrency on p-limit and p-map - #106002

Merged
steipete merged 23 commits into
mainfrom
codex/adopt-p-limit-p-map
Jul 13, 2026
Merged

steipete merged 23 commits into
mainfrom
codex/adopt-p-limit-p-map

Conversation

@steipete

@steipete steipete commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #105971

AI-assisted: yes. Codex implementation; repository autoreview workflow used before landing.

What Problem This Solves

Multiple core, package, plugin, and tooling paths independently implemented bounded-concurrency worker loops with subtly different scheduling and error behavior.

Why This Change Was Made

Uses p-limit and p-map at their owning dependency boundaries. Each call site keeps explicit stop-on-error or continue-on-error behavior. Specialized weighted, abort-aware, lifecycle, and early-stop schedulers remain custom because their contracts are not generic bounded mapping.

User Impact

No intentional user-visible behavior change. Embeddings, media uploads, model scanning, plugin workflows, and repository tooling retain ordering, progress, and error semantics with less bespoke concurrency code.

Evidence

  • Trusted AWS Crabbox run run_ac41f3b7eee1: all 77 shrinkwrap checks, SDK gates, full tsgo/lint, all 11 changed-test shards, and 6,273 tests passed.
  • Focused Blacksmith Testbox dead-code/export gate passed on lease tbx_01kxda4qy0kp9njfvexjbcp8ap (Actions run 29236252741).
  • Hosted Workflow Sanity passed at head c08206802c422e1449166d36f436479f1a56763f (run 29236595375).
  • Fresh whole-branch autoreview: clean at 0.93 confidence. Follow-up review of the five-line dead-code baseline repair: clean at 0.96 confidence.
  • git diff --check: passed.
  • LOC-negative closeout: 51 files, 612 additions, 782 deletions, net -170 lines.

The hosted CI run has four unrelated repository-global failures already present in the base: duplicate runNotStarted keys in 20 Control UI locale files affect prod/test types and lint, while Control UI export-baseline drift affects the dependency job. This PR changes no ui/** file. Per maintainer direction, those unrelated failures are not landing blockers; the concurrency proof above is green.

@steipete
steipete requested a review from a team as a code owner July 13, 2026 04:15
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: slack Channel integration: slack scripts Repository scripts commands Command implementations agents Agent runtime and tooling channel: qqbot extensions: qa-lab extensions: openshell size: XL maintainer Maintainer-authored PR labels Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • extensions/discord/npm-shrinkwrap.json
  • extensions/discord/package.json
  • extensions/openshell/npm-shrinkwrap.json
  • extensions/openshell/package.json
  • extensions/qa-lab/package.json
  • extensions/qqbot/npm-shrinkwrap.json
  • extensions/qqbot/package.json
  • extensions/slack/npm-shrinkwrap.json
  • extensions/slack/package.json
  • npm-shrinkwrap.json
  • package.json
  • packages/memory-host-sdk/package.json
  • pnpm-lock.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfile, shrinkwrap, or workspace dependency policy changes are present.
  • Treat package-lock.json and npm-shrinkwrap.json diffs as security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Jul 13, 2026
@github-actions

github-actions Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Dependency graph changes noted

This PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin or a member of @openclaw/openclaw-secops.

  • Current SHA: c08206802c422e1449166d36f436479f1a56763f
  • Trusted actor: @steipete
  • Trusted role: pull request author; openclaw-secops

Security review is still recommended before merge when the dependency graph change is intentional.

@steipete

steipete commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready proof for head c08206802c422e1449166d36f436479f1a56763f:

  • Trusted AWS Crabbox run_ac41f3b7eee1: 77 shrinkwrap checks, SDK gates, full tsgo/lint, 11 changed-test shards, and 6,273 tests passed.
  • Focused Blacksmith Testbox export-baseline gate passed: lease tbx_01kxda4qy0kp9njfvexjbcp8ap, Actions run 29236252741.
  • Hosted Workflow Sanity passed: run 29236595375.
  • Whole-branch autoreview clean at 0.93 confidence; focused baseline follow-up clean at 0.96.
  • git diff --check passed. Final diff: 51 files, 612 additions, 782 deletions, net -170 lines.

All four red core CI jobs are unrelated base failures. Prod/test types and lint report duplicate runNotStarted keys in 20 Control UI locale files; dependency checking reports Control UI export-baseline drift. This PR changes no ui/** file. Maintainer requested relaxed CI handling, so these base failures are recorded, not folded into this concurrency refactor.

@clawsweeper clawsweeper Bot added 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 13, 2026
@clawsweeper

clawsweeper Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 13, 2026, 4:38 AM ET / 08:38 UTC.

Summary
The PR replaces repeated bounded-concurrency worker loops across core, packages, plugins, and scripts with package-owned p-limit and p-map calls while retaining specialized schedulers.

PR surface: Source -145, Tests +2, Config +9, Other -31. Total -165 across 50 files.

Reproducibility: not applicable. This PR addresses duplicated maintenance infrastructure rather than a reproducible current-main user bug; correctness is evaluated through semantic comparison, tests, and live proof.

Review metrics: 1 noteworthy metric.

  • Direct concurrency dependencies: 2 pinned libraries across 7 manifests. Maintainers should confirm p-limit 7.3.0 and p-map 7.0.5 are intentionally owned at each root, package, and plugin boundary before accepting the expanded dependency graph.

Stored data model
Persistent data-model change detected: persistent cache schema: scripts/check-architecture-smells.mjs, persistent cache schema: scripts/lib/extension-import-boundary-checker.mjs, persistent cache schema: src/media-understanding/apply.ts, serialized state: scripts/check-architecture-smells.mjs, serialized state: scripts/check-temp-path-guardrails.ts, serialized state: scripts/lib/source-file-scan-cache.mjs, and 10 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #105971
Summary: This PR is the direct implementation candidate for the linked bounded-concurrency consolidation issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦪 silver shellfish
Patch quality: 🦞 diamond lobster
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted current-head live output for representative runtime and plugin paths, including observable success and failure behavior.
  • Resolve the failing check-dependencies job or document an exact current-main baseline comparison if it is unrelated.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR provides strong tests, CI, build, and Testbox evidence but no after-fix live user-path output; add redacted current-head terminal, log, or recording proof and update the PR body to trigger review, or ask a maintainer for @clawsweeper re-review if needed.

Risk before merge

  • [P1] No after-fix live scenario currently demonstrates that representative runtime and plugin paths preserve ordering, progress, partial-failure, and stop-on-error behavior outside tests and mocks.
  • [P1] The current head is newer than the posted Testbox transcript, so later API-surface and guard fixes have broad CI coverage but not refreshed real-behavior evidence.
  • [P1] The current check-dependencies job is failing, leaving the intentional dependency graph update without a fully green dependency-specific gate.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the owner-local p-limit and p-map design, then merge only after the dependency check is green and redacted current-head live output covers representative core and plugin workflows, including one success path and one failure-semantics path.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] The protected maintainer label, broad dependency refactor, missing live proof, and failing dependency check require human review rather than an automated repair PR.

Security
Cleared: The dependency changes use pinned p-limit and p-map releases with lockfile and shrinkwrap integrity updates and introduce no new permissions, secrets access, lifecycle hooks, or downloaded executable path.

Review details

Best possible solution:

Keep the owner-local p-limit and p-map design, then merge only after the dependency check is green and redacted current-head live output covers representative core and plugin workflows, including one success path and one failure-semantics path.

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

Not applicable: this PR addresses duplicated maintenance infrastructure rather than a reproducible current-main user bug; correctness is evaluated through semantic comparison, tests, and live proof.

Is this the best way to solve the issue?

Yes in architecture: established package-owned concurrency primitives are preferable to another bespoke shared helper, while specialized weighted, abort-aware, lifecycle, and early-stop schedulers correctly remain custom.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR provides strong tests, CI, build, and Testbox evidence but no after-fix live user-path output; add redacted current-head terminal, log, or recording proof and update the PR body to trigger review, or ask a maintainer for @clawsweeper re-review if needed.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P3: This is a maintenance-focused, behavior-preserving refactor with broad tests but no reported current user outage.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦪 silver shellfish and patch quality is 🦞 diamond lobster.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR provides strong tests, CI, build, and Testbox evidence but no after-fix live user-path output; add redacted current-head terminal, log, or recording proof and update the PR body to trigger review, or ask a maintainer for @clawsweeper re-review if needed.
Evidence reviewed

PR surface:

Source -145, Tests +2, Config +9, Other -31. Total -165 across 50 files.

View PR surface stats
Area Files Added Removed Net
Source 24 352 497 -145
Tests 5 52 50 +2
Docs 0 0 0 0
Config 7 10 1 +9
Generated 0 0 0 0
Other 14 198 229 -31
Total 50 612 777 -165

What I checked:

  • Owner-boundary implementation: The branch adds p-limit or p-map at each owning root, package, or plugin manifest and replaces local worker loops across core agents, sessions, media understanding, bundled plugins, the memory-host SDK, and repository scripts rather than introducing another cross-boundary helper. (package.json:2045, 9743c539d5a0)
  • Failure-contract repair: The memory-host path now has a dedicated helper and regression coverage preserving stop-admission and drain-in-flight behavior before propagating a write failure. (packages/memory-host-sdk/src/host/concurrency.ts:4, 9743c539d5a0)
  • Shared-helper semantics: The retained core helper uses p-limit while preserving ordered result slots, continue/stop error modes, first-error reporting, and completion of scheduled limiter promises. (src/utils/run-with-concurrency.ts:35, 9743c539d5a0)
  • Upstream dependency contract: p-map 7.0.5 preserves input-order results, bounds active mapper calls, stops further iterator admission after a stopOnError rejection, and permits already-started work to finish; p-limit 7.3.0 uses a FIFO queue and releases a slot after each task settles.
  • Automated validation: The PR reports focused Testbox coverage, changed tests, build, shrinkwrap checks, and autoreview at 4c1643d; current-head GitHub checks are broadly green, including build, shrinkwrap, platform, boundary, and security lanes. (9743c539d5a0)
  • Remaining proof gap: The supplied evidence is tests, builds, and CI rather than an after-fix live run of representative runtime or plugin behavior, and the strongest Testbox transcript predates the current head's later compatibility fixes and main merges. (9743c539d5a0)

Likely related people:

  • steipete: Beyond proposing the change, steipete authored the branch's compatibility and failure-semantics repairs, repeatedly refreshed it against main, and is identified by the dependency guard as a trusted openclaw-secops actor for this dependency graph change. (role: recent concurrency refactor contributor and security-review owner; confidence: high; commits: 6f84104787a6, 8fe9b3798fff, 4c1643d5cd1a; files: src/utils/run-with-concurrency.ts, packages/memory-host-sdk/src/host/concurrency.ts, package.json)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-13T05:02:43.462Z sha 4c1643d :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed 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 Jul 13, 2026
@steipete
steipete merged commit 1136757 into main Jul 13, 2026
102 of 109 checks passed
@steipete
steipete deleted the codex/adopt-p-limit-p-map branch July 13, 2026 08:53
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 14, 2026
…law#106002)

* refactor: adopt p-limit and p-map for bounded concurrency

* chore: normalize lockfile ordering

* fix: preserve memory host concurrency export

* refactor: keep media apply within size budget

* fix: drain memory concurrency before failure

* fix: satisfy memory concurrency guards

* chore: scope memory host dead-code checks

* chore: lower concurrency LOC baselines

* fix: preserve concurrency API surfaces

* chore: reconcile concurrency LOC baseline

* test: keep memory concurrency gate portable

* style: simplify concurrency drain

* ci: refresh deadcode export baseline
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord channel: qqbot channel: slack Channel integration: slack commands Command implementations dependencies-changed PR changes dependency-related files extensions: openshell extensions: qa-lab maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Consolidate bounded concurrency on p-limit and p-map

1 participant