Repository navigation
refactor(claws): author provenance writes with Kysely - #138932
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 5, 2026, 3:15 AM ET / 07:15 UTC. ClawSweeper reviewWhat this changesReplaces handwritten SQL for Claw agent and package ownership records with schema-typed Kysely queries, preserving installation, update, and removal behavior. Merge readiness⛔ Blocked before merge - 2 items remain This remains useful maintainer-owned cleanup that current main has not absorbed. No actionable correctness defects were found. Priority: P3 Review scores
Verification
How this fits togetherClaws are versioned packages that configure an OpenClaw agent. Their provenance store records installed resources and ownership so subsequent updates, retries, status checks, and removal can distinguish managed resources from independently owned ones. flowchart TD
A[Claw package and operator consent] --> B[Lifecycle plan]
B --> C[Provenance writer]
C --> D{Expected stored state matches}
D -->|Yes| E[Atomic SQLite write]
D -->|No| F[Reject stale operation]
E --> G[Ownership records and runtime cache]
G --> H[Status, update, and removal]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -84. Total -84 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep query construction on the existing synchronous SQLite adapter while preserving exact comparisons, transaction ownership, and post-commit publication. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes a behavior-preserving refactor rather than a reported runtime defect; existing tests and author-reported native/CLI results provide validation context. Is this the best way to solve the issue? Yes, the inspected implementation uses the established store-owned query adapter and removes duplicate SQL definitions. Converting legacy read projections or schema upgrades would introduce separate contracts outside this cleanup. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f9b94860bd73. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
I checked both items in the review at The dependency inspection gap is resolved by direct inspection of the installed, pinned Kysely 0.29.5 SQLite/default compilers and binary-operation, value, expression, and update-set parsers, together with the native Node 24.20.0 SQLite binding and OpenClaw's synchronous executor/cache/transaction owners. The six nullable expected fields compile to The data-model flag does not correspond to a schema or representation change. The diff changes only query construction in two provenance modules. It retains the existing serializers, legacy read projections, clocks, version filters, transaction boundaries and post-commit cache publication. All 52 focused tests passed, including schema-version handoff, runtime-cache and older-column read compatibility. Paired native runs and fresh-process readback matched stored rows, schema, errors and cache outcomes; only generated fixture paths were normalized for cross-run comparison. No migration or schema-version change is required. Twelve commands through the built CLI also passed: create, planning, stale-consent refusal, add, status, update, reopen, removal and final empty-state checks. The checks preserved original installation time and unowned artifacts, verified the updated version and workspace contents, and ended with zero Claw provenance rows and |
|
Merged via squash.
|
What Problem This Solves
Claw root and package provenance writers maintained raw SQL column and placeholder lists alongside their value objects. That duplicate query definition made storage contracts harder to check against the canonical schema.
Why This Change Was Made
The seven current writers and package compare-and-swap queries now use generated-schema Kysely statements. The existing state transaction remains the write owner. Package replacement still deletes the exact expected row and inserts its replacement atomically, including nullable extension metadata and timestamps; the occupancy query remains version-independent and stops after one row. Replay integrity, relationship/origin/independent ownership, empty expected-status filters, affected-row checks, and post-commit provenance-cache publication are preserved. Legacy read projections and consent-bound schema upgrades are unchanged.
User Impact
No intended user-visible change. Consent, replay, update and removal keep their existing persisted ownership and recovery behavior.
Evidence
Production delta: +174/-258, net -84 lines across two files. Tests/test support: unchanged. No schema, config, public API, retention, or recovery-policy changes; no new dependency, cache, or storage abstraction.
The initial native proof command invoked the TypeScript preload as an entry point and did no work. The corrected --import command ran the real owner baseline successfully; the candidate and CLI proof passed without product changes or proof retries. Remaining current-schema read cleanup is separate because nontransactional query-error ownership and legacy physical projections require their own contracts.
Independent Codex P0–P2 review completed three scoped passes with no actionable findings. Full owner/caller/sibling source, pinned compiler/parser/native binding contracts, and all native/CLI receipts were supplied. The acting maintainer also inspected these source contracts and both complete proof harnesses directly.