|
| 1 | +title: Gateway compaction preserves writer ownership and committed facts |
| 2 | + |
| 3 | +scenario: |
| 4 | + id: gateway-compaction-abort |
| 5 | + surface: runtime |
| 6 | + coverage: |
| 7 | + primary: |
| 8 | + - session-memory.compaction-retry-policy |
| 9 | + secondary: |
| 10 | + - session-memory.compaction |
| 11 | + - session-memory.pruning |
| 12 | + objective: Verify that stock overflow compaction through the real Gateway cannot write after writer replacement or cancellation, while cancellation after its commit preserves completed accounting. |
| 13 | + successCriteria: |
| 14 | + - A real built Gateway receives a synthetic HTTP context overflow and starts an actual compaction summary request held by the provider fixture. |
| 15 | + - The retained active transcript includes a completed assistant tool call paired with a 180000-character tool result before cancellation. |
| 16 | + - chat.abort cancels the exact run, and releasing the summary does not change pre-existing durable rows, retained active entry identities, tool content, or compaction accounting. |
| 17 | + - Replacing the original run's durable writer through the real claim owner in the isolated producer child preserves the same session and lifecycle revision; without chat.abort, releasing the summary cannot append a stale compaction, change checkpoints or accounting, or retry the old turn. The original lifecycle independently settles as failed, and its verified terminal fields are the only allowed replacement-row changes. |
| 18 | + - A fresh turn on the same session reaches its own held provider request before final state assertions, proving the old session lane released without relying only on agent.wait. |
| 19 | + - Interrupted turns deliver no final marker, while their same-session successors deliver exactly one recovery marker through QA Channel, matched to the exact successor run rather than rejected by an earlier run's warning. |
| 20 | + - An independent summary failure while still active exercises tool-result truncation and recovers without a compaction count increment. |
| 21 | + - A separate successful summary control commits and counts exactly one compaction. |
| 22 | + - An ordinary explicitly enabled workspace hook proves its loaded gateway startup event, then holds session:compact:after after a real SQLite compaction; aborting the original caller must retain that compaction and settle count one while the hook is still held, before release or successor admission. |
| 23 | + - The committed-cancellation case releases the hook in finally, observes hook settlement and the next same-session provider request, then joins only the owned Gateway before its final SQLite and delivery assertions; no second compaction or late original reply is allowed. |
| 24 | + - The held internal after hook covers the enclosing ContextEngine cancellation race, not the earlier SDK session_compact extension-hook timing. |
| 25 | + regressionRefs: |
| 26 | + - https://github.com/openclaw/openclaw/issues/127523 |
| 27 | + - https://github.com/openclaw/openclaw/issues/127551 |
| 28 | + docsRefs: |
| 29 | + - docs/concepts/compaction.md |
| 30 | + - docs/automation/hooks.md |
| 31 | + - docs/concepts/qa-e2e-automation.md |
| 32 | + - docs/channels/qa-channel.md |
| 33 | + codeRefs: |
| 34 | + - test/e2e/qa-lab/runtime/gateway-compaction-abort.ts |
| 35 | + - test/e2e/qa-lab/runtime/gateway-compaction-provider.fixture.ts |
| 36 | + - test/e2e/qa-lab/runtime/gateway-compaction-state.fixture.ts |
| 37 | + - src/context-engine/delegate.ts |
| 38 | + - src/agents/embedded-agent-runner/compaction-session-execution.ts |
| 39 | + - src/agents/embedded-agent-runner/compaction-safety-timeout.ts |
| 40 | + - src/agents/embedded-agent-runner/run/session-bootstrap.ts |
| 41 | + - src/agents/embedded-agent-runner/run/compaction-runtime.ts |
| 42 | + - src/agents/embedded-agent-runner/run/overflow-context-recovery.ts |
| 43 | + - src/agents/embedded-agent-runner/tool-result-truncation.ts |
| 44 | + - src/gateway/server-methods/chat-abort-handler.ts |
| 45 | + execution: |
| 46 | + kind: script |
| 47 | + path: test/e2e/qa-lab/runtime/gateway-compaction-abort.ts |
| 48 | + timeoutMs: 660000 |
| 49 | + summary: Run on Blacksmith Testbox after OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build. The producer launches an environment-isolated child before importing OpenClaw and uses a built dist Gateway with owned state and ports. Pending cancellation, real writer replacement, independent summary failure, success, and cancellation during a loaded internal after hook record SQLite snapshots, held-hook accounting, provider checkpoints, QA Channel delivery, owned-process settlement, and a standard evidence verdict. |
| 50 | + config: |
| 51 | + requiredProviderMode: mock-openai |
| 52 | + args: |
| 53 | + - --artifact-base |
| 54 | + - ${outputDir} |
0 commit comments