Skip to content

fix: session history rejects older child sessions - #114194

Closed
HOYALIM wants to merge 3 commits into
openclaw:mainfrom
HOYALIM:codex/issue-114180-session-tree-direct-access
Closed

HOYALIM wants to merge 3 commits into
openclaw:mainfrom
HOYALIM:codex/issue-114180-session-tree-direct-access

Conversation

@HOYALIM

@HOYALIM HOYALIM commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

AI-assisted: yes. I reviewed the change and understand the session-visibility and incarnation-fencing behavior.

Closes #114180

What Problem This Solves

Under the default tree visibility, sessions_list can return an older durable child session while sessions_history rejects the same key after the display-recency window expires. Direct history authorization currently depends on a recency-filtered spawned-session listing instead of the target row's stored lineage.

Why This Change Was Made

Read-only direct history access now obtains the exact target row through sessions.describe and applies the existing canonical row-visibility checker. A successful durable-lineage grant carries the row's sessionId, and runWithScopedSessionAccess revalidates that incarnation before chat.history.

If the exact row is unavailable or the Gateway lacks the method, the code falls back to the existing fail-closed direct guard. The scope intentionally remains limited to sessions_history; direct send and status behavior is unchanged and remains an explicit maintainer policy decision.

User Impact

A parent can read an older child's durable history without widening visibility to every same-agent session. Unrelated sessions remain forbidden, and a session replaced between authorization and transcript read is rejected.

Evidence

  • Current-main behavior: an aged child omitted by the recency-filtered spawned listing receives 0 history reads even when its durable parentSessionKey matches the requester.
  • Candidate behavior: aged-child history access changes 0 -> 1 through sessions.describe -> chat.history.
  • Negative controls: unrelated same-agent chat.history dispatches remain 0; replacement-incarnation dispatches remain 0; unavailable sessions.describe falls back to the existing deny path.
  • Focused validation: 55/55 tests pass across sessions-access and sessions-history-tool in 3.92s with one worker.
  • Format/lint: changed-file oxfmt, changed-file oxlint, and git diff --check pass.
  • Independent review: codex review --base origin/main completed with no actionable findings and confirmed canonical row-checker ownership, fail-closed fallback, and sessionId fencing.
  • Source identity: branch head 3686e66076f2010cbd02c7003653cefa38dd0057, merge base e4b6bde45a0769865219fa0b086618c66decdc13.
  • Runtime behavior proof: on the production-equivalent code diff before this rebase, a redacted loopback Gateway run changed aged-child history access from 0 to 1 while unrelated and replacement-incarnation chat.history dispatches remained 0.
  • Maintainer decision requested: confirm that durable parent lineage should authorize read-only history after recency expiry while send/status remain unchanged.

Signed-off-by: Ho Lim [email protected]

Copilot AI review requested due to automatic review settings July 26, 2026 23:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M labels Jul 26, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 26, 2026
@clawsweeper

clawsweeper Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 6:06 PM ET / 22:06 UTC.

ClawSweeper review

What this changes

The branch lets sessions_history authorize an older child session from its durable Gateway row, then verifies the same session incarnation before reading its transcript.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

This is a focused, source-backed repair for the linked default-tree visibility bug, not obsolete work. The implementation reuses the canonical row-aware checker and adds session-incarnation fencing before transcript reads; however, it intentionally extends a durable parent relationship into read-only history access, so it needs explicit maintainer security-boundary approval before merge.

Priority: P1
Reviewed head: 3686e66076f2010cbd02c7003653cefa38dd0057
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused and well-covered, with credible runtime proof; the remaining blocker is a deliberate authorization-policy decision and refreshed required-check status, not a demonstrated code defect.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body documents a redacted loopback Gateway before/after result with unrelated-session and replacement-incarnation negative controls, and the supplied check context marks the real-behavior proof successful.
Patch quality 🦞 diamond lobster (5/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body documents a redacted loopback Gateway before/after result with unrelated-session and replacement-incarnation negative controls, and the supplied check context marks the real-behavior proof successful.
Evidence reviewed 7 items Current-main ownership gap: The existing direct-key guard creates a synthetic row containing only the key and a recency-derived spawnedBy value, while its own comment says direct actions need a row lookup until callers can provide normalized row metadata. The canonical row checker recognizes ownerSessionKey, spawnedBy, and parentSessionKey as durable requester ownership signals.
Sibling listing behavior: sessions_list already applies the canonical row-aware checker to Gateway rows and passes ownerSessionKey, spawnedBy, and parentSessionKey; this establishes the intended authorization source that the history path was missing.
Patch uses the canonical policy and fences the read: The branch fetches only the exact target through sessions.describe, checks that durable row with the existing row checker, returns an expected session id only for a granted row, and retains the existing fail-closed guard if the row is unavailable. The history tool then passes that expected id to the scoped access admission before chat.history.
Findings None None.
Security Needs attention Confirm durable lineage as a history authorization grant: The new sessions.describe path treats a persisted parentSessionKey as sufficient for an old child’s history read after the listing-recency window expires. The branch limits this to read-only history and fences the session incarnation, but the trust-lifetime change is a maintainer security-policy decision.

How this fits together

Session tools resolve a requested key, decide whether the requesting agent may see that session, and then call the Gateway for the transcript. This PR changes the history path to consult the durable session row used by listings instead of relying only on a recency-filtered spawned-session list.

flowchart TD
  A[Agent calls sessions_history] --> B[Resolve canonical session key]
  B --> C[Gateway session description]
  C --> D[Row-aware tree visibility check]
  D --> E[Verify session incarnation]
  E --> F[Gateway chat history]
  F --> G[Sanitized history tool result]
Loading

Decision needed

Question Recommendation
Should a stored parentSessionKey continue to authorize a parent’s read-only sessions_history access after the child falls out of display recency, while direct send and status remain unchanged? Approve narrow history access: Accept durable parent lineage for sessions_history only, retaining the existing send and status behavior and the session-id fence.

Why: The code proves the former history/list mismatch and contains the authorization expansion with an existing row checker and incarnation fence, but the acceptable lifetime of transcript access is an authorization-policy decision rather than a mechanical defect fix.

Before merge

  • Resolve security concern: Confirm durable lineage as a history authorization grant - The new sessions.describe path treats a persisted parentSessionKey as sufficient for an old child’s history read after the listing-recency window expires. The branch limits this to read-only history and fences the session incarnation, but the trust-lifetime change is a maintainer security-policy decision.
  • Resolve merge risk (P1) - This changes an authorization boundary: under the default tree policy, a parent can now read an old child’s durable transcript even after the display-recency window expires. The code keeps send and status unchanged, but maintainers need to explicitly accept that read-only distinction.
  • Resolve merge risk (P1) - The supplied checks show build-artifacts and openclaw/ci-gate failing on the current PR head. Their logs were unavailable during this read-only review, so a current-head check result is still needed before merge; this is not a code finding by itself.
  • Complete next step (P2) - A maintainer must choose the durable-lineage transcript-authorization policy; no narrow mechanical repair remains for an automated worker.

Findings

  • [medium] Confirm durable lineage as a history authorization grant — src/agents/tools/sessions-access.ts:90
Agent review details

Security

Needs attention: No concrete implementation vulnerability was found, but the diff intentionally expands a transcript-authorization boundary and needs maintainer policy approval before merge.

PR surface

Source +102, Tests +185. Total +287 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 106 4 +102
Tests 2 186 1 +185
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 292 5 +287

Review metrics

Metric Value Why it matters
Production vs test delta production +106/-4; tests +186/-1 The production growth is justified by one explicit authorization-owner boundary—exact-row lookup plus incarnation fencing—and the larger test delta covers its positive and fail-closed cases.

Stored data model

Persistent data-model change detected: serialized state: src/agents/tools/sessions-access.test.ts, serialized state: src/agents/tools/sessions-access.ts, serialized state: src/agents/tools/sessions-history-tool.test.ts, serialized state: src/agents/tools/sessions-history-tool.ts, unknown-data-model-change: src/agents/tools/sessions-access.test.ts, unknown-data-model-change: src/agents/tools/sessions-access.ts, and 1 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #114180
Summary: This PR is a candidate fix for the linked report’s specific disagreement between sessions_list and sessions_history for older durable child sessions.

Members:

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

Merge-risk options

Maintainer options:

  1. Approve the bounded authorization rule (recommended)
    Merge after a maintainer explicitly accepts durable parent lineage for history-only reads and the required checks are refreshed on the reviewed head.
  2. Pause for a broader session-access policy
    Keep the current recency-limited direct history behavior until maintainers define whether durable lineage should cover other direct actions as well.

Technical review

Best possible solution:

Approve the narrow durable-lineage rule for read-only history if it matches the intended tree policy, keep direct send and status on their existing policy, and merge only after the current head has a clear required-check result.

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

Yes, at source level with high confidence: current main lists rows using durable parent metadata but direct history synthesizes a row from a recency-filtered spawned set. The linked report also supplies a concrete released-version reproduction, while this read-only review did not execute it locally.

Is this the best way to solve the issue?

Yes, conditional on approving the authorization policy: the branch reuses the canonical row checker, queries only the requested row, preserves the legacy fail-closed fallback, and uses the existing incarnation-admission mechanism before the transcript read.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 59982714ee48.

Labels

Label justifications:

  • P1: The default tree-visibility workflow can list an older child session but deny its history, blocking a real agent workflow with a deterministic inconsistent result.
  • merge-risk: 🚨 compatibility: Existing default-tree deployments gain access to durable older child transcripts after merge, changing a visible authorization outcome across upgrades.
  • merge-risk: 🚨 security-boundary: The patch intentionally extends transcript authorization from a recency-derived listing to durable parent lineage, so maintainers must accept the security-policy boundary.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body documents a redacted loopback Gateway before/after result with unrelated-session and replacement-incarnation negative controls, and the supplied check context marks the real-behavior proof successful.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body documents a redacted loopback Gateway before/after result with unrelated-session and replacement-incarnation negative controls, and the supplied check context marks the real-behavior proof successful.

Evidence

Security concerns:

  • [medium] Confirm durable lineage as a history authorization grant — src/agents/tools/sessions-access.ts:90
    The new sessions.describe path treats a persisted parentSessionKey as sufficient for an old child’s history read after the listing-recency window expires. The branch limits this to read-only history and fences the session incarnation, but the trust-lifetime change is a maintainer security-policy decision.
    Confidence: 0.93

What I checked:

  • Current-main ownership gap: The existing direct-key guard creates a synthetic row containing only the key and a recency-derived spawnedBy value, while its own comment says direct actions need a row lookup until callers can provide normalized row metadata. The canonical row checker recognizes ownerSessionKey, spawnedBy, and parentSessionKey as durable requester ownership signals. (src/plugin-sdk/session-visibility.ts:344, 990fdcf6fd0e)
  • Sibling listing behavior: sessions_list already applies the canonical row-aware checker to Gateway rows and passes ownerSessionKey, spawnedBy, and parentSessionKey; this establishes the intended authorization source that the history path was missing. (src/agents/tools/sessions-list-tool.ts:233, 59982714ee48)
  • Patch uses the canonical policy and fences the read: The branch fetches only the exact target through sessions.describe, checks that durable row with the existing row checker, returns an expected session id only for a granted row, and retains the existing fail-closed guard if the row is unavailable. The history tool then passes that expected id to the scoped access admission before chat.history. (src/agents/tools/sessions-access.ts:56, 3686e66076f2)
  • Gateway contract supports the exact-row lookup: Current Gateway sessions.describe loads the requested canonical session entry and returns a buildGatewaySessionRow result, so the patch is not inventing a parallel store or ownership source. (src/gateway/server-methods/sessions-read.ts:614, 59982714ee48)
  • Incarnation admission contract: The existing scoped-access helper rereads the local session entry and rejects a changed or archived sessionId both when admitting and revalidating the protected work, which is the appropriate existing fence for a describe-to-history race. (src/agents/tools/scoped-session-access.ts:7, 990fdcf6fd0e)
  • Current-main and PR provenance: The PR head is not contained in current origin/main; its merge base is e4b6bde45a0769865219fa0b086618c66decdc13, so current main has not already incorporated this repair. The current main commit is unreleased relative to the supplied latest release v2026.7.1; the PR head is likewise in no local release tag. (src/agents/tools/sessions-history-tool.ts:434, 3686e66076f2)

Likely related people:

  • steipete: Current-main blame attributes the direct-key guard, history authorization call site, and scoped incarnation admission to Peter Steinberger; the available local history is shallow, so this is a recent-maintenance routing signal rather than exclusive ownership. (role: recent area contributor; confidence: medium; commits: 990fdcf6fd0e; files: src/plugin-sdk/session-visibility.ts, src/agents/tools/sessions-history-tool.ts, src/agents/tools/scoped-session-access.ts)

Rank-up moves

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

  • Obtain a maintainer decision on durable parent-lineage history access.
  • Refresh and inspect the failed required-check results on the exact reviewed head before merge.

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 (8 earlier review cycles)
  • reviewed 2026-07-26T23:46:12.307Z sha 159db2b92fccb152345b44b8ae29601b28eaf24b :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T00:13:01.735Z sha d42d1ce759025a2775340d0115b91f819ec90669 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T00:27:41.492Z sha d42d1ce759025a2775340d0115b91f819ec90669 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-27T20:22:17.785Z sha 1aa1ed5334c4842ba3c5abe1284dc59a8cceee4e :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T20:47:46.265Z sha 1aa1ed5334c4842ba3c5abe1284dc59a8cceee4e :: needs maintainer review before merge. :: none
  • reviewed 2026-07-27T21:41:15.974Z sha c4018c01cfcbe0ad347572b545be737f21211247 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-03T05:24:21.408Z sha c4018c01cfcbe0ad347572b545be737f21211247 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-03T20:03:50.656Z sha d49a7ae1436a7ac3f1887bcd071c0326e464d626 :: needs maintainer review before merge. :: none

@HOYALIM
HOYALIM force-pushed the codex/issue-114180-session-tree-direct-access branch from 159db2b to d42d1ce Compare July 27, 2026 00:08
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 27, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 27, 2026
@HOYALIM
HOYALIM force-pushed the codex/issue-114180-session-tree-direct-access branch from d42d1ce to 1aa1ed5 Compare July 27, 2026 20:16
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 27, 2026
@HOYALIM
HOYALIM force-pushed the codex/issue-114180-session-tree-direct-access branch from 1aa1ed5 to c4018c0 Compare July 27, 2026 21:36
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Aug 3, 2026
@HOYALIM
HOYALIM force-pushed the codex/issue-114180-session-tree-direct-access branch from c4018c0 to d49a7ae Compare August 3, 2026 19:48
@HOYALIM
HOYALIM force-pushed the codex/issue-114180-session-tree-direct-access branch from d49a7ae to 3686e66 Compare August 3, 2026 21:28
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Aug 18, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M stale Marked as stale due to inactivity 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.

[Bug]: sessions_history denies a child session that sessions_list returns, once the child-link recency window lapses

2 participants