Skip to content

fix(runtime): hydrate canonical WAL before resume compaction - #816

Merged
mergify[bot] merged 6 commits into
matrixorigin:mainfrom
loveRhythm1990:fix/canonical-wal-resume-order-812
Sep 18, 2026
Merged

mergify[bot] merged 6 commits into
matrixorigin:mainfrom
loveRhythm1990:fix/canonical-wal-resume-order-812

Conversation

@loveRhythm1990

@loveRhythm1990 loveRhythm1990 commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up turns with a large restored history can compact the admitted canonical prefix before the Server hydrates its provider WAL. Hydration then rejects the rewritten prefix with provider canonical WAL durable base is absent from restored history, preventing execution.

Run WAL hydration during shared round preparation, after cancellation/pause and non-executing exits, but before semantic admission and resume compaction. Keep the existing idempotent hydration implementation and integrity checks, with a no-op default for hosts without durable history. Preserve the original WAL bypass for configured e2e-hooks mock rounds, including exhausted mock queues.

Regression coverage checks both the original history presented to hydration and the recovered content plus fresh user message delivered to execution after compaction. Additional tests exercise cancellation, pause, no-round exit, classified WAL failure, and mock recovery bypass.

CI follow-up (6ceca8f6) changes only test fixtures: the child-dispatch wait now allows 10 seconds for parent rounds plus child admission (still within the 30-second CI case budget), and the bounded settlement test gives its own eligible debt an earlier retry timestamp so unrelated shared-database backlog cannot occupy its single-row batch. Both business assertions remain enforced.

A subsequent run exposed an unrelated paused-clock race in edge_ws_e2e. Follow-up 37a5b62a replaces a single scheduler yield with an explicit mock publication-drop notification before advancing another 24 virtual seconds. Production heartbeat, timeout, connection-release, and WAL semantics are unchanged.

Related issue

Closes #812

The ordering defect exists on main. The exact private incident history was not replayed; approval denial and XLSX processing are not established as necessary triggers.

Change type

  • Bug fix
  • Test

User and compatibility impact

Restored conversations can pass WAL validation before authorized compaction changes their prefix. No configuration, schema, model, token-budget, or API changes. The hook adds no model calls. In WAL recovery cases, semantic admission and compaction now see the recovered history; ordinary histories remain unchanged by hydration. No accuracy benchmark or live-provider comparison was performed.

Architecture and complexity delta

  • Canonical owner changed or extended: shared AgenticLoopHost / round preparation, with Server-owned WAL hydration. Preparation returns classified errors so WAL failure retains its original kind.
  • Existing implementations and callers searched: Server background and SSE lifecycle restoration, shared loop preparation and resume compaction, WAL hydration and rewrite proof ownership.
  • Superseded code, states, tables, shims, or self-only tests removed: removed the late hydration invocation in Server execute_turn.
  • If parallel implementations remain, their boundary and retirement condition: none; the existing idempotent WAL recovery implementation is reused.

Verification

  • Review follow-up validation: cargo test -p astra-runtime --features e2e-hooks --lib hydrat: 17 passed, including restored-history compaction, classified failures, control exits, and mock bypass. Formatting and diff checks passed.
  • Final CI on 37a5b62a: Test Suite succeeded, including runtime (5912/5912), core/bridge, online core (390/390 service DB tests), online integration, and both terminal PTY platforms. Static Checks also succeeded.
  • PR merged as f415b8dc; its Git tree is identical to the tested 37a5b62a tree. The Mergify queue permission notice was a fork-maintainer-edit permission issue, not a test failure; no permissions were changed.
  • Prior CI on 6ceca8f6: lint, runtime, and core/bridge passed; selective e2e-hooks ran 120 tests, all passed. Online core was cancelled when the branch was updated with main.
  • CI on the subsequent main merge exposed the paused-clock test race fixed in 37a5b62a; the final run above confirms that regression now passes.
  • On 37a5b62a, the exact paused-clock regression passed 50 consecutive fresh-process runs. The full edge_ws_e2e binary passed 26 tests; its one explicitly live-DB test was not selected. Latest-head CI lint passed.
  • Local make check completed lint and formatting; its broad compile-check phase was interrupted after the branch changed to prioritize validation of the new exact regression. This is not claimed as a full make check pass.
  • The formerly failing child workspace inheritance test passed locally both alone and in the expanded Web E2E run.
  • The formerly failing bounded settlement test passed twice against an isolated local MatrixOne test database (alone and within the full inference suite).
  • Additional non-gating local sweeps are not fully green: Web E2E had 84 passed / 4 failed (three replay assertions disagree with the existing unindexed session_info preamble, and one unknown-skill assertion expects a different error phrase). Inference DB coverage had 42 passed / 1 failed: the 300-round WAL case exceeded its fixture's five-minute run-owner lease and was correctly fenced (291 admissions across 299 seconds). That same pressure case passed in final CI in 10.361 seconds. These broader results are reported separately from the selected CI checks; no production guard was weakened to pass them.
  • Initial revision commands and results:
    • cargo test -p astra-runtime restored_history_is_hydrated_before_first_round_compaction --lib: 1 passed.
    • cargo test -p astra-runtime provider_transition_wal --lib: 7 passed.
    • cargo test -p astra-runtime crash_hydration_preserves_the_openai_cache_visible_prompt --lib: 1 passed.
    • make lint: passed.
    • make format-check: passed.
    • git diff --check: passed.
  • Public entrypoints exercised: shared run_agentic_loop_with_host, mock-provider HTTP/SSE child tool dispatch, and live MatrixOne settlement recovery. No live model/provider or interactive TUI comparison was run.
  • Unhappy paths exercised: existing WAL tests cover forked and disconnected transition rejection; hydration integrity checks remain unchanged.
  • Database verification: no production schema, query, or transaction changes. The test fixture's retry timestamp is scoped to its exact user and invocation; live MatrixOne results are recorded above.

Final checklist

  • I added or updated tests at the layer that owns the behavior, or explained why no test is needed.
  • I updated public or design documentation for contract changes, or the change needs no documentation update. This restores the existing recovery-before-rewrite contract.
  • I checked the diff for credentials, private URLs, customer data, generated files, and other sensitive information.
  • The PR title follows the repository's Conventional Commit format.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep review of eb55867: no actionable code findings.

Traced shared loop entry/preparation, Server WAL hydration and rewrite-proof ownership, semantic admission, resume compaction and execution. Hydration now sees the admitted history before prefix rewriting; the existing idempotency, subagent exclusion and integrity checks remain in the canonical Server implementation. Cancellation/pause and non-executing exits retain precedence, classified WAL failures propagate without charging an iteration, and configured mock rounds (including exhausted queues) retain their bypass. The regression also verifies recovered content and the fresh user suffix reach execution after compaction.

Validation: git diff --check passed. Cargo is unavailable locally, so Rust tests were not independently rerun. GitHub Static Checks and the runtime/HTTP-contract job passed; the new feature-gated mock_llm_history_hydration_never_enters_provider_wal_gate test also passed.

CI caveat: Test Suite run 35322024859 is still red. Logs show web_agent_dynamic_spawn_inherits_edge_workspace_binding timing out waiting for tool_request, plus the services-only canonical_transition_wal_is_linear_and_recoverable_across_many_rounds timeout and deferred_settlement_does_not_consume_another_users_bounded_batch_slot assertion failure. I have not established these as regressions caused by this diff (the mock path skips the new gate, and the services-only tests do not call the changed runtime code). This approval is a code-review conclusion, not a claim that CI is green; those failures still need disposition before merge.

@mergify mergify Bot added the queued label Sep 18, 2026
@mergify

mergify Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-18 09:26 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-09-18 09:26 UTC · at f415b8dc209870b979f84f47f11b9f1d9715d5ac · squash

This pull request spent 18 seconds in the queue, including 1 second running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Check PR title
    • check-neutral = Check PR title
    • check-skipped = Check PR title
  • any of [🛡 GitHub branch protection]:
    • check-success = check
    • check-neutral = check
    • check-skipped = check
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: core crates + bridge hooks
    • check-neutral = Test: core crates + bridge hooks
    • check-skipped = Test: core crates + bridge hooks
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-runtime
    • check-neutral = Test: astra-runtime
    • check-skipped = Test: astra-runtime
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-fs-tools)
    • check-neutral = Test: astra-cli (edge-fs-tools)
    • check-skipped = Test: astra-cli (edge-fs-tools)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-git-gix)
    • check-neutral = Test: astra-cli (edge-git-gix)
    • check-skipped = Test: astra-cli (edge-git-gix)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-rest)
    • check-neutral = Test: astra-cli (edge-rest)
    • check-skipped = Test: astra-cli (edge-rest)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (edge-shell)
    • check-neutral = Test: astra-cli (edge-shell)
    • check-skipped = Test: astra-cli (edge-shell)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: astra-cli (non-edge)
    • check-neutral = Test: astra-cli (non-edge)
    • check-skipped = Test: astra-cli (non-edge)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: online (core)
    • check-neutral = Test: online (core)
    • check-skipped = Test: online (core)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: online (integration)
    • check-neutral = Test: online (integration)
    • check-skipped = Test: online (integration)
  • any of [🛡 GitHub branch protection]:
    • check-success = Test: turn-core + services + plan
    • check-neutral = Test: turn-core + services + plan
    • check-skipped = Test: turn-core + services + plan
  • any of [🛡 GitHub branch protection]:
    • check-skipped = web (typecheck, test, build)
    • check-neutral = web (typecheck, test, build)
    • check-success = web (typecheck, test, build)
  • any of [🛡 GitHub branch protection]:
    • check-skipped = Astra SDK (typecheck, test+coverage, build)
    • check-neutral = Astra SDK (typecheck, test+coverage, build)
    • check-success = Astra SDK (typecheck, test+coverage, build)

@mergify
mergify Bot merged commit f415b8d into matrixorigin:main Sep 18, 2026
28 of 29 checks passed
@mergify mergify Bot removed the queued label Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Follow-up turn fails with canonical WAL durable-base mismatch after an incomplete tool turn

2 participants