Skip to content

feat(gateway): system change history RPC and Ask OpenClaw recent-changes panel - #111286

Merged
steipete merged 3 commits into
mainfrom
claude/system-changes-reader-110896
Jul 19, 2026
Merged

steipete merged 3 commits into
mainfrom
claude/system-changes-reader-110896

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #110896

What Problem This Solves

The config change journal (#111147) records every config mutation — but nothing reads it. Operators still cannot see "what changed on my system, when, by whom" anywhere in the product.

Why This Change Was Made

Phase 3 of #110896:

  • openclaw.changes.list (additive gateway method, operator.admin, Swift/Kotlin protocol clients regenerated): merges the system-agent-audit and config-audit journals newest-first into typed SystemChangeEntry rows (operation / config-write / external-edit, closed source union incl. argv-classified legacy writes). System-agent operations collapse with their matching config write (same hash transition within a 60s window) so one change shows once, enriched with its paths.
  • Robust pagination: opaque cursors freeze both journal heads on the first page (concurrent writes cannot reorder later pages), advance through scanned-but-filtered ranges, carry bounded collapse-suppression markers (with the causal window re-checked at consumption), and cap raw rows scanned per request at 1000/scope so a 50k-row journal cannot stall the gateway event loop — short pages with a nextCursor resume cheaply. Ordering is canonical store-insertion order; payload timestamps are display-only (skewed producer clocks cannot break the page contract).
  • Custodian UI: a History button (shown only when the gateway advertises the method) opens a "Recent changes" panel — source badges (system-agent / doctor / Settings / CLI / plugin install / manual edit), relative times, expandable changed paths, a warning style for manual edits that broke validation, opaque-change note, and cursor-driven Load more.
  • Store: latest({limit, beforeSequence}) bounded newest-first reads on the shared audit record store (no full-scope loads).
  • Docs: "Change history" section in docs/cli/openclaw.md (what is recorded, bounds, path-only privacy).

User Impact

Ask OpenClaw now answers the most common ops mystery visually: who changed the config and when — including hand edits made while the gateway was offline, marked invalid when they broke validation.

history panel

Evidence

  • node scripts/run-vitest.mjs src/gateway/server-methods/system-changes.test.ts — 10 tests pass (merge/collapse/skip, argv classification, newest-first with suppression markers + causal window, clock-rollback ordering, frozen heads across pages, bounded-scan regression with counting store).
  • node scripts/run-vitest.mjs ui/src/pages/custodian — 38 tests pass (gating, panel, cards, expansion, short-page Load more, refresh-on-reopen).
  • node scripts/run-vitest.mjs src/infra/sqlite-audit-record-store.test.ts — 7 pass (latest() bounds).
  • pnpm protocol:gen + :swift + :kotlin + pnpm protocol:check — clean; pnpm ui:i18n:baseline run (en.ts only).
  • Screenshot above from a mocked-gateway Playwright session.
  • Autoreview (codex/gpt-5.6-sol, xhigh): five cycles to clean — final pass reports no accepted/actionable findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: android App: android app: web-ui App: web-ui gateway Gateway runtime size: XL maintainer Maintainer-authored PR labels Jul 19, 2026
@steipete steipete closed this Jul 19, 2026
@steipete steipete reopened this Jul 19, 2026
@clawsweeper

clawsweeper Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 19, 2026, 4:56 AM ET / 08:56 UTC.

Summary
The branch adds openclaw.changes.list, bounded audit-store paging, generated Android/Swift protocol models, a Custodian Recent changes panel, and change-history documentation.

PR surface: Source +1228, Tests +791, Docs +14, Other +95. Total +2128 across 21 files.

Reproducibility: yes. from source: insert records from the two scopes around a producer-clock rollback, and separately place many filtered records after an eligible record to reproduce incorrect ordering and repeated scan work.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: migration/backfill/repair: apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift, migration/backfill/repair: docs/cli/openclaw.md, migration/backfill/repair: packages/gateway-protocol/src/schema/openclaw.ts, migration/backfill/repair: ui/src/i18n/locales/en.ts, migration/backfill/repair: ui/src/pages/custodian/custodian-page.ts, unknown-data-model-change: packages/gateway-protocol/src/schema/openclaw.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦐 gold shrimp
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Fix cross-scope ordering and raw-frontier cursor advancement with focused regressions.
  • Attach redacted live audit-store-to-gateway-to-Custodian output, logs, or a recording; updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review.
  • Obtain maintainer confirmation that the new gateway API is the intended permanent core contract.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Focused tests and a mocked-gateway screenshot are useful supplemental evidence, but a redacted real audit-store-to-gateway-to-Custodian result is still required before merge; redact paths, endpoints, IPs, and credentials. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Merging now can show operators an incorrect newest-first history across journal scopes when producer clocks differ, despite the RPC’s ordering contract.
  • [P1] A sparse audit journal can repeatedly rescan filtered rows on each Load more request, weakening the bounded-work guarantee.
  • [P1] The new operator-admin RPC and native protocol models need explicit product/API ownership, and the provided proof does not demonstrate the real persisted-store-to-UI path.

Maintainer options:

  1. Fix ordering and scan-frontier semantics (recommended)
    Order cross-scope rows by the global diagnostic-event sequence and persist the final raw scanned sequence in the cursor, with focused rollback and sparse-filter regression tests.
  2. Pause for API ownership
    Hold the feature until a maintainer confirms that this gateway method and retained audit-history UX are the intended permanent core contract.

Next step before merge

  • [P1] A maintainer must sponsor the new core protocol/UI direction and assess real behavior proof; the two code defects are concrete but should be resolved within that owned feature decision.

Maintainer decision needed

  • Question: Should OpenClaw expose the new persistent system-change journal as the public operator.admin gateway API and Custodian history surface after the ordering and pagination fixes?
  • Rationale: This is a new core protocol/UI capability rather than a repair to an established public contract, and the PR carries the repository's protected maintainer label.
  • Likely owner: steipete — They introduced the merged journal foundation and authored the proposed reader/API layer.
  • Options:
    • Sponsor the bounded admin history API (recommended): Keep the additive RPC and Custodian panel, contingent on fixing the two correctness defects and adding real end-to-end proof.
    • Keep the journal internal for now: Defer the public RPC/UI until maintainers settle the long-term audit-history API and retention presentation.

Security
Cleared: The diff adds no dependency, workflow, permission, secret-handling, or supply-chain change; the new read endpoint is scoped to operator.admin and presents path-only audit details.

Review findings

  • [P2] Order merged history by the global insertion sequence — src/gateway/server-methods/system-changes.ts:1-635
  • [P2] Persist the final raw scan frontier in the cursor — src/gateway/server-methods/system-changes.ts:1-635
Review details

Best possible solution:

Use the shared diagnostic_events.sequence as the inter-scope ordering and paging authority, advance cursors to the actual raw scan frontier, add regression coverage for both cases, then attach redacted end-to-end audit-store-to-Custodian evidence before maintainer approval.

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

Yes, from source: insert records from the two scopes around a producer-clock rollback, and separately place many filtered records after an eligible record to reproduce incorrect ordering and repeated scan work.

Is this the best way to solve the issue?

No. The panel/RPC concept is plausible, but ordering by producer timestamps and not the shared insertion sequence fails the stated history contract; the cursor must also retain the raw scan frontier.

Full review comments:

  • [P2] Order merged history by the global insertion sequence — src/gateway/server-methods/system-changes.ts:1-635
    The merge comparator uses timestamp-derived audit created_at values, so a later record from one scope can appear behind an earlier record from the other after a producer clock rollback. Use the shared diagnostic-event sequence as the cross-scope ordering key so the advertised canonical newest-first contract holds.
    Confidence: 0.95
  • [P2] Persist the final raw scan frontier in the cursor — src/gateway/server-methods/system-changes.ts:1-635
    When the capped scan consumes filtered rows after its last eligible entry, the next cursor resumes below that eligible entry and rereads the filtered rows. Advance each scope to the last raw scanned sequence once buffered eligible entries are consumed to preserve the bounded-work pagination guarantee.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.92

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P2: This is a meaningful operator-facing feature with concrete correctness defects but no evidence of immediate data loss, security bypass, or core-runtime outage.
  • add merge-risk: 🚨 compatibility: The PR adds a gateway protocol method and regenerated native client models that become a cross-client public contract once merged.
  • add merge-risk: 🚨 other: The advertised canonical newest-first and bounded-pagination semantics can be violated by the current merged-journal implementation.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Focused tests and a mocked-gateway screenshot are useful supplemental evidence, but a redacted real audit-store-to-gateway-to-Custodian result is still required before merge; redact paths, endpoints, IPs, and credentials. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This is a meaningful operator-facing feature with concrete correctness defects but no evidence of immediate data loss, security bypass, or core-runtime outage.
  • merge-risk: 🚨 compatibility: The PR adds a gateway protocol method and regenerated native client models that become a cross-client public contract once merged.
  • merge-risk: 🚨 other: The advertised canonical newest-first and bounded-pagination semantics can be violated by the current merged-journal implementation.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Focused tests and a mocked-gateway screenshot are useful supplemental evidence, but a redacted real audit-store-to-gateway-to-Custodian result is still required before merge; redact paths, endpoints, IPs, and credentials. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +1228, Tests +791, Docs +14, Other +95. Total +2128 across 21 files.

View PR surface stats
Area Files Added Removed Net
Source 11 1236 8 +1228
Tests 6 1315 524 +791
Docs 2 15 1 +14
Config 0 0 0 0
Generated 0 0 0 0
Other 2 95 0 +95
Total 21 2661 533 +2128

What I checked:

  • Current unresolved review: cross-scope ordering: The current review discussion identifies that merged ordering uses timestamp-derived created_at values from each producer rather than the shared diagnostic-event insertion sequence, so a clock rollback can place later writes behind earlier ones across journal scopes. (src/gateway/server-methods/system-changes.ts, 2dccc67e3307)
  • Current unresolved review: filtered-scan cursor frontier: The current review discussion identifies that a capped scan can advance its cursor only to the last eligible row rather than the last scanned raw row, causing filtered rows to be reread on later pages. (src/gateway/server-methods/system-changes.ts, 2dccc67e3307)
  • Feature foundation is already on main: The related config-journal work merged as PR 111147 at commit 3af3493; this PR builds the reader/UI layer rather than duplicating that merged persistence work. (src/infra/sqlite-audit-record-store.ts, 3af349354107)
  • Proof remains mock-only: The PR body reports focused tests and a screenshot from a mocked-gateway Playwright session, but it does not provide a redacted real audit-store-to-gateway-to-Custodian run demonstrating the claimed operator flow. (ui/src/pages/custodian/custodian-page.ts, 2dccc67e3307)
  • Repository policy applied: The full repository AGENTS.md requires additive protocol follow-through, treats persisted-state and gateway changes as compatibility-sensitive, and requires real behavior evidence for user-visible changes. (AGENTS.md, c26d3cfbd049)

Likely related people:

  • steipete: Authored the related merged config-journal implementation and this reader/UI follow-on, making them the clearest history-connected owner for the audit-history boundary. (role: feature owner; confidence: medium; commits: 3af349354107, 2dccc67e3307; files: src/infra/sqlite-audit-record-store.ts, src/gateway/server-methods/system-changes.ts, ui/src/pages/custodian/custodian-page.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-19T07:46:48.020Z sha 5e38909 :: needs real behavior proof before merge. :: none

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5e389099b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +152 to +155
if (command === "config") {
return "cli" as const;
}
return "unknown" as const;

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.

P2 Badge Classify all CLI mutation commands as CLI

For first-party CLI mutations outside openclaw config, such as hooks enable and agents bind, the callers in src/cli/hooks-cli.ts:455 and src/commands/agents.commands.bind.ts:261 omit auditOrigin, so command is hooks or agents and this classifier falls through to unknown. The new panel therefore misattributes normal user-initiated CLI changes; recognize other OpenClaw CLI commands as cli while continuing to prefer explicit origins.

Useful? React with 👍 / 👎.

Comment on lines +365 to +367
function isWithinCollapseWindow(operationAt: number, configAt: number): boolean {
const delay = operationAt - configAt;
return delay >= 0 && delay <= COLLAPSE_MAX_DELAY_MS;

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.

P2 Badge Collapse matching writes across clock rollback

When the wall clock steps backward between the config-write audit and the later operation audit, this directional subtraction is negative, so identical system-agent hash transitions are not collapsed and appear as duplicate changes. The write occurs inside the operation before appendSystemAgentAuditEntry (src/system-agent/operations-execution-helpers.ts:266-269), so causal insertion order remains valid even if payload timestamps regress; the collapse test should tolerate rollback within the intended 60-second window.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f1cae48550

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +353 to +356
function compareCandidates(left: ChangeCandidate, right: ChangeCandidate): number {
// History is insertion-ordered; display time may differ if a producer's clock skewed.
if (left.recordedAt !== right.recordedAt) {
return right.recordedAt - left.recordedAt;

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.

P2 Badge Order merged journals by a genuine insertion clock

When either producer's wall clock rolls back, this does not provide the claimed insertion ordering: appendConfigAuditRecord* stores Date.parse(record.ts) as created_at (src/config/io.audit.ts:681-684), and appendSystemAgentAuditEntry likewise stores its payload timestamp (src/system-agent/audit.ts:44-48), so recordedAt is just another producer timestamp. Consequently, a later operation from one scope can be placed behind an earlier config write from the other scope, and page boundaries can present “newest first” history out of order. Fresh evidence beyond the existing collapse-window comment is that the ordering comparator itself consumes those timestamp-derived created_at values rather than an insertion-order field.

Useful? React with 👍 / 👎.

Comment on lines +300 to +304
return {
entries,
exhausted,
nextBeforeSequence: entries.at(-1)?.sequence ?? beforeSequence,
};

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.

P2 Badge Advance filtered scans to the actual raw-row frontier

When a capped scan finds at least one eligible row and then scans filtered rows, this returns the last eligible sequence instead of the final raw sequence assigned to beforeSequence. For example, one visible write followed by 999 observations consumes the full 1,000-row budget, but the next cursor starts immediately below the visible write and rereads all 999 observations. Sparse eligible rows can therefore make successive Load more requests repeatedly perform synchronous SQLite/JSON work that this frontier-tracking logic is intended to avoid; use the actual scanned frontier once all buffered eligible entries have been consumed.

Useful? React with 👍 / 👎.

@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Jul 19, 2026
@steipete
steipete merged commit b9fa1ff into main Jul 19, 2026
163 of 167 checks passed
@steipete
steipete deleted the claude/system-changes-reader-110896 branch July 19, 2026 09:38
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 20, 2026
…ges panel (openclaw#111286)

* feat(gateway): system change history RPC and Ask OpenClaw recent-changes panel

* test(gateway): fix journal fixtures, split custodian page tests, refresh docs map

* chore: quiet lint on journal reader tests and custodian harness
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…ges panel (openclaw#111286)

* feat(gateway): system change history RPC and Ask OpenClaw recent-changes panel

* test(gateway): fix journal fixtures, split custodian page tests, refresh docs map

* chore: quiet lint on journal reader tests and custodian harness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant