Skip to content

fix(memory): automations linked to older dashboard chats get no memory access - #182345

Merged
jalehman merged 4 commits into
mainfrom
openclaw-0d5.21/backfill-dashboard-chat-type
Oct 24, 2026
Merged

jalehman merged 4 commits into
mainfrom
openclaw-0d5.21/backfill-dashboard-chat-type

Conversation

@jalehman

@jalehman jalehman commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: automations linked to a dashboard chat created on v2026.10.6 or earlier still get no memory access after upgrading. Those chats have no stored chat type, so the memory audience check refuses them (root session ... has no durable chat type).

User Impact

After openclaw doctor --fix, automations linked to an older dashboard chat get the same memory access as automations linked to a chat created today. Owner-saved jobs get the owner-private vault. Older jobs with no recorded owner get that chat's conversation memory instead of being refused. Group and channel sessions stay unchanged.

Why This Change Was Made

#181359 records chatType: "direct" only when sessions.create/chat.send creates a new dashboard root. It has no backfill, so older dashboard roots keep a null chat type until a webchat turn runs in them. Chats that were only driven by sessions_send, cron, or the agent method never get one. This PR adds a Doctor row repair that records the same stamp on rows that provably are such roots. Doctor owns legacy-state normalization, so runtime code stays unchanged.

Eligibility rule (isUnstampedDashboardRoot). This is the creation-time newDashboardRoot condition rebuilt from durable facts. A row qualifies only when all of these hold:

  • chatType is unset and createdVia === "operator"
  • the key is agent:<id>:dashboard:<…> and is not an incognito key, and the row is not incognito
  • parentSessionKey is that agent's main session key under the current session.mainKey. That is the dashboard-root grouping link.
  • the row has no spawnedBy, forkSource, or pluginOwnerId, and no external delivery route

Channel and group sessions are created via channel, never operator. An operator can create a row with a channel-shaped key, and v2026.10.6 also parents that row to main, so the dashboard-key check is what excludes it. The upgrade proof below covers exactly that row. A dashboard root from before roots were grouped under main (July 2026) has no parent link and stays unstamped. That is an accepted gap: those rows can't be told apart from operator-created explicit children.

There is no runtime "stamp on next chat.send" change. Gateway client turns already record ChatType: "direct" (gateway-client-identity.ts). On Josh's live install, every operator dashboard root that has run a webchat turn already has direct. The null rows are the ones driven only by sessions_send, cron, or agent, and only Doctor can reach those.

Scope: one new Doctor module plus one call in doctor-session-transcripts.ts. The call sits next to the existing exec-policy row repair and uses the shared repairCanonicalSessionEntries scan/rewrite. No changes to the cron Doctor check from the sibling card.

Evidence

  • Unit tests in src/commands/doctor-session-dashboard-chat-type.test.ts (18 tests). They cover the predicate's accept case, the configured mainKey, and every reject branch: existing chat type, channel/spawn/unstamped creation, spawned child, fork, plugin owner, incognito row and key, external delivery, explicit or missing parent, channel-shaped key, the main session, and a cross-agent parent. A Doctor integration test checks three things: preview changes nothing, --fix stamps only the eligible root, and the rerun is a no-op. The only change to the repaired row is chatType; its session ID and lifecycle revision stay the same, so linked jobs keep their captured parent incarnation. src/commands/doctor-session-exec-policy.test.ts (shared repair path) also passes. pnpm tsgo:core and pnpm tsgo:core:test pass; oxlint/oxfmt are clean on changed files.
  • Replay over stored data (read-only, Josh's live state, 19 agent DBs, 978 session rows). 36 rows have createdVia: operator, a dashboard key, and a null chat type, and all 36 are eligible. Zero group/channel rows match. The 36 rows are main 5, fm-base 8, fm-skills 8, fm-both 7, fm-know 7, douglas 1. Two cron jobs link to an eligible row, both disabled. No row loses access.
  • Upgrade proof from v2026.10.6 (Crabbox, AWS): AWS us-east-1 lease cbx_ea109a58f557 (c7a.8xlarge), run run_f46c44aa8d12fffa38458232311a8c5a, exit 0, lease released. Tested source: this PR's production files byte-identical to head 3a05c30b748 (the commit after the proof only changes the test's mock), on base e96f6921f32, plus local-only proof tooling (a QA memory provider and a fake CLI that calls it through the loopback MCP bridge). An earlier eu-west-1 run on 542600bf42b (run_a62f9a8a3074538b6516953b9fd0296f) gave the same result.
    • Setup on v2026.10.6 (npm [email protected], isolated state): sessions.create makes a dashboard chat, an operator-created row with a channel-shaped key (agent:main:discord:group:proof-123), and an incognito root, and each gets a linked cron job. Both stored rows have chatType: null and parentSessionKey: agent:main:main.
    • openclaw doctor --fix on this branch prints Recorded 1 dashboard chat(s) as direct chats … agent:main:dashboard:a8c7c677-…. The dashboard row becomes chatType: "direct" with the same lifecycle revision. The channel-shaped row stays null. Linked jobs are unchanged across the upgrade.
    • Allowed: the owner-saved job linked to the pre-upgrade dashboard chat gets audience {"kind":"owner-private","agentId":"main"} → OWNER-PRIVATE-NOTE. The pre-upgrade job (no recorded owner) gets that chat's conversation audience → CONVERSATION-NOTE. Before this change, both were denied with root session … has no durable chat type (2b upgrade proof).
    • Refused: the jobs linked to the channel-shaped root (pre-upgrade and owner-saved) are still denied: memory audience unavailable: root session agent:main:discord:group:proof-123 has no durable chat type. The incognito-linked job stays paused because its conversation is unavailable after the restart. That is existing behavior, unrelated to this repair.

@clawsweeper

clawsweeper Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@jalehman jalehman changed the title fix(memory): automations linked to dashboard chats from before v2026.10.7 get no memory access fix(memory): automations linked to older dashboard chats get no memory access Oct 24, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Doctor records missing direct-chat metadata on eligible older dashboard sessions so linked automations can access memory.

Example: An automation links to agent:main:dashboard:7d3c1f00-0000-4000-8000-000000000001 created before chat-type stamping.

  • Before: Memory resolution refuses the run because its root has no durable chat type.
  • After: After openclaw doctor --fix, the root records direct; an owner occurrence gets owner-private memory and an occurrence without owner authority gets conversation memory.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused persisted-state repair with supplied shipped-command upgrade evidence, meaningful exclusion tests, and no identified defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied isolated v2026.10.6 upgrade exercises Gateway-created legacy sessions, the real Doctor command, scheduled jobs, and CLI loopback provider calls using unchanged production files: eligible owner and non-owner jobs reach their proper partitions, while excluded roots remain refused; linked merged proof covers reset and requester revocation through the unchanged final-effect owners.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Automations linked to older dashboard chats cannot use memory after upgrading.
Reason: This maintainer-authored repair restores the behavior already intended for dashboard roots and explicitly accepts the conservative exclusion of historically ambiguous rows.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current upgrade gap through the existing Doctor repair owner; no actionable correctness or security defect was found.

Priority: P2
Reviewed head: 3a05c30b748f8307d186a582528055078b1e44ae

Before merge

None.

Findings

None.

Agent review details

How this fits together

Doctor normalizes persisted session rows before runtime use; the existing memory resolver consumes their chat type, current occurrence authority, and session-generation facts to grant or refuse provider access.

flowchart LR
  A[Legacy dashboard session] --> B[Doctor eligibility check]
  B --> C[Canonical row repair]
  C --> D[Scheduled occurrence admission]
  D --> E[Memory audience resolver]
  E --> F[Provider authority guard]
  F --> G[Memory partition]
Loading

Technical review

Best possible solution:

Land the bounded Doctor backfill while preserving the existing memory audience and revocation owners.

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

Current source denies roots without a durable chat type, and the supplied stable-release upgrade reproduction demonstrates that failure for legacy dashboard-linked jobs; no target code was executed during this review.

Is this the best way to solve the issue?

The repair restores an existing session invariant through Doctor's canonical transaction owner, with conservative eligibility and no competing runtime fallback.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Dashboard chat type and memory documentation keeps the original intent (36f471b: Dashboard roots need a durable direct-chat fact before their first webchat turn; occurrence authority independently selects the memory partition.)
  • Doctor session repair ordering and shared mutation ownership keeps the original intent (60f7030: Consolidate Doctor mutation and reporting mechanics while preserving migration ordering and lifecycle boundaries.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +80, Tests +154, Docs +4. Total +238 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 80 0 +80
Tests 1 154 0 +154
Docs 1 5 1 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 239 1 +238

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Older dashboard-linked automations lose memory access after upgrade; the affected state is bounded and Doctor can repair it without changing runtime policy.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (1 earlier review cycle)
  • reviewed 2026-10-24T07:13:07.392Z sha f398528 :: needs maintainer review before merge. :: none

Reviewed October 24, 2026, 3:51 AM ET / 07:51 UTC (Revision 2).

@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: M labels Oct 24, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 24, 2026
@clawsweeper clawsweeper Bot removed the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Oct 24, 2026
@jalehman
jalehman merged commit 8e5741e into main Oct 24, 2026
135 of 140 checks passed
@jalehman
jalehman deleted the openclaw-0d5.21/backfill-dashboard-chat-type branch October 24, 2026 08:16
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 25, 2026
…y access (openclaw#182345)

* fix(doctor): record pre-existing dashboard roots as direct chats

* docs(memory): note the Doctor chat-type backfill for older dashboard chats

* fix(doctor): describe the chat-type backfill without implying owner access

* test(doctor): keep real note exports in the chat-type backfill test
RomneyDa added a commit that referenced this pull request Oct 28, 2026
…y access (#182345)

* fix(doctor): record pre-existing dashboard roots as direct chats

* docs(memory): note the Doctor chat-type backfill for older dashboard chats

* fix(doctor): describe the chat-type backfill without implying owner access

* test(doctor): keep real note exports in the chat-type backfill test

Backport adaptation: retain beta.5 branch-native fixture APIs and existing regression coverage; no donor behavior omitted.

Source-commit: 8e5741e
Canonical-group: final-p0-r0b-8e5741ef75bc
Co-authored-by: RomneyDa <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 29, 2026
Release adaptation of 50b532d (#183153). The backport of #182345
(51f63cb) exported isUnstampedDashboardRoot only for its unit test.
Main made it private and drove the eligibility cases through
repairLegacyDashboardChatTypes using a canonical-repair fixture this
branch does not carry. Keep every accepted and rejected row case, now
asserted through the repair boundary with the branch's session accessor.
RomneyDa added a commit that referenced this pull request Oct 29, 2026
…eadcode after backports (#187570)

* refactor: keep Teams allowlist sentinel private (#185484)

The Microsoft Teams fail-closed allowlist sentinel now remains module-private while preserving its exact restrictive projection and lifecycle coverage.

(cherry picked from commit 59b1ddd)

* test: teach the live-wrapper fake Bun to answer --revision

Partial cherry-pick of the test/scripts/test-live.test.ts hunk only.
#173807 (backported as e72f868) made the CI Bun --revision probe
mandatory; the fake Bun fixture must answer it from the checkout pin.

(cherry picked from commit 08dd80a)

* test(ci): expect watchdog exit 124 from wedged run-tsgo

#184639 (backported as d9a91b5) intentionally changed the run-tsgo
watchdog exit from 1 to 124 so CI collectors stop admitting work. Main
realigned this case in run-tsgo-worktree.test.ts (9b14a38); on the
release branch the same watchdog case lives in run-tsgo.test.ts and was
not realigned by the backport.

* test(vitest): keep gateway database-worker routes in canonical order

The beta.5 adaptation of #178415 (23a2bcd) prepended three
integration proofs to gatewayDatabaseWorkerTestFiles. Canonical project
ownership compares that list against sorted discovery, so the
out-of-order entries failed vitest-cli-ownership. Move them to their
sorted positions; routing membership is unchanged.

* refactor: keep Slack reconnect policy private (#181690)

Keeps Slack reconnect policy details module-private while preserving the exact invalid-auth cutoff, reset, and blocked-status behavior.

(cherry picked from commit cd65901)

* fix: keep retired Telegram throttler release private

Telegram hunk of 09f9ec8 (#183086) only. The release-only test
called the private helper directly; its surviving-alias case is already
asserted through releaseRemovedTelegramAccountThrottler, so drop the
duplicate direct call.

(cherry picked from commit 09f9ec8, partial)

* refactor: keep Claude partial-message measurement private

src/agents/cli-output-stream-limits.ts hunk of 28e2774 (#184686) only;
the backport of #184352 left this export without a consumer.

(cherry picked from commit 28e2774, partial)

* refactor: keep managed plugin cache selector private

src/plugins/management-catalog.ts hunk of 2c0c30b (#185269) only;
the backport of #184921 left this export without a consumer.

(cherry picked from commit 2c0c30b, partial)

* refactor(agents): keep requester settle batch callbacks type private

The backport of #181260 (2f7589a) moved RequesterSettleWakeParams
into the state module, leaving RequesterSettleWakeBatchCallbacks exported
only for a test fixture. Main keeps it module-private; type the fixture
through RequesterSettleWakeParams instead.

* refactor(infra): drop unconsumed streaming UTF-8 decoder

The minimal backport of #180861 (8d3183d) added decodeUtf8Chunks as
a prerequisite, but its main consumers (streaming state-migration
importers) were intentionally not backported, so production Knip flags
it. Remove the export and its unit case; decodeUtf8Input is unchanged.

* refactor(scripts): keep pinned Bun CI detection private

The minimal #172625 backport (e6c3639) deferred the dev-tool,
test-runtime and run-format callers that consume isCiEnvironment on main,
so the export has no consumer on the release branch.

* test(update): drop orphaned recovery version-mismatch fixture

The #185692 backport in 39f9bde removed the last consumer of
recoveryVersionMismatch from update-cli.plugin-convergence.test.ts. Main
removed the same fixture in eae9bc4 (#181717).

* test(gateway): type config removal mocks through inline module imports

The release adaptation of #152052 (41aa7a6, de41770) typed its
partial mocks through type-only namespace imports. Knip treats the
secrets runtime namespace as the only consumer of its exports, so the
full-tree scan reported prepareSecretsRuntimeSnapshotRestore and
SecretResolverWarning as unused. Use main's inline typeof import() form.

* refactor(shared): drop unconsumed async-store helper

The backport of #179213 (6d9852d, plus f3fb0e9 registering it
as a wrapper component) took the runWithAsyncStore helper and its test
without the plugin-instance-invocation consumer, leaving
src/shared/async-store.ts unused in production. Remove the helper, its
test and its wrapper-components entry rather than complete a perf change
during beta stabilization.

* chore(knip): model backported perf scripts and Telegram worker fixture

Mirror main's Knip entries for files added by beta.5 backports:
- scripts/perf/{node-event-session-source-measure.mjs,
  stream-dispatch-scope-measure.ts,system-prompt-report-retention.ts}
  as path-invoked script roots (#183931, #183552, #183010);
- the Telegram ingress context Worker fixture loaded by URL (#178909) in
  production ignoreFiles.
Also register scripts/test-security-mail-parser.mjs, the standalone
nodemailer sender-parsing regression added by #187301 (release-only).

* refactor(doctor): keep dashboard migration guard at the repair boundary

Release adaptation of 50b532d (#183153). The backport of #182345
(51f63cb) exported isUnstampedDashboardRoot only for its unit test.
Main made it private and drove the eligibility cases through
repairLegacyDashboardChatTypes using a canonical-repair fixture this
branch does not carry. Keep every accepted and rejected row case, now
asserted through the repair boundary with the branch's session accessor.

* test(agents): hold requester preparation for the settle capacity case after #181260 backport

Backport 2f7589a (#181260) filters delivered child findings from
settle wakes (needsRequesterSettleFindings), so this delivered-row case
no longer reads the child transcript where it injected worker capacity
and failed with 'expected findTranscriptEvent to be called'. Main
realigned the same case in 411b2e6 (#178104): inject capacity at
captureRequesterSessionEntryCurrent and assert the delivered result is
not repeated in the resumed wake. Apply that realignment; the
'Already delivered child results' wording that main also asserts belongs
to #178104's message change, which this branch does not carry.

(adapted from commit 411b2e6)

---------

Co-authored-by: Shakker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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