Skip to content

refactor(nostr): share doctor state migration flow - #148647

Merged
vincentkoc merged 2 commits into
mainfrom
refactor/nostr-doctor-state-migrations-current-20260914
Sep 15, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
refactor/nostr-doctor-state-migrations-current-20260914

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

This maintainer-requested refactor is part of the approved duplication and complexity reduction deliverable. Nostr's bus-state and profile-state Doctor migrations repeat the same discovery, capacity check, import and archival flow.

User Impact

No intended migration behavior change. Existing state wins over legacy files, normalized-key collisions keep the first discovered value, and insufficient capacity leaves all legacy sources in place. Registration completes before each source is archived; archive failures remain warnings, while registration failures stop later imports.

Why This Change Was Made

One private migration factory receives each existing namespace, label and parser. Descriptor IDs, order, parsing, account-key normalization and messages are preserved. The validated entries pass through the canonical unknown-valued registration boundary without the former assertions or an unnecessary generic. The SDK's single-file helper has different archival semantics and would not preserve this multi-file flow.

Production: -45 lines. Tests: +193 lines. The assertion baseline changes only this owner's count from four to two; intervening rows are preserved. No schema version or persisted value shape changes.

Evidence

  • Complete owners, tests, runtime readers, Doctor callers, keyed-store operations, archival helper and dependency contracts were inspected. Independent current-source admission at 12daee6db8284d640cd1c1d13b947e990c59d99f found compatible caller/store drift and unchanged owner/test preimages. This source review is separate from the frozen runtime execution below.
  • Normal CI passed on unchanged head a1fac8538ce52cd797892ed6a4d1eac1cf207d18. Actual tested merge 38620ba0a72605d087e3cbdea3e87511ae9e49b2 contains the reviewed owner/test bytes and the row-only baseline composition. Selected static checks passed, including the pinned oxfmt 0.66.0 and oxlint 1.81.0. That CI selection omitted the two database-worker test files; the focused proof below covers them.
  • One managed Testbox proof associated with this workflow used frozen source 38620ba0a72605d087e3cbdea3e87511ae9e49b2, tree 5e4a2998487399e0c0a62b35e4eb7724f110a689. The canonical source capsule used carrier 7ffd04f976a0b2f2d3ffd6350ea91ae419ca31da for native package and registry identity; it did not substitute a different source tree. The reviewed private harness stayed separate from the clean candidate.
  • The normal extension database-worker runner passed 19/19 cases, zero skips: 10 Doctor-contract cases and nine runtime-store cases. The eight added Doctor cases exercise both namespaces' capacity refusal, collisions/existing values, partial registration failure and continued archival failure behavior. Linux x64, Node 24.19.0, pnpm 12.3.4 and Vitest 5.0.0 were observed.
  • The normal Docker planner selected exactly one published-upgrade-survivor lane for [email protected] and nostr-state, with zero omitted scenarios. Package preparation and the joined survivor process both exited zero. Final full candidate/harness source checks, carrier HEAD and clean candidate index passed after the survivor and before the result assertions.

Published Updater and Data Compatibility

  • Official baseline core and Nostr 2026.9.4 tarballs matched the pinned published integrity values. Installed baseline core bytes matched the shipped inventory, package and CLI bin; installed Nostr bytes and its install record matched the served artifact.
  • Four existing SQLite rows were seeded through the baseline's installed SDK. The original explicit-tarball updater and its post-core child both exited zero, with explicit plugin convergence success and no repair/recovery path. Candidate core and Nostr installed bytes matched their independently inventoried candidate artifacts, including the Doctor implementation.
  • The first update preserved the original rows and imported legacy state: 4 to 6 rows, with all four source files archived byte-for-byte before any later Doctor step. A separate set of four legacy files then exercised candidate Doctor: 6 to 8 rows, with eight total byte-exact archives and no active legacy files.
  • Existing raw values, creation timestamps and null TTLs were preserved. Repeating Doctor produced identical full row/archive receipts. Shared schema version 17, metadata, integrity and foreign-key checks passed throughout; no schema bump was introduced.

These results address the three Before merge proof requests and the Rank-up move in the existing exact-head ClawSweeper review. That review found no introduced correctness defect. The exact-head P2 review also completed without findings; its static scope remains separate from execution.

Retained Limits

The first private proof invocation exited 2 because its external verifier incorrectly required an auxiliary post-core snapshot. Its original updater and survivor succeeded, but final source checks were not reached, so that invocation is not qualified. A reviewed verifier-only correction used the canonical explicit update result and correlated process exits, and moved the existing final source checks before derived assertions. The unchanged workload then completed successfully; this invocation also captured a consistent auxiliary snapshot. Follow-up: the first invocation's auxiliary snapshot omission remains unexplained.

The successful capture contains 37 complete hash-verified artifact streams; SHA256 87a285be576f47f3e56d278c23d34c9b2f634c13fe0f88b9f0493a4230e6aa9f. Native lease stop completed. Portal synchronization timed out, so portal publication is unconfirmed; the backing workflow may show cancellation from the owned Testbox shutdown. No live Nostr provider or performance result is claimed.

@vincentkoc vincentkoc self-assigned this Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@vincentkoc
vincentkoc marked this pull request as ready for review September 15, 2026 00:23
@openclaw-barnacle openclaw-barnacle Bot added channel: nostr Channel integration: nostr size: M maintainer Maintainer-authored PR labels Sep 15, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 14, 2026, 11:08 PM ET / September 15, 2026, 03:08 UTC (Revision 2).

ClawSweeper review

What this changes

Shares Nostr’s legacy bus and profile state migration flow while preserving existing import behavior and adding failure-path coverage.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this requested refactor remains useful, and both reported lint corrections are present at the pinned head. No introduced correctness defect was found; the previously requested update-path validation remains outstanding.

Priority: P3
Reviewed head: a1fac8538ce52cd797892ed6a4d1eac1cf207d18

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving refactor with useful boundary coverage and no identified patch defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored internal refactor is exempt from the external-contributor proof gate and changes no authority boundary; the separate repository-required published-updater check remains outstanding.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored internal refactor is exempt from the external-contributor proof gate and changes no authority boundary; the separate repository-required published-updater check remains outstanding.
Evidence reviewed 8 items Pinned lint corrections: GitHub’s exact-head commit patch removes the factory’s nonrelational type parameter and renames the shadowed registration-options parameter. Neither change alters runtime control flow.
Behavior-preserving private consolidation: The complete introduced patch and current module preserve both descriptor IDs, parsers, namespaces, capacity preflight, first-discovered collision handling, and registration-before-archive ordering. The public plugin contract and persisted value shapes are unchanged.
Existing SDK alternative has a different contract: The SDK helper handles one source file and archives after processing all its rows; Nostr discovers multiple account files and preserves per-source partial progress. Reusing that helper directly would not preserve this migration’s ordering and failure behavior.
Findings None None.
Security None None.

How this fits together

Nostr’s Doctor migrations import legacy account files into OpenClaw’s SQLite-backed plugin state and archive successfully handled sources. The channel subsequently reads that state for subscription timing and profile publication history.

flowchart TD
  A[Doctor migration request] --> B[Discover legacy Nostr files]
  B --> C[Parse and normalize account keys]
  C --> D{Enough state capacity?}
  D -->|No| E[Warn and preserve sources]
  D -->|Yes| F[Import missing entries]
  F --> G[Archive handled sources]
  F --> H[Nostr runtime state]
Loading

Before merge

  • Resolve merge risk (P1) - Published-updater-to-candidate integration has not been demonstrated; source equivalence and descriptor tests do not establish that update-path result.
  • Complete next step (P2) - Add the repository-required published-updater-to-candidate migration result to the PR body, showing preserved existing Nostr values and successful archival, with private information redacted.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -45, Tests +193, Other 0. Total +148 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 36 81 -45
Tests 1 194 1 +193
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 3 231 83 +148

Review metrics

Metric Value Why it matters
Production versus test change production −45 lines; tests +193 lines The production reduction removes duplicated orchestration while the test growth covers preservation of migration behavior.

Stored data model

Persistent data-model change detected: migration/backfill/repair: config/assertion-safety-baseline.txt, migration/backfill/repair: extensions/nostr/doctor-contract-api.ts, serialized state: extensions/nostr/doctor-contract-api.ts, unknown-data-model-change: extensions/nostr/doctor-contract-api.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the private Nostr migration factory and unchanged storage contracts, backed by the repository-required upgrade-path validation.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the private Nostr migration factory and unchanged storage contracts, backed by the repository-required upgrade-path validation.

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

Not applicable: this PR removes duplicated migration orchestration rather than reporting a runtime defect; the duplication remains visible on current main.

Is this the best way to solve the issue?

Yes: a private factory preserves Nostr’s multi-file migration semantics without expanding the SDK or introducing a competing state owner.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a requested internal simplification with no intended user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored internal refactor is exempt from the external-contributor proof gate and changes no authority boundary; the separate repository-required published-updater check remains outstanding.

Evidence

What I checked:

  • Pinned lint corrections: GitHub’s exact-head commit patch removes the factory’s nonrelational type parameter and renames the shadowed registration-options parameter. Neither change alters runtime control flow. (extensions/nostr/doctor-contract-api.ts:135, a1fac8538ce5)
  • Behavior-preserving private consolidation: The complete introduced patch and current module preserve both descriptor IDs, parsers, namespaces, capacity preflight, first-discovered collision handling, and registration-before-archive ordering. The public plugin contract and persisted value shapes are unchanged. (extensions/nostr/doctor-contract-api.ts:158, a1fac8538ce5)
  • Existing SDK alternative has a different contract: The SDK helper handles one source file and archives after processing all its rows; Nostr discovers multiple account files and preserves per-source partial progress. Reusing that helper directly would not preserve this migration’s ordering and failure behavior. (src/plugin-sdk/runtime-doctor-migrations.ts:394, a1fac8538ce5)
  • Current main still contains the duplication: Fetched main retains separate bus-state and profile-state migration implementations. The requested consolidation is therefore still distinct work. (extensions/nostr/doctor-contract-api.ts:135, dfaec136991a)
  • Release comparison: The supplied latest release, v2026.9.4, likewise contains the two separate migration descriptors rather than the private factory. (extensions/nostr/doctor-contract-api.ts:135, 3a9d69db306c)
  • Validation and review continuity: The supplied body explicitly claims no runtime migration result. The previous completed review requested published-updater-to-candidate validation, and root policy independently requires that check for Doctor changes. Added tests cover capacity refusal, collisions, registration failure and archive failure in both namespaces; no tests or builds were executed during this read-only review. (AGENTS.md, a1fac8538ce5)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Record the required published-updater-to-candidate result with legacy Nostr state, preserved existing values and successful source archival.

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 (1 earlier review cycle)
  • reviewed 2026-09-15T00:30:27.994Z sha 69355b0 :: blocked before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head a1fac8538ce52cd797892ed6a4d1eac1cf207d18; the two CI lint findings are corrected.

@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@vincentkoc
vincentkoc merged commit c9b49f6 into main Sep 15, 2026
97 of 99 checks passed
@vincentkoc
vincentkoc deleted the refactor/nostr-doctor-state-migrations-current-20260914 branch September 15, 2026 08:31
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 15, 2026
* commit '0cd944c01416c4f9c1f6dc9d1dea9670c5b99cab':
  improve: speed up session search for restricted operators (#148826)
  fix(update): avoid retry guidance for historical abandoned runs (#146982)
  fix(android): reduce queued-message send overhead (#148899)
  refactor(slack): count table cells only for native output (#148872)
  fix: correct update status and apply saved model keys (#148830)
  refactor(nostr): share doctor state migration flow (#148647)
  refactor(gateway): centralize device token denial responses (#148644)
  test: make kitchen sink assertions runtime portable (#148891)
  refactor(agents): share preferred block chunk boundaries (#148391)
  fix(ui): use the selected timezone for Usage date shortcuts (#148277)
  test: probe active Node in release preflight (#148892)
  fix(test): restore services typecheck shard headroom (#148889)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
* refactor(nostr): share doctor state migration flow

* fix(nostr): satisfy doctor migration lint contracts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: nostr Channel integration: nostr maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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