fix: declare the OpenClaw 2026.8.1 durable-turn contract (engine is currently degraded to legacy on every turn) #372
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->

<!-- review_stack_entry_end -->
<!-- walkthrough_start -->
<details>
<summary>📝 Walkthrough</summary>
Walkthrough
The context engine now supports atomic, idempotent turn commits. It coordinates durable ingestion, joins concurrent retries, records successful advancement keys within a 4096-entry bound, and propagates failures for retry.
Changes
Turn commitment
|Layer / File(s)|Summary|
|---|---|
|Transcript and advancement contract <br> src/context-engine.ts|Engine metadata declares transcript fencing and atomic idempotent advancement. Bounded state tracks committed and in-flight advancement keys.|
|Durable ingestion coordination <br> src/context-engine.ts|Ingestion queues return task outcome promises. afterTurn exposes internal ingestion capture while keeping fire-and-forget behavior and isolating best-effort post-ingest work.|
|Bounded idempotent turn commit <br> src/context-engine.ts, test/unit/context-engine.test.ts|commitTurn deduplicates keys, joins concurrent calls, records only successful commits, propagates shared failures, and supports retry after ingestion failure. Tests cover these paths.|
Estimated code review effort: 4 (Complex) | ~45 minutes
Sequence Diagram(s)
sequenceDiagram
participant Host
participant CommitTurn as commitTurn
participant AfterTurn as afterTurn
participant IngestionQueue
participant Daemon
Host->>CommitTurn: Provide advancementKey and turn arguments
CommitTurn->>AfterTurn: Start a new turn with capture hook
AfterTurn->>IngestionQueue: Enqueue durable ingestion
IngestionQueue->>Daemon: Persist turn
Daemon-->>IngestionQueue: Return success or failure
IngestionQueue-->>AfterTurn: Resolve ingestion promise
AfterTurn-->>CommitTurn: Expose ingestion outcome
CommitTurn-->>Host: Return committed or duplicate, or propagate failure
Possibly related PRs
afterTurn ingestion flow.afterTurn.context-engine.ts.Suggested labels: release:patch
Suggested reviewers: xdarkicex
Poem
A rabbit tracks each turn with care,
One key commits; repeats stay there.
Failed hops may try again,
While durable paths remain plain.
Thump, thump—the queue is fair.
</details>
<!-- walkthrough_end -->
<!-- pre_merge_checks_walkthrough_start -->
<details>
<summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary>
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
| :----------------: | :--------- | :------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- |
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
<details>
<summary>✅ Passed checks (4 passed)</summary>
| Check name | Status | Explanation |
| :------------------------: | :------- | :---------------------------------------------------------------------------------------------------------- |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly identifies the durable-turn contract update and the legacy-path degradation it addresses. |
</details>
</details>
<!-- pre_merge_checks_walkthrough_end -->
<!-- tips_start -->
---
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
<details>
<summary>❤️ Share</summary>
</details>
<sub>Comment @coderabbitai help to get the list of available commands.</sub>
<!-- tips_end -->
_🗄️ Data Integrity & Integration_ | _🟠 Major_ | _🏗️ Heavy lift_
Do not mark the advancement key committed before durable ingestion succeeds.
afterTurn resolves after it queues ingestion. It does not wait for afterTurnKernel or manifest persistence. It also catches queued failures internally. Line 3355 therefore records the key when the daemon write can still fail. A host retry then returns "duplicate" and cannot retry the lost ingestion.
Two concurrent calls with the same advancementKey can also both pass line 3343 before either call reaches line 3355. Both calls then report "committed". This does not provide atomic idempotency.
Use a per-key in-flight promise or lock. Keep it until a serialized ingestion operation confirms the daemon and manifest update. Delete the in-flight entry on failure. Record the committed key only after that success. Add tests for concurrent same-key calls and an afterTurnKernel failure followed by a retry.
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/context-engine.ts` around lines 3342 - 3361, The advancement handling
around afterTurn must provide atomic per-key idempotency and only commit keys
after durable ingestion succeeds. Replace the check-and-add flow in the relevant
context-engine method with a per-key in-flight promise or lock that serializes
identical advancementKey calls, keeps the entry until afterTurnKernel and
manifest persistence succeed, removes it on failure, and records
committedAdvancementKeys only after success. Ensure failures propagate so a
later retry can run, and add coverage for concurrent same-key calls and retrying
after an afterTurnKernel failure.
</details>
<!-- fingerprinting:phantom:poseidon:tapir -->
<!-- cr-indicator-types:potential_issue -->
<!-- cr-comment:v1:cdb310f9aedcdd9f724030d1 -->
<!-- This is an auto-generated reply by CodeRabbit -->
✅ Addressed in commit 8ac9d9a
Actionable comments posted: 1
<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/context-engine.ts`:
- Around line 3342-3361: The advancement handling around afterTurn must provide
atomic per-key idempotency and only commit keys after durable ingestion
succeeds. Replace the check-and-add flow in the relevant context-engine method
with a per-key in-flight promise or lock that serializes identical
advancementKey calls, keeps the entry until afterTurnKernel and manifest
persistence succeed, removes it on failure, and records committedAdvancementKeys
only after success. Ensure failures propagate so a later retry can run, and add
coverage for concurrent same-key calls and retrying after an afterTurnKernel
failure.
</details>
<details>
<summary>🪄 Autofix</summary>
Fix all unresolved CodeRabbit comments on this PR:
</details>
---
<details>
<summary>ℹ️ Review info</summary>
<details>
<summary>⚙️ Run configuration</summary>
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4e720b2a-2c0f-4a27-8afd-1f22e8dea9d6
</details>
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between c883cf755609023cfc5b15c3acb04f08ed4d7c2c and 6e21ffce860ec537e7aa93b1b0646bee933fe9a9.
</details>
<details>
<summary>📒 Files selected for processing (1)</summary>
src/context-engine.ts</details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
Confirmed and fixed in 8ac9d9a — both halves were real.
Recording before durability. You are right that afterTurn resolves once ingestion is queued and that the queued task caught its own failures, so the key was recorded while the daemon write could still fail. enqueueAsyncIngestion now returns a handle that settles with the task's real outcome, and commitTurn awaits it. The queue chain keeps its own .catch so one failed task cannot poison the tasks behind it, and that same catch means the handle can never surface as an unhandled rejection when afterTurn ignores it.
I split the task rather than propagating everything: a failure in afterTurnKernel or the manifest write now rejects, but predictive compaction, the prediction cache and embedding pre-warm stay logged-and-swallowed. Those run after the turn is already durable, and asking the host to retry a durable turn is worse than losing a prediction. That matches how you scoped it — "confirms the daemon and manifest update".
afterTurn itself is unchanged from the host's perspective: same return value, still fire-and-forget, still logs. The handle goes out through a symbol-keyed argument instead of being added to the result, so the public shape does not move. (Adding a field to the result was my first attempt; it also broke TypeScript's fresh-object-literal union normalisation for the inferred return type, which an existing test depends on for .skipped.)
Non-atomic check-and-add. Identical advancementKeys are now serialized on one in-flight promise. Exactly one caller ingests; the others join it and resolve "duplicate" on success, or reject with the same error on failure — a joiner is never told the turn succeeded when it did not. The key is recorded only after the durable work succeeds, and there is no await between recording it and clearing the in-flight entry, so no caller can observe a window where the key is neither in flight nor committed. On failure nothing is recorded and the entry is deleted, so a retry does real work. The 4096 bound is unchanged, now with oldest-first eviction in a helper.
Tests (test/unit/context-engine.test.ts), all three of which fail against the previous implementation:
afterTurnKernel call, statuses ["committed","duplicate","duplicate"], and a later retry short-circuits without touching the daemon. Pre-fix this returned ["duplicate","duplicate","duplicate"].afterTurnKernel failure → the call rejects rather than reporting committed, the retry re-runs and commits, and only then does a third call report duplicate. Pre-fix: "Missing expected rejection".They set OPENCLAW_STATE_DIR to a temp dir. They assert on whether the daemon was called, which depends on an empty per-session manifest, and the default store is the developer's real ~/.openclaw/libravdb-manifests — a manifest left by an earlier run makes afterTurn short-circuit with no-new-messages and flips the assertions. Worth noting separately: two pre-existing afterTurn tests on main already fail for exactly that reason, independent of this PR.
One limitation I want to be explicit about rather than paper over. This makes the commit atomic and durability-gated within a process. committedAdvancementKeys is in-memory, so a retry after a crash finds an empty set and re-runs afterTurn — which is safe because it reloads the manifest inside the serialized queue and slices at findOverlapIndex, so a replayed turn contributes no new messages. The key set is a fast path for exact in-process retries, not the durability mechanism; the manifest is. I have said so in the commitTurn doc comment.
Verified: tsc --noEmit clean, tsc -p tsconfig.build.json && node scripts/bundle-entrypoint.mjs clean, contract still present in dist/index.js, and the unit suite is at the same two pre-existing failures as main with the three new tests passing.
@Marvinthebored, confirmed. The current implementation addresses both parts of this finding.
commitTurn() now waits for the captured ingestion handle before it records advancementKey. Failures from afterTurnKernel or manifest persistence propagate, remove the in-flight entry, and leave the key retryable.
inFlightAdvancements serializes concurrent calls for the same key. Joiners return "duplicate" only after the leader succeeds. They receive the leader’s failure if it fails.
Keeping predictive compaction and cache warming as best-effort post-durability work is correct. The manifest overlap logic provides safe idempotency after a process restart.
Thank you for adding coverage for concurrent commits and failed-ingestion retries.
<!-- <review_comment_addressed> -->
🐇 ✅
---
<!-- This is an auto-generated comment: tweet message by coderabbit.ai -->
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
<!-- end of auto-generated comment: tweet message by coderabbit.ai -->
<sub>You are interacting with an AI system.</sub>
<!-- This is an auto-generated reply by CodeRabbit -->
[!CAUTION]
Some comments are outside the diff and can’t be posted inline due to platform limitations.
>
> <details>
<summary>⚠️ Outside diff range comments (1)</summary><blockquote>
> <details>
<summary>src/context-engine.ts (1)</summary><blockquote>
> 2768-2778: _🗄️ Data Integrity & Integration_ | _🟠 Major_ | _⚡ Quick win_> Update the installed OpenClaw SDK before relying on transcriptSemantics.>src/context-engine.tsdeclares supported semantics that require OpenClaw >= 2026.8.1, butpackage.jsonbuilds withopenclawVersion/pluginSdkVersion2026.4.23 andinstall.minHostVersion>=2026.4.23. Install / build with a 2026.8.1+ host SDK before relying on these fields to enable the durable logical turn path.
> <details>
<summary>🤖 Prompt for AI Agents</summary>
>> Verify each finding against current code. Fix only still-valid issues, skip the > rest with a brief reason, keep changes minimal, and validate. > > In `@src/context-engine.ts` around lines 2768 - 2778, Update the OpenClaw SDK > version configuration before relying on transcriptSemantics in the > libravdb-memory context engine declaration. Align package.json’s > openclawVersion, pluginSdkVersion, and install.minHostVersion with a > 2026.8.1-or-newer host SDK, then retain the transcriptSemantics fields in the > context-engine configuration. >
> </details>
> <!-- cr-comment:v1:2652ed6f7d1a53f1e71d7662 -->
> </blockquote></details>
> </blockquote></details>
<details>
<summary>🧹 Nitpick comments (2)</summary><blockquote>
<details>
<summary>test/unit/context-engine.test.ts (1)</summary><blockquote>
3444-3446: _📐 Maintainability & Code Quality_ | _🔵 Trivial_ | _💤 Low value_
Assert that the failed concurrent attempt reached the daemon once.
The test name claims a shared ingest, but the assertions only check that both callers reject. A regression that starts two ingests, where both fail, still passes. failAfterTurnKernel returns a calls() probe; the return value is discarded at Line 3432.
<details>
<summary>♻️ Proposed assertion</summary>
- failAfterTurnKernel(client, 1);
+ const probe = failAfterTurnKernel(client, 1);
const settled = await Promise.allSettled([call(), call()]);
assert.equal(settled[0]?.status, "rejected", "the leader must reject");
assert.equal(settled[1]?.status, "rejected", "a joiner must see the leader's failure, not success");
+ assert.equal(probe.calls(), 1, "the joiner must share the leader's ingest, not start a second one");
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@test/unit/context-engine.test.ts` around lines 3444 - 3446, Update the
concurrent ingest test around failAfterTurnKernel and the settled assertions to
retain its calls() probe and assert that the daemon was reached exactly once
after both callers reject. Keep the existing rejection assertions while
verifying the shared-ingest behavior.
</details>
<!-- cr-comment:v1:28bb76bd80c2978d840a8091 -->
</blockquote></details>
<details>
<summary>src/context-engine.ts (1)</summary><blockquote>
3393-3411: _🩺 Stability & Availability_ | _🔵 Trivial_ | _⚡ Quick win_
Bind afterTurn without relying on this.
ingestTurn calls this.afterTurn(...). This works only while the host invokes engine.commitTurn(...) as a method on the returned object. If the host destructures the hook, or wraps it (for example const { commitTurn } = engine; await commitTurn(args)), this is undefined and the call throws a TypeError before any ingestion runs. The other hooks in this object do not depend on this, so this is the only method that carries that constraint.
Consider extracting the afterTurn body into a named function in the factory closure, then calling it from both afterTurn and commitTurn.
<details>
<summary>♻️ Minimal alternative: capture the object once</summary>
return {
+ // `engine` refers to this object so hooks stay callable when detached.
info: {
Then use engine.afterTurn(...) inside ingestTurn instead of this.afterTurn(...), where engine is a const bound to the returned object.
</details>
<details>
<summary>🤖 Prompt for AI Agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/context-engine.ts` around lines 3393 - 3411, Remove the `this` dependency
from `ingestTurn` in the `commitTurn` flow by reusing a factory-scoped named
after-turn function, or by capturing the returned engine object and calling its
`afterTurn` property. Ensure `afterTurn` and `commitTurn` share the same
implementation so destructured or wrapped `commitTurn` calls still await
ingestion successfully.
</details>
<!-- cr-comment:v1:5ce8e925ed1b7be989726c9f -->
</blockquote></details>
</blockquote></details>
<details>
<summary>🤖 Prompt for all review comments with AI agents</summary>
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/context-engine.ts`:
- Around line 2768-2778: Update the OpenClaw SDK version configuration before
relying on transcriptSemantics in the libravdb-memory context engine
declaration. Align package.json’s openclawVersion, pluginSdkVersion, and
install.minHostVersion with a 2026.8.1-or-newer host SDK, then retain the
transcriptSemantics fields in the context-engine configuration.
---
Nitpick comments:
In `@src/context-engine.ts`:
- Around line 3393-3411: Remove the `this` dependency from `ingestTurn` in the
`commitTurn` flow by reusing a factory-scoped named after-turn function, or by
capturing the returned engine object and calling its `afterTurn` property.
Ensure `afterTurn` and `commitTurn` share the same implementation so
destructured or wrapped `commitTurn` calls still await ingestion successfully.
In `@test/unit/context-engine.test.ts`:
- Around line 3444-3446: Update the concurrent ingest test around
failAfterTurnKernel and the settled assertions to retain its calls() probe and
assert that the daemon was reached exactly once after both callers reject. Keep
the existing rejection assertions while verifying the shared-ingest behavior.
</details>
---
<details>
<summary>ℹ️ Review info</summary>
<details>
<summary>⚙️ Run configuration</summary>
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9bf6b6e6-e6bc-4474-885b-133c2d30ceae
</details>
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between 6e21ffce860ec537e7aa93b1b0646bee933fe9a9 and 8ac9d9a6c38cddc3464d1256969fb1fba7f0fca7.
</details>
<details>
<summary>📒 Files selected for processing (2)</summary>
src/context-engine.ts
test/unit/context-engine.test.ts
</details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
Vale Review — PR #372
Quality: Q3/5 — promising
Head: 8ac9d9a
Findings:
commitTurn calls this.afterTurn(...), so the hook only works when invoked as a method on the returned engine object. If the host stores or wraps the hook as a bare function, this is undefined and the durable-turn path throws before it can ingest. Keep the shared after-turn implementation in the factory closure or call a captured engine object. minorfailAfterTurnKernel's call probe, so it proves both callers reject but does not prove they shared one daemon call. A regression that starts two failing ingests could still pass this test. nitProof gaps: I did not run a live OpenClaw 2026.8.1 runtime test or verify exactly how the host invokes commitTurn; the PR body still says full ingestion restoration is not proven on the target runtime.
Verdict: comment-only — The contract fix is directionally right and the durability-gating regression is covered, but these edges should be tightened before relying on it as the durable-turn implementation.
– Vale
use @vale review
Thanks — the this.afterTurn finding was right and is fixed.
commitTurn now calls engine.afterTurn(...) through the closure instead of this. OpenClaw does bind it today (params.engine.commitTurn?.bind(params.engine) in context-engine-turn-outbox.ts), so this was latent rather than live — but nothing in the contract requires binding, and a host that stored the hook bare would have thrown before ingesting anything.
Added a regression test that detaches commitTurn from the engine and calls it unbound. Verified both ways: it fails with this.afterTurn and passes with the closure reference.
On the SDK-version point from CodeRabbit: I have deliberately not raised install.minHostVersion. transcriptSemantics and commitTurn are additive — older hosts ignore both, so the plugin still works there, and raising the floor would block installs that are currently fine. If you would rather gate it, that is your call and I will make the change.
The nit about the shared-failure test not proving a single daemon call is fair; I have left it, since the behaviour it would pin is already covered by the serialization test above it. Happy to tighten it if you want it explicit.
Vale Review — PR #372
Quality: Q4/5 — sharp
Head: fae5bf0
Findings:
Proof gaps: I did not run a live OpenClaw 2026.8.1 runtime test; focused unit coverage passed with isolated state, but the PR body still names the separate host receipt-path blocker.
Verdict: approve — Current head fixes the prior unbound commitTurn edge and the durable-ingest/idempotency tests pass at this head.
– Vale
use @vale review
Vale Review — PR #372
Quality: Q4/5 — sharp
Head: c851377
Findings:
Proof gaps: I did not run a live OpenClaw 2026.8.1 runtime test in this automation pass; the PR still depends on the separate host receipt-path fix for full runtime restoration.
Verdict: approve — Current head fixes the prior unbound-hook edge and now carries the stricter afterTurn durability handling needed before mapping commits to the host contract.
– Vale
use @vale review
compoodment
Marvinthebored
Problem
On OpenClaw 2026.8.1, this plugin's context engine is never used. Every turn logs:
The plugin loads, registers in
fullmode, and is then silently bypassed — nothing is ingested. It worked on 2026.6.x.Cause: OpenClaw changed the context-engine contract, deliberately
openclaw/openclaw#119325 (merged 2026-08-07, in 2026.8.1) added a required durable-turn contract for context engines:
info.transcriptSemantics.currentTurnFence: "before-current-turn-entry-v1"info.transcriptSemantics.turnAdvancementIdempotency: "atomic-idempotent-v1"commitTurn()methodThe host enforces it in
resolveSelectionIssue()(src/agents/harness/context-engine-logical-turn.ts): an engine missing either field, or missingcommitTurn, is degraded tolegacyfor the whole logical turn.This is intentional and is now canon, not an accident:
docs/concepts/context-engine.md): "Without the full declaration and method, OpenClaw uses the legacy context path for the whole logical turn… OpenClaw tries the configured engine again on the next logical turn."commitTurncontract in this PR." It was merged on that basis.So the fallback to
legacyis working as designed; the plugin simply has not adopted the contract yet.Current
info(src/context-engine.ts) declares neither field, and there is nocommitTurn:What this PR does
1. Declares both
transcriptSemanticsfields.2. Adds
commitTurn(), delegating to the existingafterTurn.afterTurnis already atomic and idempotent for this purpose: it reloads the per-session manifest inside the serialized ingestion queue and slices frommanifestStore.findOverlapIndex, so a replayed turn contributes no new messages.commitTurntherefore satisfies "atomic, idempotent, keyed byadvancementKey" without reworking ingestion. A boundedSetof seenadvancementKeys short-circuits an exact host retry so the host is answeredduplicaterather than repeating the overlap scan.No behavior change on older OpenClaw versions: the extra
infofields are inert, andcommitTurnis only called by hosts that look for it.Evidence
Typecheck and build clean:
Live on OpenClaw 2026.8.1. I applied this same change to the built
dist/index.jsof the installed 1.10.21 and restarted the gateway.| | turns | degradations |
|---|---|---|
| stock 1.10.21 | 3 | 3 — "atomic idempotent turn advancement is not declared" |
| with this change | 3 | 0 — engine selected,
LibraVDB bootstrapran, codex wrote acontext-engine thread binding|It has been running on my production instance since, with no degradation warnings.
Important caveat — this is necessary but not sufficient
Two things remain, neither caused by this plugin and neither fixed here:
1. A host bug blocks the receipt path. On 2026.8.1 the host also degrades every fresh turn with "current-turn transcript admission receipt is unavailable", because it checks for the receipt during turn preparation, before the user turn is persisted. That affects every third-party context engine, including a minimal reference engine that implements the contract in full. Filed as openclaw/openclaw#121460 with a fix in openclaw/openclaw#121461. Until that lands, this PR alone will not restore ingestion — you need both.
2. I have not yet observed
commitTurnorafterTurnactually firing under the Codex app-server runtime even with both fixes applied: no session manifest is written. I am still investigating whether that is a further host issue or something on the plugin side, and will follow up. I did not want to overstate this PR: it removes the contract-based degradation, which I have measured; it is not yet proof that ingestion is fully restored on that runtime.Also worth knowing
info.acceptedHostParamsis still undeclared. OpenClaw's docs say undeclared engines receive the pre-host-field legacy parameter set only through 2026-08-12, after which they receive every current host field. That may need attention separately.AI-assisted: investigated, implemented and tested with Claude (Claude Code).
---
Update — durability defects found by review, now fixed
Depends on #375.
An adversarial review of this PR found that it promoted
afterTurn's advisory semantics into a durability contract.afterTurnmay skip, dedupe by content, or short-circuit. That was harmless while it only drove logging; it is load-bearing oncecommitTurnmaps the result to{committed|duplicate}, because the host deletes the durable outbox row for both values and never retries either.The concrete defect: an excluded session returned
"duplicate"for work that was never committed, and memoized theadvancementKeyas though it had been. So"duplicate"could mean "intentionally ignored and never stored" rather than "already committed", and the turn was gone.What changed
"committed"."duplicate"is decided solely byadvancementKeymatching — the host's own definition of the word — and never inferred fromafterTurn's result."duplicate"only when the leader actually committed, so two concurrent excluded calls can no longer manufacture a prior commit between them.afterTurnis idempotent against the persisted manifest, so it re-derives the same skip. The key set is a fast path, not the correctness mechanism.Tests assert the absences
The earlier tests covered only the happy paths, so they could not have caught this:
"duplicate"for an excluded session, including on a replay of the same key"duplicate"when two concurrent excluded calls share a key"duplicate"still reachable by replaying a key that did commit — so the two negative assertions above cannot pass vacuouslyAll three fail on the previous head and pass here.
Dependency on #375
commitTurnis only as trustworthy as the ingest beneath it. Two defects inafterTurnare not fixed here because they exist onmainindependently of this contract and are not this PR's concern — they are #375:"committed"for a turn that was never storedbootstrapdeletes the in-flightasyncIngestionQueuesentry, breaking per-session serializationThe first is recorded as a known limitation on the method's own documentation, so it stays visible if this lands first.
Also documented rather than changed
Both predate this PR and belong to
afterTurn:Review
Six adversarial passes on this change. Two of them found defects in the fix for the previous pass's finding — a reason-string gate that failed open, and an in-flight join that returned
"duplicate"unconditionally — so one re-review after acting on findings would not have been enough here.AI-assisted throughout: written with Claude (Claude Code).
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary
-
currentTurnFence: "before-current-turn-entry-v1"-
turnAdvancementIdempotency: "atomic-idempotent-v1"commitTurn()with atomic, per-advancementKeyidempotency."duplicate".afterTurn.Complexity
kevicted keys.nis the number of unique advancement keys.commitTurn()has higher cyclomatic complexity because it handles duplicate detection, in-flight coordination, durable failure propagation, retry cleanup, and successful commit recording.afterTurn()has higher cyclomatic complexity because it separates durable ingestion from best-effort post-ingest work and captures ingestion outcomes.Caveats
commitTurn()andafterTurn()have not yet been observed under the Codex app-server runtime.acceptedHostParamsremains undeclared separately.<!-- end of auto-generated comment: release notes by coderabbit.ai -->