Skip to content

chore(sessions): add bounded delivery generation refusal diagnostics - #196724

Merged
fuller-stack-dev merged 8 commits into
mainfrom
openclaw/delivery-generation-recovery-fix
Nov 10, 2026
Merged

fuller-stack-dev merged 8 commits into
mainfrom
openclaw/delivery-generation-recovery-fix

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Why

Identify the first delivery-generation refusal without exposing session content in the diagnostic payload. The missing first-refusal and invalidating-producer link prevents a causal fix. This diagnostic-only change is not a verified incident fix; the historical root cause remains unknown.

What changed

  • Record the first unavailable refusal per file lease with one of 22 branch tags, existing state flags, and the first relevant state change.
  • Keep diagnostics in the existing lease owner and one sibling helper. Project at most four vetted, root-relative source positions into a closed diagnostic payload of at most 1,024 bytes.
  • Preserve error identity, code, message and cause, callback multiplicity and ordering, genuine REVOKED behavior, and normal release semantics. Diagnose prepare failures before cleanup changes the observed state.
  • Reuse the existing ASCII-control predicate for raw and decoded positions, retaining C0/DEL rejection and the separate decoded-space check. Test transport values use the existing record-coercion boundary; exact-key expectations retain locale-independent ordering.

Scope

  • Two production files, one test file, and one test-line allocation. The producer remains explicitly unknown; the observed invalidation call chain does not identify its origin.
  • Excludes two pre-lease guards, the optional callback reason, and the memory backend. No SQL or publication tracing, runtime guard/limit changes, or new runtime configuration.
  • The diagnostic payload contains no session IDs, error messages, causes, raw scopes, or raw stacks. The 1,024-byte bound and privacy projection apply to that payload, not the normal tslog envelope: existing logger _meta can include a hostname and absolute logger callsite, and complete log lines can exceed 1,024 bytes. This change does not alter logger-envelope collection or egress redaction.

Tradeoffs

Bounded, best-effort evidence can distinguish refusal paths without process-wide deduplication or producer tracing. It does not establish historical causality, and accepted positions can contain only observer frames.

Blast Radius

File-backed session-generation leases gain a one-shot diagnostic warning and bounded state-change capture. Logging or capture failures do not replace the original refusal; normal release and genuine generation revocation do not emit this warning.

Verification

  • Exact-head CI run 42869355624 on 68e4f7d7db88970019a8b097d4dae88b8748e56d completed successfully: 36 jobs passed, 27 conditionally skipped, none failed or pending. Core lint, all five core test-type stripes, production types, source contracts, changed-node lanes, build artifacts with generated-asset and CLI smoke checks, and all three PostgreSQL conformance shards passed. The aggregate CI check and applicable dependency/security-review statuses also passed.
  • The same run passed all 34 affected tests under Bun: diagnostics 11, native 19, registry 4. Coverage includes raw and encoded bytes 0–32 and DEL rejected, C1 retained, exact four-frame expectations, payload privacy bounds, logger/capture failures, error identity/cause, cleanup ordering, callback counts, and real lease revocation. The whole test file was audited without removing distinct assertions.
  • The regression allocation is exactly 393 lines, justified by the diagnostic test file; the obsolete inherited-debt credit was removed. Actual CI job 130017200797 passed the unchanged checker at comparison base cd6abdb94c5eae55c2e676a0309497ec1b3382df and merge 95c157d0c75bb815b73a753bd2eb18962ef5dcb6: 6,633,622 lines, ceiling 6,633,649, 27 slack. The shared baseline and checker are unchanged. The allocation-only update leaves all production and test bytes identical to dd12d9a18b3e1bac31bd9446eca4cc605e14771e.
  • Prior local targeted type-aware lint passed with 293 rules and zero warnings/errors; formatting, whitespace, normal commit hooks, and the staged line-cap guard passed. The unchanged lease owner remains 691 counted lines against its 700-line cap. No runtime suites were rerun locally for the allocation-only update.
  • Independent narrow API, security, privacy, and test-quality review was accepted and freshly bound to the final allocation-only head. Hosted review 42872921671, revision 4, also reviewed that exact head and found no actionable defect. Earlier paired API/privacy evidence and later projector/sink verification retain their original revision labels; they are not historical incident reproduction. The earlier broad API review timeout remains historical, not a passing verdict.
  • Skipped lanes are not passes. The Windows-positive fixture uses native absolute paths and pathToFileURL; Node's Windows conversion control rejects the original drive-less URL and round-trips corrected paths, but the current Windows suite was skipped. CodeQL's aggregate annotation is neutral because 17 main-branch configurations were absent; the selected CodeQL workflows completed successfully, without establishing full configuration coverage. The standalone focused type attempt remains blocked before analysis by canonical dependency containment; passing hosted types do not retroactively make that attempt pass. Full declaration qualification remains incomplete. No shipped Gateway refusal trace or historical-incident reproduction is claimed.

@clawsweeper

clawsweeper Bot commented Nov 10, 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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:feature Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR records one bounded diagnostic warning for the first unavailable refusal of each file-backed session-generation lease.

Example: A row invalidation causes two consecutive assertions on the same lease to fail.

  • Before: Both assertions throw SESSION_DELIVERY_GENERATION_UNAVAILABLE without identifying the refusal branch.
  • After: Both assertions retain that error, while one diagnostic identifies active-invalidated and row-invalidated, with at most four source positions.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused instrumentation with meaningful owner-level coverage and no actionable finding; proof remains in-process.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence covers real lease/database operations in-process and explicitly limits privacy and byte bounds to the diagnostic payload rather than the logger envelope.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Maintenance · Worth it: Yes · Fix scope: Complete
User problem: Unavailable session-generation refusals lack enough bounded context to distinguish the failing branch and observed invalidation chain.
Reason: The maintainer-authored direction adds useful diagnostic evidence while explicitly preserving authority behavior and acknowledging that producer attribution remains unknown.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: the bounded diagnostics are useful, and review found no actionable defect in the introduced diff.

Priority: P3
Reviewed head: 68e4f7d7db88970019a8b097d4dae88b8748e56d

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Coverage exercises production leases in-process; no shipped Gateway refusal trace or historical-incident reproduction is claimed.
Agent review details

How this fits together

The session-generation owner checks retained session authority before delivery and file effects; this change projects its refusal state into the existing logger without changing admission decisions.

flowchart TD
  A[Session consumers] --> B[Generation lease owner]
  C[Committed session changes] --> B
  D[Database resource lifecycle] --> B
  B --> E[Existing authority assertions]
  B --> F[Bounded diagnostic projection]
  F --> G[Existing logger]
Loading

Technical review

Best possible solution:

Retain the bounded instrumentation in the existing lease owner and use its observations to investigate any later refusal without claiming an incident fix.

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

The refusal paths are source-verifiable, but the historical incident and its producer remain unknown, as the PR explicitly states.

Is this the best way to solve the issue?

The existing lease owner remains authoritative, and the sibling helper contains the bounded projection without adding another admission path or persistence model.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Unavailable versus revoked errors and lease settlement keeps the original intent (4f53213: Keep delayed results bound to their original session generation and reject reset or replacement before delivery.)
  • Native and prepared final-effect authority checks keeps the original intent (b1a2aa2: Prepare expensive authority facts off-thread while retaining live checks immediately before file mutation.)
  • Prepare-failure diagnostic ordering changes intended behavior with a stated reason (4f53213: Preparation failures release retained resources and preserve recognized generation errors; this PR deliberately observes failure state before that cleanup.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Josh Avant: Raw commit 4f53213 adds src/config/sessions/session-delivery-generation.ts:77 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4f53213ad359; files: src/config/sessions/session-delivery-generation.ts)

PR surface

Source +193, Tests +393, Other +2. Total +588 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 227 34 +193
Tests 1 393 0 +393
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 4 622 34 +588

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test LOC Production +227/-34; tests +393/-0 Production growth implements bounded projection and per-lease instrumentation; tests cover distinct privacy, error-preservation, and lifecycle failures.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a diagnostic improvement with no claimed repair of a verified user-facing incident.
  • 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 execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-10T15:29:52.226Z sha 58ad792 :: needs changes before merge. :: [P2] Build the positive stack fixture with a Windows-valid file URL
  • reviewed 2026-11-10T17:24:33.269Z sha f3b4a35 :: needs changes before merge. :: [P2] Allocate the justified diagnostic regression-test growth
  • reviewed 2026-11-10T17:43:40.475Z sha dd12d9a :: needs maintainer review before merge. :: none

Reviewed November 10, 2026, 1:17 PM ET / 18:17 UTC (Revision 4).

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review November 10, 2026 17:13
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 10, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 10, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Nov 10, 2026
@clawsweeper clawsweeper Bot removed the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Nov 10, 2026
@fuller-stack-dev
fuller-stack-dev merged commit 2c4e34a into main Nov 10, 2026
133 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the openclaw/delivery-generation-recovery-fix branch November 10, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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