Skip to content

refactor: reuse activated worker placement facts - #169086

Merged
steipete merged 2 commits into
mainfrom
dbasync/sdkasync
Oct 11, 2026
Merged

steipete merged 2 commits into
mainfrom
dbasync/sdkasync

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Worker activation rereads the placement it just committed before notifying Gateway maintenance, adding a synchronous SQLite read to the activation path.

User Impact

No intended user-visible change. Activation notifications use the committed active placement. External plugins retain the released synchronous placement readers, now deprecated in favor of their existing async counterparts.

Why This Change Was Made

The placement owner passes its committed row through onActivated; Gateway maintenance consumes that fact instead of calling placements.get() and repeating the active-state check. The real execution/placement authority guards remain at their effect boundaries.

Accepted edge case: maintenance may consume a committed activation after a later placement transition; the maintenance operation retains its existing effect-boundary authority checks. No generation or freshness handshake is added.

This is the placement slice of the SDK async migration. Synchronous placement get, getMany, list, and listForReconcile remain only for released compatibility and existing security/recovery callers, emit the SDK migration warning, and point to the async methods. The recovery constructor's initial census needs a separate lifecycle-owner change because delaying it would alter interrupted-claim classification.

Evidence

Three alternating base/candidate pairs on the same isolated host, using the shared SQL harness, base 95e0638a1046051eb09cfd23e452a00c095a2bbe, and placement head e2fe26ea78bca0ee9a13da2942081c0404dc6cc7:

Warmed metric Base median [min–max] Candidate median [min–max]
All-thread SQL statements / turn 356.6 [355.3–356.8] 357.4 [356.6–357.6]
Worker requests / turn 91.7 [90.9–91.7] 91.7 [91.6–92.0]
MAIN SQL statements / turn 1.0 [1.0–1.0] 1.0 [1.0–1.0]

The +0.224% warmed statement variation is below the 0.5% noise floor and comes from unchanged actor completion/shared-facts and startup work. Whole-workload median: 10,163→10,171 statements, 1,728→1,732 requests. First-turn statements: 1,260→1,266 (+0.476%), from deferred startup work. The boot + connect + first-turn combined median falls 4,243→4,237 statements (−6) with 303→303 requests; the three combined statement samples are base [4,230, 4,243, 4,259] and candidate [4,237, 4,210, 4,257]. This applies the deferred-startup combined-window rule; no placement activation runs in these phases. Warmed duration ratio: 1.0085. The chat workload does not activate placements, so it demonstrates neutrality, not a placement saving.

Per activation: one fewer SELECT, no added worker request. Placement-store lexical T1 inventory: 2→2, because released sync adapters and real effect/recovery guards remain; this PR does not claim lexical T1 elimination.

Focused remote proof passed: provisioning replay, placement store, SDK placement compatibility, recovery events, startup maintenance, and runtime API guardrails (six files, 78 seconds). The replay regression checks that the activation callback receives the persisted active placement.

The final head 533f30e7ae5e8dcd4c11ad2b453eb48ac7c7eccd merges main cb2a3ce3dda69bd6781411bb0b13ec7b9486b08f to pick up already-landed Knip fixes. The merge had no conflicts and preserves the same seven-file placement delta (+53/−12), so the focused and SQL proof above is reused. Static checks were rerun on the final head.

Codex autoreview: clean (one round). Formatting and diff checks passed. Remote check:changed, Madge, SDK surface, SDK API comparison, and inventory/dialect ratchets passed apart from inherited Knip findings. Final-head type-aware oxlint (22s), export-collision checks (30s), SDK surface (6s), and runtime API guardrails (24s) passed. Final-head Knip (98s) reports exactly the same 58 rule/file/symbol findings as main cb2a3ce3dda69bd6781411bb0b13ec7b9486b08f: zero candidate-only and zero main-only findings. The SDK API comparison adds/removes no entrypoints. No schema, migration, updater, plugin loading, or service-lifecycle contract change; no update cell required.

LOC: 7 files, +53/−12. Release-note context: plugin placement readers are deprecated in favor of worker-backed async readers; bundled activation maintenance no longer rereads its committed placement.

Pass the committed active placement to maintenance scheduling and remove its native reread. Deprecate remaining synchronous placement readers in favor of existing worker operations; preserve final effect guards and released compatibility.
@clawsweeper

clawsweeper Bot commented Oct 11, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Oct 11, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR passes the committed active placement to maintenance scheduling and adds deprecation warnings to synchronous placement readers.

Example: A plugin calls workerSessionPlacementService.get("session-42").

  • Before: The current placement returns synchronously without a reader deprecation warning.
  • After: The same synchronous result remains available, with a bounded warning recommending getAsync.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and preserves authority and compatibility; supplied changed-path coverage is an in-process harness rather than shipped-entry-point proof.
Proof confidence 🦐 gold shrimp (3/6) The task identifies this as maintainer-authored, outside the ordinary contributor proof gate; inspected replay coverage exercises activation through real placement owners with mocked transport, and the reported chat benchmark establishes neutrality rather than activation coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Worker activation performs an unnecessary synchronous database read before scheduling maintenance.
Reason: The existing feature owner removes identifiable Gateway-thread work and explicitly accepts the scheduling tradeoff while preserving compatibility.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: the maintainer-authored refactor removes a redundant activation read while preserving current authority checks and released synchronous contracts; no actionable defect was found.

Priority: P3
Reviewed head: 533f30e7ae5e8dcd4c11ad2b453eb48ac7c7eccd

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The replay assertion covers committed-row delivery, but supplied evidence does not exercise activation-to-maintenance through a shipped entry point or record a base-failing regression run.
Agent review details

How this fits together

Placement dispatch commits worker activation and notifies node workspace maintenance, which prepares current placement facts and validates authority before sending retention commands.

flowchart TD
  A[Placement dispatch] --> B[Placement worker commit]
  B --> C[Committed active placement]
  C --> D[Activation callback]
  D --> E[Maintenance coordinator]
  E --> F[Current placement and node checks]
  F --> G[Node retention command]
Loading

Technical review

Best possible solution:

Reuse the committed activation result for scheduling while retaining maintenance authority checks and the released synchronous SDK compatibility window.

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

Current-main source directly establishes the redundant activation read; this is an internal refactor rather than a reported runtime failure.

Is this the best way to solve the issue?

Passing the existing owner's committed result removes the redundant read without introducing a cache, worker request, or competing authority owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 961bd6b16773.

Provenance checked

  • Activation maintenance scheduling changes intended behavior with a stated reason (8a1ff39: Schedule maintenance for the attached cloud or paired-node environment matching the active placement owner.)
  • Synchronous placement readers keeps the original intent (e98c7df: Provide durable placement reads; later worker migrations preserve the released synchronous contracts.)
  • SDK migration diagnostics keeps the original intent (d9eba8a: Use bounded migration warnings while retaining synchronous signatures and completion semantics.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 8a1ff39 adds src/gateway/server-worker-placement-startup.ts:400 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8a1ff3966b7e; files: src/gateway/server-worker-placement-startup.ts)

PR surface

Source +29, Tests +5, Docs +7. Total +41 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 38 9 +29
Tests 1 6 1 +5
Docs 1 9 2 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 53 12 +41

Review metrics

Metric Value Why it matters
Production versus test LOC Production +38/-9; tests +6/-1 Production growth primarily adds bounded compatibility warnings; the regression extends an existing replay fixture.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a focused internal optimization and SDK migration diagnostic change with no intended execution behavior change.
  • merge-risk: 🚨 compatibility: Released plugin readers gain deprecation diagnostics; the maintainer-authored direction retains their signatures, results, timing, and compatibility window.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-11T12:02:54.679Z sha e2fe26e :: needs maintainer review before merge. :: none

Reviewed October 11, 2026, 9:25 AM ET / 13:25 UTC (Revision 2).

@steipete
steipete merged commit 5fac9ea into main Oct 11, 2026
126 checks passed
@steipete
steipete deleted the dbasync/sdkasync branch October 11, 2026 13:32
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
Pass the placement owner's committed active row to Gateway maintenance instead of rereading SQLite and repeating the active-state check after activation.

Deprecate synchronous placement readers in favor of their existing worker-backed async counterparts while preserving released SDK compatibility and real effect/recovery authority checks.

Accepted edge case: maintenance can consume a committed activation after a later placement transition; existing effect-boundary checks remain authoritative.

Proof: focused owner/compatibility tests, one clean Codex review, three alternating SQL measurement pairs, static checks, SDK API comparison, and unchanged T1/dialect ratchets. One fewer SELECT per placement activation, no added worker request; warmed chat workload remains within noise.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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