Skip to content

fix(delivery): keep failed queue rows payload-free - #123642

Merged
steipete merged 4 commits into
mainfrom
steipete/simplify-delivery-failure-lifecycle
Aug 14, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/simplify-delivery-failure-lifecycle

Conversation

@steipete

@steipete steipete commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Related: #123409
Follow-up to #123410

AI-assisted.

What Problem This Solves

#123410 repaired the privacy issue where failed delivery rows could retain sensitive payloads indefinitely, but it also introduced an unshipped general failure-operations subsystem far larger than the invariant required. This follow-up keeps the privacy and idempotency repair while removing that operator platform and the connected duplicate policy.

Why This Change Was Made

The lifecycle now follows the existing owner boundaries: ordinary ownerless failures are deleted; stable-ID and crash-ambiguous producers retain only minimal payload-free receipts using existing completion-retention metadata; canonical task and subagent state owns retries; existing startup and hourly queue maintenance performs physical age expiry; health remains coarse and read-only; and media leases span terminal provider cleanup. The removed list, purge, and resubmit CLI/RPC surfaces, rich health API, and two-phase journal were never released. SQLite schema version remains 7 and Gateway protocol version remains 4.

User Impact

Failed outbound and session rows no longer retain message bodies, destinations, session context, or provider errors indefinitely. Ordinary failures leave no permanent receipt, while reusable or crash-ambiguous IDs remain fenced against duplicate sends. No newly shipped CLI or API is removed because the deleted surface never reached a release.

Evidence

  • Focused SQLite, terminal-outcome, namespace, outbound/session, subagent/restart, migration, and media suites passed; the final queue-maintenance slice passed 39/39, and the state DB suite passed 146 tests with 1 skipped.
  • pnpm build passed.
  • node scripts/check-changed.mjs passed every selected lane.
  • pnpm docs:list, targeted oxfmt, and git diff --check passed.
  • Final autoreview was clean after two chunked passes; all accepted independent-review findings were resolved.
  • Current-main integration proof passed: node --import tsx scripts/check-madge-import-cycles.ts, node --import tsx scripts/check-kysely-guardrails.mts, and node scripts/run-vitest.mjs src/gateway/server-methods/server-methods.test.ts (212/212).
  • Hosted exact-head CI run 31801311752 passed on 0d6ec1588edc1009a6af930ffd98234773617e55.
  • A 20,000-row missing-ID receipt lookup averaged 0.1349 ms; the read-only health count completed in 1.7–3 ms.
  • Fixed-base production LOC for this follow-up is +873/-4121 (net -3248). Combined with fix(delivery): bound failed-row retention and recovery #123410's +3241 production LOC, the cumulative production delta is -7. The current-main integration adds four net production-source comment/import lines, one tooling allowlist line, and a test-only fixture replacement; tests, docs, generated artifacts, and tooling are classified separately.
  • No local Testbox lease or run existed because the remote provider was unavailable, so the documented trusted-source local fallback was used; hosted exact-head CI supplies the landing gate.

Replace the unshipped failure-operations platform with payload-free terminal receipts owned by existing queue boundaries. Keep bounded/permanent idempotency only for reusable or crash-ambiguous producers, move physical expiry to queue maintenance, and preserve migration and media-cleanup safety.\n\nTogether with #123410, production code is net negative by 11 lines; tests, docs, and generated protocol mirrors are accounted separately.
@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 14, 2026 12:11
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: android App: android app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 14, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. 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 Aug 14, 2026
@clawsweeper

clawsweeper Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 8:46 AM ET / 12:46 UTC.

ClawSweeper review

What this changes

The PR removes the unreleased delivery-failure CLI and Gateway API, replacing retained failed delivery rows with payload-free receipts only where recovery or duplicate-send fencing needs one.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep open for maintainer review: the maintainer-authored, protected PR changes durable delivery state, while this checkout cannot materialize the exact head for independent migration and exact-CI verification.

Priority: P1
Reviewed head: 0d6ec1588edc1009a6af930ffd98234773617e55
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The supplied patch direction matches the current ownership model, but exact-head source, migration proof, and CI remain unavailable to this review environment.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository state identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; exact-head upgrade evidence remains a merge requirement.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository state identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; exact-head upgrade evidence remains a merge requirement.
Evidence reviewed 5 items Current failed-row owner: Current main persists a failed row through a terminal-policy transition; the proposed refactor replaces this retention model at its lifecycle owner.
Migration contract coverage: Current migration coverage imports legacy failed outbound and session rows, including their stored metadata and terminal behavior.
Feature provenance: The broader failed-row lifecycle originated in the merged related change; its commit is dated after the latest release tag.
Findings None None.
Security Needs attention Verify payload removal on the exact migration path: A failed-row migration must be observed on the exact head to confirm it clears payload-bearing fields without weakening required delivery ownership or cleanup.

How this fits together

Outbound and session delivery queues persist work in the shared SQLite state database, then recovery either sends, retries, or terminalizes each row. This PR changes terminal retention and removes the temporary operator API around failed rows.

flowchart LR
A[Outbound or session work] --> B[Durable queue record]
B --> C[Send and recovery]
C --> D{Terminal outcome}
D -->|ordinary failure| E[Delete payload-bearing row]
D -->|stable or ambiguous ID| F[Payload-free receipt]
F --> G[Restart and duplicate-send fence]
E --> H[Queue maintenance]
Loading

Decision needed

Question Recommendation
Is the exact-head upgrade and recovery evidence sufficient to merge this durable-state simplification? Require exact-head upgrade proof: Run the legacy failed-row migration and recovery scenario on the PR head, showing payload removal while required receipts and cleanup remain correct.

Why: The protected maintainer PR changes persisted delivery behavior, but the review environment could not inspect its exact source revision or run its focused migration path.

Before merge

  • Resolve security concern: Verify payload removal on the exact migration path - A failed-row migration must be observed on the exact head to confirm it clears payload-bearing fields without weakening required delivery ownership or cleanup.
  • Resolve merge risk (P1) - The exact PR head could not be materialized locally, so this review cannot independently prove that legacy failed rows are compacted without losing required duplicate-send fences or media cleanup.
  • Resolve merge risk (P1) - Exact-head CI is still incomplete for a change that removes protocol registrations and rewrites persisted queue-state handling.
  • Complete next step (P2) - Protected maintainer work needs exact-head migration and CI evidence rather than an automated repair lane.

Findings

  • [medium] Verify payload removal on the exact migration path
Agent review details

Security

Needs attention: The patch targets sensitive-data retention, but exact-head source and migration behavior could not be independently inspected in this environment.

Review metrics

Metric Value Why it matters
Production delta (PR-reported) production +862/-4,114 (net -3,252); tests not independently countable The stated net reduction supports the removal of duplicate failure-policy machinery, but the exact head was unavailable for independent diff accounting.

Stored data model

Persistent data-model change detected: database schema: packages/gateway-protocol/src/schema/delivery-failures.test.ts, migration/backfill/repair: docs/cli/doctor.md, migration/backfill/repair: scripts/check-kysely-guardrails.mts, migration/backfill/repair: src/commands/doctor-delivery-failures.test.ts, migration/backfill/repair: src/commands/doctor-delivery-failures.ts, migration/backfill/repair: src/infra/outbound/delivery-queue-migration.ts, and 31 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: partial_overlap
Canonical: #123410
Summary: This PR narrows the broader lifecycle introduced by the merged predecessor while retaining the same failed-row privacy objective.

Members:

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

Merge-risk options

Maintainer options:

  1. Verify the upgrade boundary (recommended)
    Require an exact-head legacy-row migration and recovery trace before merge because the change rewrites retained delivery state.
  2. Pause pending proof
    Hold the PR until the exact head can be inspected and its required CI completes if the migration scenario cannot be shown.

Technical review

Best possible solution:

Merge only after exact-head migration proof demonstrates payload removal, retained-id fencing, and media cleanup for preexisting failed rows.

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

No exact-head reproduction was possible: the PR commit is absent from the checkout and GitHub DNS resolution failed. Current migration fixtures provide a focused legacy failed-row scenario once that head is available.

Is this the best way to solve the issue?

Unclear: collapsing the unreleased operations layer fits the repository’s preference for one owner-boundary flow, but exact-head migration and recovery proof is still required.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: This changes recovery for durable outbound and session delivery rows, including a privacy-sensitive failure path.
  • merge-risk: 🚨 compatibility: The PR removes an unreleased CLI and Gateway protocol surface while changing the upgrade behavior for stored rows.
  • merge-risk: 🚨 session-state: Session delivery and subagent completion recovery use the changed terminal-row lifecycle.
  • merge-risk: 🚨 security-boundary: The intended invariant is that failed rows no longer retain sensitive payload, route, session, or provider-error detail.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The repository state identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; exact-head upgrade evidence remains a merge requirement.

Evidence

Security concerns:

  • [medium] Verify payload removal on the exact migration path
    A failed-row migration must be observed on the exact head to confirm it clears payload-bearing fields without weakening required delivery ownership or cleanup.
    Confidence: 0.9

What I checked:

  • Current failed-row owner: Current main persists a failed row through a terminal-policy transition; the proposed refactor replaces this retention model at its lifecycle owner. (src/infra/delivery-queue-sqlite.ts:586, 44dd983c0c37)
  • Migration contract coverage: Current migration coverage imports legacy failed outbound and session rows, including their stored metadata and terminal behavior. (src/infra/state-migrations.test.ts:2247, 44dd983c0c37)
  • Feature provenance: The broader failed-row lifecycle originated in the merged related change; its commit is dated after the latest release tag. (src/infra/delivery-queue-sqlite.ts:586, 7026cf2f21de)
  • Release check: The latest supplied release tag predates the related lifecycle commit, so the removed CLI and protocol surface is not a shipped release contract. (0790d9f593ad)
  • Exact-head inspection gap: The requested PR head is absent from the partial clone; Git attempted the promisor remote but DNS could not resolve GitHub, so exact-head source and tests were not independently inspectable. (0d6ec1588edc)

Likely related people:

  • steipete: The related merged lifecycle commit and current-area blame connect this person to the queue retention and migration boundary. (role: recent delivery-lifecycle contributor; confidence: high; commits: 7026cf2f21de; files: src/infra/delivery-queue-sqlite.ts, src/infra/state-migrations.storage.ts, src/state/openclaw-state-db-legacy-backfills.ts)

Rank-up moves

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

  • Make the exact head available for inspection and complete its required CI.
  • Capture a redacted legacy failed-row upgrade trace that proves payload removal, duplicate-send fencing, and media cleanup.

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 (2 earlier review cycles)
  • reviewed 2026-08-14T12:22:08.612Z sha 1da0ae4 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-14T12:31:40.308Z sha 625aa50 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 14, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for 0d6ec1588edc1009a6af930ffd98234773617e55:

  • Hosted exact-head CI passed: run 31801311752. Native prepare accepted it in hosted_exact_or_recent_parent mode and verified the remote PR tree matches the prepared head.
  • Exact current-main integration commands passed: node --import tsx scripts/check-madge-import-cycles.ts; node --import tsx scripts/check-kysely-guardrails.mts; node scripts/run-vitest.mjs src/gateway/server-methods/server-methods.test.ts (212/212); targeted oxfmt --check; and git diff --check.
  • Earlier full branch proof passed pnpm build, node scripts/check-changed.mjs, pnpm docs:list, and the focused SQLite/terminal/namespace/outbound/session/subagent/restart/migration/media families recorded in the PR body (queue maintenance 39/39; state DB 146 passed, 1 skipped). Final autoreviews were clean.
  • Fixed-base production LOC is +873/-4121 (net -3248); combined with fix(delivery): bound failed-row retention and recovery #123410's +3241, cumulative production LOC is -7. Tests, docs, generated artifacts, and the one-line tooling allowlist are separate.
  • SQLite schema remains 7. Gateway protocol remains 4. Removed CLI/RPC/generated surfaces were never released.
  • ClawSweeper reported no code findings. Its exact-head CI rank-up move is complete. The optional redacted upgrade/media trace was not attached because no local Testbox executable/provider lease or run existed; the documented trusted-source local fallback and hosted exact-head CI were used, and no live Testbox proof is claimed.

Ready to land.

@steipete
steipete merged commit ad6bc6d into main Aug 14, 2026
184 checks passed
@steipete
steipete deleted the steipete/simplify-delivery-failure-lifecycle branch August 14, 2026 13:22
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Aug 14, 2026
server-maintenance.test.ts crossed the 1000-counted-line test cap when
#123642 added payload-retention coverage, failing check-lint-core-2 on
every merge-ref CI run. Move the dedupe TTL/overflow block into a themed
sibling; module mocks are hoisted per file so the mock preamble is
repeated while fixtures stay local. Test parity 41 = 41.
steipete added a commit that referenced this pull request Aug 14, 2026
… file) (#123794)

* chore(cli): drop unused resolveClawHubTargetWorkspaceDir

#116489 migrated its last callers to resolveClawHubTargetWorkspace but left
the wrapper, failing check-prod-types (TS6133) on every merge-ref CI run.

* test: split dedupe maintenance suite below the max-lines cap

server-maintenance.test.ts crossed the 1000-counted-line test cap when
#123642 added payload-retention coverage, failing check-lint-core-2 on
every merge-ref CI run. Move the dedupe TTL/overflow block into a themed
sibling; module mocks are hoisted per file so the mock preamble is
repeated while fixtures stay local. Test parity 41 = 41.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
* refactor(delivery): collapse failed-row lifecycle

Replace the unshipped failure-operations platform with payload-free terminal receipts owned by existing queue boundaries. Keep bounded/permanent idempotency only for reusable or crash-ambiguous producers, move physical expiry to queue maintenance, and preserve migration and media-cleanup safety.\n\nTogether with openclaw#123410, production code is net negative by 11 lines; tests, docs, and generated protocol mirrors are accounted separately.

* fix(delivery): break state DB import cycle

* fix(delivery): classify SQLite boundary uses

* test(gateway): mark retained health fixture
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
… file) (openclaw#123794)

* chore(cli): drop unused resolveClawHubTargetWorkspaceDir

openclaw#116489 migrated its last callers to resolveClawHubTargetWorkspace but left
the wrapper, failing check-prod-types (TS6133) on every merge-ref CI run.

* test: split dedupe maintenance suite below the max-lines cap

server-maintenance.test.ts crossed the 1000-counted-line test cap when
openclaw#123642 added payload-retention coverage, failing check-lint-core-2 on
every merge-ref CI run. Move the dedupe TTL/overflow block into a themed
sibling; module mocks are hoisted per file so the mock preamble is
repeated while fixtures stay local. Test parity 41 = 41.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: android App: android app: web-ui App: web-ui cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL 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