Skip to content

refactor(sessions): compare submitted inputs and recover dedupe through workers - #164313

Merged
steipete merged 3 commits into
mainfrom
dbasync/subdedupe
Oct 3, 2026
Merged

steipete merged 3 commits into
mainfrom
dbasync/subdedupe

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Chat retries without an in-memory identity, harness completion delivery, and recovered inbound deduplication still read submitted input through caller-thread SQLite.

User Impact

These durable reads move off the Gateway thread while preserving original submitted bytes, retry decisions, and current-owner recovery checks. No schema, stored-format, retention, durability, configuration, or update migration changes. Process-held incognito storage retains its existing owner.

Why This Change Was Made

Extend the existing pending-input operation family and history reader with bounded source reads. Capture the physical store before yielding, preserve original collected-source bytes, and refuse stale transcript projections without rebuilding them. Source bytes remain comparison evidence; the host owner still controls replay and single-use recovered dedupe.

Chat admission prepares fresh evidence under its existing lifecycle writer barrier, excluding only its own exact pending reservation from retry discovery. Completion delivery awaits the read and rechecks its requester. Accepted reads retain the existing reader lifecycle and cleanup.

This follows merged #164284. Main was merged without rebasing, preserving its Goal-preparation and abort-settlement fixes. Scope overlap with #156941 and design draft #162433 remains informational; neither is changed here.

Evidence

  • Full changed-check precondition passed (exit 0): node scripts/check-changed.mjs --staged --base d6c1b1f9e14aa06443c685d81414911628e18914 on the final candidate. The frozen workspace install restored the QA Lab dependency link. Core production types, all 27 core test type graphs, extension production/test types, lint, all three dead-export scans, SDK/package boundaries, SQLite and line-count ratchets, and the final guards passed. Existing max-lines warnings in unrelated voice-call and Crabbox files remain unchanged.
  • 233 cases passed across 12 files, covering chat retries, completion delivery, inbound recovery, pending-input storage, and the required shared-registry/import checks. Command: pnpm test <12 explicit files> --maxWorkers=1; wall time 887.26 s, including preparation.
  • After the integration corrections, 82 cases passed in chat-send-pending-inputs.test.ts, chat-send-pre-admission.test.ts, chat-send-admission.reads.test.ts, and delivery.custody.integration.test.ts. Command: pnpm test <these four files> --maxWorkers=1; wall time 463.94 s, including preparation. The exact-head CI run succeeded with zero failed/cancelled/timed-out jobs; aggregate job time was 9,343 seconds.
  • ClawSweeper identified three missed async integration assertions. The focused before-fix run reproduced expected Promise to be 'pending'; all three calls now await reconciliation, and the complete 21-case owning suite passes. The existing admission-failure response block moved to the existing work-admission module after main integration exceeded the line-count ratchet; the ratchet now passes.
  • Shared-registry proof includes test/scripts/runtime-process-build-graph.test.ts, src/auto-reply/reply/get-reply.imports.test.ts, and src/worker/worker.runtime-imports.test.ts: 14 passed. No new wrapper dependency-inventory entry is needed.
  • ClawSweeper re-review completed on 7861578a1dbbcc7efb626019f80dd773ddbd07db with no actionable findings. Codex autoreview through P2: scoped-clean on the final candidate. git diff --check passed. No new OPENCLAW_* names.
  • Released SDK check: latest local release tag v2026.9.8 already declares deliverAgentHarnessCompletion as returning Promise<AgentHarnessCompletionDelivery>. The changed synchronous helpers are internal, not exported through released SDK subpaths or api.runtime.*; no released signature changes or compatibility companion is required.

The longer suites retain real SQLite/worker custody fixtures because mocks cannot establish their source, transaction, and settlement boundaries. Existing other-owner metadata/authority reads remain follow-up debt: chat-send-work-admission.ts:85,92, the recovery commit guard at chat-send-pre-admission.ts:609, and agent-harness-completion-delivery.ts:34. Zero-SQL assertions cover the migrated submitted-source operations, not those surrounding owners or the separate cold completion-input guard.

…gh workers

Read bounded submitted sources through the existing history worker, preserve current-owner single-use recovery, and recheck retry evidence at admission. Keep the released asynchronous completion contract and document unchanged storage/update behavior.
@clawsweeper

clawsweeper Bot commented Oct 3, 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 agents Agent runtime and tooling size: XL labels Oct 3, 2026
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Base automatically changed from dbasync/pendstage to main October 3, 2026 13:14
@clawsweeper clawsweeper Bot added 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. labels Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 9:48 AM ET / 13:48 UTC (Revision 2).

ClawSweeper review

What this changes

Move stored-input comparisons and recovered inbound deduplication reads into database workers while preserving retry decisions and current-owner checks.

Merge readiness

✅ Ready for maintainer review

The worker migration remains necessary on current main. The previous missed-await finding is resolved, and this review found no remaining actionable patch defect.

Priority: P2
Reviewed head: 7861578a1dbbcc7efb626019f80dd773ddbd07db

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent worker migration with reported focused validation and the previous actionable finding resolved.
Proof confidence 🌊 off-meta tidepool Not applicable: The verified repository-admin author is exempt from the external-contributor proof gate. Captured evidence reports real SQLite/worker boundary coverage for retry comparison, completion refusal, and recovered dedupe; source inspection found retained current-owner guards. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The verified repository-admin author is exempt from the external-contributor proof gate. Captured evidence reports real SQLite/worker boundary coverage for retry comparison, completion refusal, and recovered dedupe; source inspection found retained current-owner guards. No stored-data contract changes.
Evidence reviewed 8 items Pinned introduction and clean checkout: Reviewed the introduced delta from d6c1b1f to the exact head. The checkout remains clean and the diff whitespace check passed. The supplied test merge is stale and was not used to infer removal of main behavior.
Current main still needs the read cutover: Current main still implements submitted-input lookup through caller-thread read-only SQLite. The merged prerequisite #164284 explicitly excludes submitted-input comparison and recovered dedupe; it does not supersede this work.
Previous finding resolved: All three completion-custody integration assertions now await reconciliation. The captured PR body reports the original Promise-versus-string failure and a passing complete owning suite after correction; tests were not executed during this read-only review.
Findings None None.
Security None None.

How this fits together

Session storage retains submitted messages used to recognize retries and recover interrupted input. Gateway chat admission, inbound dispatch, and harness completion delivery consume that evidence before deciding whether work may proceed.

flowchart TD
 A[Chat retries and recovered input] --> B[Capture physical session store]
 B --> C[Database history worker]
 D[Pending input and transcript] --> C
 C --> E[Original submitted evidence]
 E --> F[Current host owner checks]
 F --> G[Replay or admit work]
 F --> H[Reject stale or conflicting work]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +381, Tests +435, Docs +10. Total +826 across 30 files.

View PR surface stats
Area Files Added Removed Net
Source 19 669 288 +381
Tests 10 623 188 +435
Docs 1 12 2 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 30 1304 478 +826

Review metrics

Metric Value Why it matters
Production versus test growth Production net +381 lines; tests net +435 lines Production growth has a stated purpose: bounded worker source reads and asynchronous integration with existing owners.

Technical review

Best possible solution:

Keep bounded source reads in the existing history worker and leave replay, recovery, and final effects under their current host owners.

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

Not applicable to a standalone bug reproduction: current-main source establishes the synchronous reads being migrated, and this review did not execute target code.

Is this the best way to solve the issue?

Yes. Extending the existing worker owner preserves the source-comparison boundary without introducing another storage owner or changing the released asynchronous SDK contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • 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: The verified repository-admin author is exempt from the external-contributor proof gate. Captured evidence reports real SQLite/worker boundary coverage for retry comparison, completion refusal, and recovered dedupe; source inspection found retained current-owner guards. No stored-data contract changes.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded runtime storage improvement without evidence of an urgent user-facing outage.
  • 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: The verified repository-admin author is exempt from the external-contributor proof gate. Captured evidence reports real SQLite/worker boundary coverage for retry comparison, completion refusal, and recovered dedupe; source inspection found retained current-owner guards. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction and clean checkout: Reviewed the introduced delta from d6c1b1f to the exact head. The checkout remains clean and the diff whitespace check passed. The supplied test merge is stale and was not used to infer removal of main behavior. (7861578a1dbb)
  • Current main still needs the read cutover: Current main still implements submitted-input lookup through caller-thread read-only SQLite. The merged prerequisite refactor(sessions): stage and settle pending inputs in workers #164284 explicitly excludes submitted-input comparison and recovered dedupe; it does not supersede this work. (src/config/sessions/session-accessor.pending-inputs.ts:515, bee5d85d423c)
  • Previous finding resolved: All three completion-custody integration assertions now await reconciliation. The captured PR body reports the original Promise-versus-string failure and a passing complete owning suite after correction; tests were not executed during this read-only review. (src/agents/command/delivery.custody.integration.test.ts:418, 7861578a1dbb)
  • Recovered dedupe retains live custody: The consuming callback revalidates the captured owner, current async context, lifecycle, physical path, exact source row, consumption state, and single-use recovery before replacing inbound dedupe. A changed test covers revocation after the worker read. (src/config/sessions/session-accessor.sqlite-pending-inputs.ts:414, 7861578a1dbb)
  • Completion and retry checks survive worker waits: Completion delivery rechecks requester identity after awaited reconciliation. Chat admission prepares fresh comparison evidence inside its existing lifecycle writer barrier and refuses conflicting or unavailable evidence before registering work. (src/plugin-sdk/agent-harness-completion.ts:146, 7861578a1dbb)
  • Released SDK remains asynchronous: GitHub source at v2026.9.8 declares deliverAgentHarnessCompletion as returning Promise<AgentHarnessCompletionDelivery>. The patch changes its internal reconciliation await without adding or breaking a released SDK signature. The introduced delta contains no schema or serialized-format change. (src/plugin-sdk/agent-harness-completion.ts:72, fc23bc864e45)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • joshavant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-03T13:19:31.425Z sha 281c696 :: needs changes before merge. :: [P2] Await the reconciler in the remaining integration assertions

Merge main after the pending-input staging prerequisite landed, preserving its Goal preparation and abort settlement fixes. Await the remaining completion-custody integration assertions, and keep admission failure responses in the existing work-admission owner.
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. and removed 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. labels Oct 3, 2026
@steipete
steipete merged commit 5e1ffe9 into main Oct 3, 2026
149 of 151 checks passed
@steipete
steipete deleted the dbasync/subdedupe branch October 3, 2026 14:07
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…gh workers (openclaw#164313)

* refactor(sessions): stage and settle pending inputs in workers

* refactor(sessions): compare submitted inputs and recover dedupe through workers

Read bounded submitted sources through the existing history worker, preserve current-owner single-use recovery, and recheck retry evidence at admission. Keep the released asynchronous completion contract and document unchanged storage/update behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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