Skip to content

fix(gateway): isolate cold placement results from later reads - #177489

Merged
steipete merged 1 commit into
mainfrom
deslop/z02-34-placement-results-20261015
Oct 19, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/z02-34-placement-results-20261015

Conversation

@steipete

@steipete steipete commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes later placement reads reporting caller-mutated metadata after a plugin modifies its first, cold placement result.

User Impact

SDK placement results remain independently mutable whether the reader is cold or warm. Modifying a returned agent ID or nested turn claim no longer changes the Gateway's retained placement facts. No migration or user action is required.

Why This Change Was Made

Cold reads published their worker records to the canonical replica and returned those same records to callers. Warm reads already detached their results. Apply that existing caller-owned result contract at the cold result adapter too, without copying internal inventories or changing publication, authority checks, persisted data, or public types.

Best-effort tradeoffs accepted

None: no guard is removed. The boundary copy preserves the existing mutable SDK contract; internal retained facts keep their current ownership and authority checks.

Net production LOC removed: 0 (one-line replacement). Tests: 42 net lines added, one regression in the existing reader suite. This is a real bug fix, not deletion-quota credit.

Evidence

  • Negative control on unchanged production: the real native store was persisted, closed, and reopened; the cold-cache precondition and initial record passed, then the post-mutation read failed with both caller-mutated fields. Case 2.005s; isolated wrapper 87.10s.

  • Independent complete-diff P0–P2 review: scoped-clean. No new API, schema, config, dependency, suppression, timeout, retry, skip, or protected memory-backend change.

  • Both complete focused reader/projection suites: 16 passed. The new regression passed in 2.920s; Vitest 183.90s / isolated wrapper 202.51s, including cached-worker preparation and verification.

  • Three-root native typecheck passed (8.51s); two-file type-aware lint passed (48.04s); formatting passed (25ms).

  • Required suppression audit: 13 passed / 1 unchanged baseline failure (20.83s wrapper): the allowlist expects 97 entries but finds 98, adding src/gateway/session-row-scope.ts | unicorn/no-new-array | 1. Both that file and the audit are byte-identical to this branch's fresh main base. The coordinator records this exact open scheduled-main signature in run 39270035500. No suppression or baseline is changed here; this local failure is not claimed fixed by later CI.

  • Exact-head hosted CI is the broad acceptance gate; no live operator Gateway or real user state is exercised locally.

Exact-head inherited CI exception

Run 39287247724 attempt 1 completed on this exact head: all selected executable suites and independent security passed. The sole executable failure is checks-fast-baseline-ratchets / 118178606331: an unrelated closed mock at src/infra/openclaw-process-census.missing-command.test.ts:12. The actual scanner reproduces the exact unallowlisted factory fingerprint on the unchanged CI baseline, tested merge and fresh main. Neither authored path is named. Aggregate 118188435164 depends only on that leaf. The complete 82-job/223-check census and failure table are retained in the landing evidence comment; CI is not called green.

The native exact-head workflow failed twice before merge dispatch: moving-main observation, then GitHub core API quota. The coordinator-authorized direct exact-SHA fallback applies after quota reset, with the same reviewed head, attributed failures and independent security clearance. No CI rerun, repair push, rebase or gate waiver is used.

@clawsweeper

clawsweeper Bot commented Oct 19, 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 October 19, 2026 16:39
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T16:41:43.604408Z 4ec8f63 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Oct 19, 2026
@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR copies cold placement results before returning them so caller mutations cannot change retained placement facts.

Example: A caller reads placement caller-owned-placement after reopening the database, then changes agentId to caller-mutated-agent and turnClaim.claimId to caller-mutated-claim.

  • Before: Later reads return the caller-mutated fields.
  • After: Later reads retain agentId main and claimId caller-owned-claim.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, source-supported repair with meaningful real-store regression coverage; supplied proof stops at the in-process owner boundary.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate does not apply under the supplied maintainer-authored classification; supporting evidence is a reported real-store cold-read regression, with no shipped Gateway or plugin execution supplied.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A plugin modifying its cold placement result can change the placement metadata returned by later Gateway reads.
Reason: This restores the existing caller-owned mutable-result contract with a narrow repair; the supplied maintainer-authored classification already establishes direction.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep open: this PR fixes a current-main object-aliasing bug with a focused change and a meaningful regression test; no introduced correctness or security defect was found.

Priority: P2
Reviewed head: 4ec8f6382bd0c2e239dcdb6da24a500599b62b05

Before merge

  • Complete next step - Determine the mock-exports failure in checks-fast-baseline-ratchets and either repair a demonstrated branch-caused defect or establish matching base evidence for the native inherited-failure path.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied verification exercises the real placement store in-process, but does not show the mutation scenario through a shipped Gateway or plugin entry point.
Agent review details

How this fits together

The placement reader loads session placement records through the database worker, publishes them to the Gateway's retained replica, and returns records to placement-store callers.

flowchart LR
  A[Placement caller] --> B[Placement read store]
  B --> C[Database worker]
  C --> D[Placement records]
  D --> E[Retained replica]
  D --> F[Caller result copy]
  F --> A
Loading

Technical review

Best possible solution:

Retain the boundary copy and regression test while preserving the existing replica, publication, and authority owners.

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

Current-main source directly exposes the aliasing path, and the PR reports a matching real-store negative control; this read-only review ran no target code.

Is this the best way to solve the issue?

The one-line cold-result copy is the smallest complete fix for getManyAsync and its getAsync consumer, matching existing warm-read behavior without copying internal inventories.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 0d955281f9f3.

Provenance checked

  • Cold placement result ownership keeps the original intent (8d86209: The earlier worker cutover retained committed placement facts for SQL-free reads and cloned warm results; the unchanged return expression began sharing retained records when cold publication was added.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit af18444 adds src/gateway/worker-environments/placement-read-store.ts:25 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: af18444df4ac; files: src/gateway/worker-environments/placement-read-store.ts)

PR surface

Source 0, Tests +42. Total +42 across 2 files. Added test files: 0.

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

Labels

Label changes:

  • add P2: Caller mutation can corrupt later in-process placement reads, but the demonstrated trigger is limited to mutable cold-read results.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Caller mutation can corrupt later in-process placement reads, but the demonstrated trigger is limited to mutable cold-read results.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 October 19, 2026, 12:56 PM ET / 16:56 UTC.

@steipete

Copy link
Copy Markdown
Contributor Author

Exact-head landing evidence for 4ec8f6382bd0c2e239dcdb6da24a500599b62b05, CI run 39287247724, attempt 1. CI remains failed; this requests the authorized inherited-only native exception, not a green label.

Failing job Attribution and proof
checks-fast-baseline-ratchets / 118178606331 Only failed subcheck is mock-exports: src/infra/openclaw-process-census.missing-command.test.ts:12 has a closed ./container-environment.js mock. That test, target, scanner, parser and maintained baseline are unchanged between actual CI baseline 02e11d67e643, tested merge e884cf874623, and fresh main f9842dcdff1f. A focused replay of the actual scanner on that single source reproduces the same unallowlisted factory fingerprint at all three revisions. Neither authored path is named by the failure.
openclaw/ci-gate / 118188435164 Aggregate explicitly reports only checks-baseline-ratchets failed; all selected executable suites completed successfully.

The inspected checkout is e884cf87462363d5250254cf542a710061624c91, with ordered parents 02e11d67e6434de3d8d116354eb3d166a5e0a2ca and this exact PR head. Its tree equals the independently reconstructed merge tree. Draft-era cancelled dispatch/context checks are superseded by the completed ready-head run, not missing executable-suite proof. Independent security clearance is retained.

Local proof: refined cold negative control failed at the intended top-level/nested alias assertion; the fix passes 16 tests across both complete owner suites, targeted native types, scoped lint and formatting. Independent P0–P2 review is scoped-clean. The separate local suppression audit remains honestly recorded as 13 passes / one unchanged session-row-scope allowlist failure, also present in scheduled main. No baseline, suppression, timeout, retry, skip, schema or protected memory-backend change. No CI rerun, repair push or rebase was used to obtain green.

@steipete
steipete merged commit a13e869 into main Oct 19, 2026
230 of 235 checks passed
@steipete
steipete deleted the deslop/z02-34-placement-results-20261015 branch October 19, 2026 17:06
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant