Skip to content

feat: warn on SQLite schema changes - #1252

Merged
Patrick-Erichsen merged 1 commit into
mainfrom
codex/sqlite-schema-callout
Aug 27, 2026
Merged

Patrick-Erichsen merged 1 commit into
mainfrom
codex/sqlite-schema-callout

Conversation

@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Summary

  • detect production SQLite table/schema changes from the reviewed PR diff
  • show a visible warning beneath What this changes only when that risk exists
  • ignore query-only SQL, documentation examples, and test fixtures

Sample ClawSweeper comment

Warning

SQLite table change

This PR modifies persisted SQLite tables in packages/memory-host-sdk/src/host/memory-schema-base.ts. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

PRs without a detected SQLite table/schema change render no SQLite callout.

Test plan

  • pnpm run build && node --test test/pr-surface-policy.test.ts
  • pnpm run check (3,743 tests passed)

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

path &&
!isDocsPath(path) &&
!/(^|\/)(?:__tests__|examples?|fixtures?|test|tests)(?:\/|$)/i.test(path) &&
!/\.(?:spec|test)\.[^/]+$/i.test(path),
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal priority bug or improvement with limited blast radius. 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 Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 26, 2026, 7:11 PM ET / 23:11 UTC.

ClawSweeper review

What this changes

Adds SQLite table/schema detection for OpenClaw pull-request diffs and renders a prominent warning in the generated ClawSweeper review comment.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 6 items remain

Keep this PR open: the new filename classifier introduces an input-controlled polynomial regular expression, and it silently treats truncated pull-file lists as a clean negative result. The PR body provides test and CI claims but no after-fix real-behavior artifact.

Priority: P2
Reviewed head: 48b156a472c1615b9fb344425df2af24b72cfe85

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused feature is understandable and tested, but concrete correctness/security findings and missing real-behavior proof prevent a merge-ready rating.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body names build, unit-test, and CI results, but supplies no after-fix runtime artifact; add a redacted Crabbox local-container transcript that exercises report generation and shows the warning result. 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.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body names build, unit-test, and CI results, but supplies no after-fix runtime artifact; add a redacted Crabbox local-container transcript that exercises report generation and shows the warning result. 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 5 items Current-main baseline: Current main already has the broader persistent-data-model detector and warning renderer; the proposed change is a narrow SQLite-specific extension rather than a replacement.
Input-dependent regex: The PR adds an unanchored suffix regex with a greedy end-anchored segment to classify GitHub-provided filenames.
CodeQL finding: The supplied review discussion reports that the new regex can run slowly on repeated .spec. input; this is consistent with retrying the greedy suffix from multiple unanchored matches.
Findings 2 actionable findings [P2] Replace the polynomial filename regex
[P2] Mark truncated pull-file scans as incomplete
Security Needs attention Polynomial filename matching can stall review workers: The new unanchored regex can repeatedly attempt its greedy suffix on a filename containing many .spec. or .test. fragments before a slash, creating avoidable CPU work from GitHub-provided input.

Live Verification

Command: pnpm run build && node --test test/pr-surface-policy.test.ts

Result: FAIL (failed) — step 1 run pnpm run build && node --test test/pr-surface-policy.test.ts: previous terminal command was still running after 30 seconds: "pnpm run build && node --test test/pr-surface-policy.test.ts"

$ tsc -p tsconfig.json
✔ config surface reports force human review instead of automerge pass (3.470225ms)
✔ config surface reports preserve security-sensitive markers (1.023451ms)
✔ config surface detector finds schema and plugin manifest additions (1.614421ms)
✔ config surface detector ignores non-semantic docs wording (0.316154ms)
✔ config surface detector finds removed schema keys (0.252755ms)
✔ config surface detector finds schema assembly changes (0.217038ms)
✔ config surface detector fails closed for schema continuation changes (0.339117ms)
✔ config surface detector fails closed for missing patches (0.187832ms)
✔ config surface detector fails closed for truncated file patches (0.261561ms)
✔ config surface detector fails closed for renamed config surface files (0.388219ms)
✔ config surface detector fails closed for truncated pull files (0.318107ms)
✔ data model detector finds persistent schema and embedding metadata changes (3.155183ms)
✔ data model detector ignores query-only and non-semantic docs changes (1.155308ms)
✔ SQLite schema detector finds production table changes and ignores non-schema SQL (1.38495ms)
✔ SQLite schema warning is visible for table changes and absent otherwise (19.622207ms)
✔ data model detector flags path-hinted persisted field declarations (0.59647ms)
✔ data model detector fails closed for missing and truncated likely-surface patches (0.228979ms)
✔ data model reports force human review without migration proof (7.118875ms)
✔ data model warnings escape marker-like surface filenames (1.908563ms)
✔ data model reports can pass when migration proof is recorded (1.98164ms)
✔ data model reports can pass when no migration is required and compatibility is verified (2.379687ms)
✔ data model reports reject explicitly negative migration proof (1.755455ms)
✔ data model reports reject requested future migration proof (2.697344ms)
✔ data model reports reject planned migration tests as proof (2.062733ms)
✔ data model reports reject hypothetical compatibility proof (1.778028ms)
ℹ tests 25
ℹ suites 0
ℹ pass 25
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 334.921195

Assertions:

  • FAIL expect_output: SQLite schema detector finds production table changes and ignores non-schema SQL
  • FAIL expect_output: SQLite schema warning is visible for table changes and absent otherwise

How this fits together

ClawSweeper classifies GitHub pull-file patches, stores the result in a review report, and renders that report into a maintainer-facing comment. This PR adds a SQLite-specific classifier alongside the existing persistent-data-model policy.

flowchart LR
  A[Pull request file patches] --> B[SQLite schema classifier]
  B --> C[Review report front matter]
  C --> D[Comment renderer]
  D --> E[Maintainer warning]
  B --> F[Policy tests]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body names build, unit-test, and CI results, but supplies no after-fix runtime artifact; add a redacted Crabbox local-container transcript that exercises report generation and shows the warning result. 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.
  • Replace the polynomial filename regex (P2) - path comes from GitHub pull-file metadata, and this unanchored expression can retry [^/]+$ from each repeated .spec. or .test. occurrence before a slash. The open CodeQL alert identifies this case; use linear basename/suffix parsing and add an adversarial filename regression so review workers cannot be stalled.
  • Mark truncated pull-file scans as incomplete (P2) - This classifier never checks context.counts?.pullFilesTruncated, unlike the adjacent data-model detector. When GitHub returns only a subset of files, it can return change: false and suppress the new callout even when an omitted file changes a SQLite table; preserve an explicit incomplete state and cover it with a focused test.
  • Resolve security concern: Polynomial filename matching can stall review workers - The new unanchored regex can repeatedly attempt its greedy suffix on a filename containing many .spec. or .test. fragments before a slash, creating avoidable CPU work from GitHub-provided input.
  • Resolve merge risk (P1) - Reviewing a crafted or unusually long filename can consume disproportionate worker CPU until the regex is bounded.
  • Resolve merge risk (P1) - A truncated GitHub pull-file list can omit a SQLite schema change while the new classifier reports no SQLite risk.

Findings

  • [P2] Replace the polynomial filename regex — src/clawsweeper-change-detection.ts:199
  • [P2] Mark truncated pull-file scans as incomplete — src/clawsweeper-change-detection.ts:173
  • [medium] Polynomial filename matching can stall review workers — src/clawsweeper-change-detection.ts:199
Agent review details

Security

Needs attention: The added filename regex has a concrete polynomial-time path on uncontrolled pull-file metadata.

Review metrics

Metric Value Why it matters
Classifier and rendering scope production +155/-1, tests +90; 9 files affected The feature spans detection, durable report metadata, and comment rendering, so incomplete-input behavior must remain consistent end to end.

Merge-risk options

Maintainer options:

  1. Bound classifier input handling (recommended)
    Replace the regex with linear basename/suffix parsing and add an explicit incomplete-result path for truncated pull-file lists before merge.
  2. Pause the SQLite callout
    Do not land the new detector if its incomplete-input behavior and worker-cost safeguards are not wanted for review automation.

Technical review

Best possible solution:

Keep the specialized warning, but use linear filename parsing and explicitly represent incomplete pull-file inspection before publishing a definitive SQLite warning state.

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

Not applicable as a bug report: this PR proposes a new classifier, and source inspection directly identifies its unsafe regex and its missing truncated-list branch.

Is this the best way to solve the issue?

No: the SQLite-specific presentation is a reasonable extension of the existing data-model warning, but it needs bounded matching and an explicit incomplete-scan outcome before it is safe to use.

Full review comments:

  • [P2] Replace the polynomial filename regex — src/clawsweeper-change-detection.ts:199
    path comes from GitHub pull-file metadata, and this unanchored expression can retry [^/]+$ from each repeated .spec. or .test. occurrence before a slash. The open CodeQL alert identifies this case; use linear basename/suffix parsing and add an adversarial filename regression so review workers cannot be stalled.
    Confidence: 0.99
  • [P2] Mark truncated pull-file scans as incomplete — src/clawsweeper-change-detection.ts:173
    This classifier never checks context.counts?.pullFilesTruncated, unlike the adjacent data-model detector. When GitHub returns only a subset of files, it can return change: false and suppress the new callout even when an omitted file changes a SQLite table; preserve an explicit incomplete state and cover it with a focused test.
    Confidence: 0.93

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The PR adds a review-automation feature with two concrete bounded defects that can misclassify pull requests or consume worker time.
  • add merge-risk: 🚨 availability: The new unanchored regex processes GitHub-provided filenames and can impose disproportionate CPU cost on the review worker.
  • 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: The PR body names build, unit-test, and CI results, but supplies no after-fix runtime artifact; add a redacted Crabbox local-container transcript that exercises report generation and shows the warning result. 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: The PR adds a review-automation feature with two concrete bounded defects that can misclassify pull requests or consume worker time.
  • merge-risk: 🚨 availability: The new unanchored regex processes GitHub-provided filenames and can impose disproportionate CPU cost on the review worker.
  • 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: The PR body names build, unit-test, and CI results, but supplies no after-fix runtime artifact; add a redacted Crabbox local-container transcript that exercises report generation and shows the warning result. 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

Security concerns:

  • [medium] Polynomial filename matching can stall review workers — src/clawsweeper-change-detection.ts:199
    The new unanchored regex can repeatedly attempt its greedy suffix on a filename containing many .spec. or .test. fragments before a slash, creating avoidable CPU work from GitHub-provided input.
    Confidence: 0.99

Acceptance criteria:

  • [P1] pnpm run build && node --test test/pr-surface-policy.test.ts.
  • [P1] pnpm run check.
  • [P1] Run the documented focused scenario in Crabbox local-container and attach a redacted current-head transcript showing the warning and incomplete-scan behavior.

What I checked:

Likely related people:

  • Martin Cleary: Current-main blame attributes the existing change-detection and data-model warning path to this commit. (role: introduced adjacent review-policy behavior; confidence: high; commits: 115abf8548e0; files: src/clawsweeper-change-detection.ts, src/clawsweeper-orchestration-foundation.ts)
  • joshavant: Recent history for the affected policy files includes this contributor's authority-review work. (role: recent adjacent contributor; confidence: medium; commits: 868eb60db2fb; files: src/clawsweeper-change-detection.ts, src/clawsweeper-orchestration-foundation.ts)

Rank-up moves

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

  • Replace the filename regex with bounded linear parsing and add a repeated .spec. regression case.
  • Represent truncated pull-file inspection explicitly and test that the published review cannot silently claim a clean SQLite result.
  • Add a redacted after-fix Crabbox local-container transcript to the PR body; a body update should trigger re-review, or a maintainer can request @clawsweeper re-review.

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.

@Patrick-Erichsen
Patrick-Erichsen merged commit a8b2deb into main Aug 27, 2026
18 of 19 checks passed
@Patrick-Erichsen
Patrick-Erichsen deleted the codex/sqlite-schema-callout branch August 27, 2026 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal priority bug or improvement with limited blast radius. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants