Skip to content

fix: avoid SQLite schema warnings for unrelated runtime edits - #1456

Merged
steipete merged 1 commit into
mainfrom
steipete/magical-burnell-bca12a
Sep 5, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/magical-burnell-bca12a

Conversation

@steipete

@steipete steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where contributors receive a false SQLite table change warning when a runtime-only edit shares a file with unchanged table setup. The confirmed example changes refresh() to refresh(true) and a diagnostic suffix from a string to null in another diff hunk; the database schema does not change.

Why This Change Was Made

The producer previously joined the whole patch when looking for unchanged table context and used one case-insensitive pattern for both raw SQL columns and JavaScript properties. This combined unrelated hunks and interpreted suffix: null as a SQL declaration.

Unchanged SQL/ORM table context now applies only within the changed declaration's hunk. Raw SQL columns remain case-insensitive; ORM properties require supported column-builder calls. Direct changed table DDL, genuine same-hunk columns, and conservative likely-schema uncertainty remain detectable. Approval and compatibility-proof gates are not weakened. Serialization and filename/path-ownership classification are outside this change.

User Impact

Runtime-only changes no longer receive an invented SQLite schema warning. Genuine table changes continue to receive their warning and compatibility-proof requirements. The detector remains a bounded lexical heuristic, not a complete SQL/JavaScript parser.

OpenClaw Bay Impact

Unaffected: no observer API, fields, routes, or controls change.

Documentation Impact

Updated active implementation guidance in docs/pr-review-comments.md and added one Unreleased changelog entry. Reviewed AGENTS.md, CONTRIBUTING.md, docs/README.md, and the proposed material-SQLite-change policy; the proposal remains untouched and grants no new enforcement authority.

Evidence

Reviewed head: 5f3f045d394bb7309eed889890062ead311f4ab6.

The regression suite covers the supplied cross-hunk repro, same-hunk runtime values/type annotations, independently tested hunk locality, lowercase/NULL/NUMERIC SQL columns, ORM builder calls, added/changed/removed declarations, direct DDL, normalized input, and contributor-visible warnings/readiness/automation markers.

The new negative regressions failed before the source fix: 121 passed, 34 failed. The initial fixed run passed all 155 focused tests. A fresh pre-commit Codex review found no actionable P0–P2 findings.

At this head, pnpm run build and node --test test/pr-surface-policy.test.ts passed all 155 focused tests with no failures. The committed branch also passed a fresh isolated Codex review against current main, with no actionable P0–P2 findings. Required repository checks remain mandatory before merge.

Real Behavior Proof

Claim and surface: the compiled SQLite/data-model producers reject the supplied runtime-only false positive while continuing to classify genuine table changes. Equivalent before/after programs are executed against real in-memory SQLite databases using Node's DatabaseSync; sqlite_schema, PRAGMA table_info, diagnostic values, and refresh calls provide the observable result.

Environment: local macOS, Node 24+, repository-pinned pnpm. All inputs are synthetic; no hosted workflow, production database, or live publication is used for this proof.

Observed result at the reviewed head: the baseline at da713f68d3fd46a1e6b123da5d709062b412cd1b reports a SQLite change for the supplied patch; this head reports neither a SQLite nor a data-model change. Actual SQLite schemas stay identical while diagnostics/refresh behavior change. Three positive controls change actual columns and remain detected: a normal SQL column, a raw SQL NULL column, and ALTER TABLE.

{
  "outcome": "PASS",
  "head": "5f3f045d394bb7309eed889890062ead311f4ab6",
  "node": "v24.20.0",
  "platform": "darwin",
  "runtimeSchemaUnchanged": true,
  "baseline": {
    "sqlite": {
      "change": true,
      "files": [
        "src/runtime/controller.ts"
      ]
    },
    "dataModel": {
      "change": false,
      "surfaces": []
    }
  },
  "candidate": {
    "sqlite": {
      "change": false,
      "files": []
    },
    "dataModel": {
      "change": false,
      "surfaces": []
    }
  },
  "positiveControls": [
    {
      "name": "SQL column",
      "sqliteChange": true,
      "dataModelChange": true,
      "columns": [
        "revision",
        "id"
      ]
    },
    {
      "name": "SQL NULL column",
      "sqliteChange": true,
      "dataModelChange": true,
      "columns": [
        "suffix",
        "id"
      ]
    },
    {
      "name": "ALTER TABLE",
      "sqliteChange": true,
      "dataModelChange": true,
      "columns": [
        "id",
        "revision"
      ]
    }
  ]
}

Reproduction: run the following from the repository root on the reviewed head. The baseline commit must be available locally.

pnpm run build
node --input-type=module <<'NODE'
import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import { stripTypeScriptTypes } from "node:module";
import { DatabaseSync } from "node:sqlite";
import { pathToFileURL } from "node:url";
import { resolve } from "node:path";
import { runInNewContext } from "node:vm";

const candidate = await import(pathToFileURL(resolve("dist/clawsweeper-change-detection.js")).href);
const baselineSource = execFileSync("git", ["show", "da713f68d3fd46a1e6b123da5d709062b412cd1b:src/clawsweeper-change-detection.ts"], { encoding: "utf8" });
const baselineJs = stripTypeScriptTypes(baselineSource).replace('"./openclaw-file-role.js"', JSON.stringify(pathToFileURL(resolve("dist/openclaw-file-role.js")).href));
const baseline = await import(`data:text/javascript;base64,${Buffer.from(baselineJs).toString("base64")}`);
const filename = "src/runtime/controller.ts";
function detect(module, patch) {
  const context = { issue: {}, comments: [], timeline: [], counts: { comments: 0, timeline: 0 }, pullFiles: [{ filename, patch }] };
  return {
    sqlite: module.sqliteSchemaChangeFromContext("openclaw/openclaw", context),
    dataModel: module.dataModelChangeFromContext("openclaw/openclaw", context),
  };
}
function execute(source) {
  const db = new DatabaseSync(":memory:");
  const refreshCalls = [];
  try {
    const diagnostic = runInNewContext(`${source}\n;typeof diagnostic === "undefined" ? null : diagnostic;`, { db, refresh: (...args) => refreshCalls.push(args) }, { timeout: 1000 });
    return JSON.parse(JSON.stringify({ diagnostic, refreshCalls, schema: db.prepare("SELECT name, sql FROM sqlite_schema WHERE type = 'table' ORDER BY name").all(), columns: db.prepare("PRAGMA table_info(sessions)").all() }));
  } finally { db.close(); }
}
const patch = '@@ -1,2 +1,2 @@\n db.exec("CREATE TABLE sessions (id TEXT)");\n- refresh();\n+ refresh(true);\n@@ -40,3 +40,3 @@\n const diagnostic = {\n-  suffix: "none",\n+  suffix: null,\n };';
const before = execute('db.exec("CREATE TABLE sessions (id TEXT)");\nrefresh();\nconst diagnostic = { suffix: "none" };');
const after = execute('db.exec("CREATE TABLE sessions (id TEXT)");\nrefresh(true);\nconst diagnostic = { suffix: null };');
assert.deepEqual(before.schema, after.schema);
assert.deepEqual(before.columns, after.columns);
assert.notDeepEqual(before.diagnostic, after.diagnostic);
assert.notDeepEqual(before.refreshCalls, after.refreshCalls);
const oldResult = detect(baseline, patch);
const fixedResult = detect(candidate, patch);
assert.deepEqual(oldResult, { sqlite: { change: true, files: [filename] }, dataModel: { change: false, surfaces: [] } });
assert.deepEqual(fixedResult, { sqlite: { change: false, files: [] }, dataModel: { change: false, surfaces: [] } });
const controls = [
  ["SQL column", 'db.exec(`CREATE TABLE sessions (\n  revision integer,\n  id TEXT\n);`);', '@@\n db.exec(`CREATE TABLE sessions (\n+  revision integer,\n   id TEXT\n );`);'],
  ["SQL NULL column", 'db.exec(`CREATE TABLE sessions (\n  suffix NULL,\n  id TEXT\n);`);', '@@\n db.exec(`CREATE TABLE sessions (\n+  suffix NULL,\n   id TEXT\n );`);'],
  ["ALTER TABLE", 'db.exec("CREATE TABLE sessions (id TEXT)");\ndb.exec("ALTER TABLE sessions ADD COLUMN revision INTEGER");', '@@\n db.exec("CREATE TABLE sessions (id TEXT)");\n+db.exec("ALTER TABLE sessions ADD COLUMN revision INTEGER");'],
].map(([name, program, changedPatch]) => {
  const actual = execute(program);
  assert.notDeepEqual(before.schema, actual.schema, name);
  assert.notDeepEqual(before.columns, actual.columns, name);
  const detection = detect(candidate, changedPatch);
  assert.equal(detection.sqlite.change, true, name);
  assert.equal(detection.dataModel.change, true, name);
  return { name, sqliteChange: true, dataModelChange: true, columns: actual.columns.map((column) => column.name) };
});
console.log(JSON.stringify({ outcome: "PASS", head: execFileSync("git", ["rev-parse", "HEAD"], { encoding: "utf8" }).trim(), node: process.version, platform: process.platform, runtimeSchemaUnchanged: true, baseline: oldResult, candidate: fixedResult, positiveControls: controls }, null, 2));
NODE

Limits: this proves the compiled classifier boundary and actual SQLite schema outcomes for these fixtures, not hosted review/publication or database migration safety. The focused regression suite separately verifies report generation, visible warnings, readiness, and compatibility-proof gates. No real-user data or agent transcript is included.

Keep unchanged table context within its diff hunk and distinguish raw SQL
columns from ORM builder calls so runtime properties such as suffix: null
do not invent a persisted schema change.

Preserve direct DDL detection, genuine SQL/ORM columns, likely-schema
uncertainty, approval boundaries, and compatibility-proof requirements.
Add raw and production-normalized regressions covering classification,
report warnings, readiness, and automation markers.

Validated with 155 focused tests, the complete repository check, and a real
in-memory SQLite replay showing unchanged schemas for runtime-only edits
and changed schemas for positive SQL-column and ALTER TABLE controls.
@clawsweeper

clawsweeper Bot commented Sep 5, 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.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. 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 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 2:50 PM ET / 18:50 UTC.

ClawSweeper review

What this changes

The PR prevents unrelated runtime edits from triggering SQLite schema warnings by limiting table context to the same diff hunk and distinguishing SQL columns from runtime properties.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on the pinned main revision. The patch is focused, the supplied real SQLite proof supports its claim, and no actionable correctness or security defect was found.

Priority: P2
Reviewed head: 5f3f045d394bb7309eed889890062ead311f4ab6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with convincing real SQLite proof, broad regression coverage, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied macOS Node 24 trace exercises the compiled production classifiers against real SQLite schema outcomes at the reviewed head: the runtime-only false positive disappears and three genuine schema-change controls remain detected; hosted publication is explicitly outside this proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The supplied macOS Node 24 trace exercises the compiled production classifiers against real SQLite schema outcomes at the reviewed head: the runtime-only false positive disappears and three genuine schema-change controls remain detected; hosted publication is explicitly outside this proof.
Evidence reviewed 7 items Applicable repository policy: Read the full root AGENTS.md and CONTRIBUTING.md. Applied the narrow-change, real-behavior-proof, review-only, and Bay-impact requirements. No nested AGENTS.md or maintainer-notes directory was found.
Current main still contains the defect: Pinned main joins all patch hunks when finding table context and accepts colon-separated runtime values such as suffix: null as declarations. The introduced diff replaces both mechanisms; the supplied trigger therefore remains source-reproducible on main.
Introduced implementation and preserved boundaries: The changed detector uses individual hunks and separate SQL-column and ORM-call patterns. Direct table DDL, likely-schema uncertainty, production-path filtering, and the existing upgrade-proof evaluator remain intact. Input compaction preserves diff prefixes and hunk headers.
Findings None None.
Security None None.

How this fits together

ClawSweeper classifies incoming OpenClaw PR patches for possible database changes. Those classifications feed stored review reports, contributor warnings, and compatibility-proof requirements.

flowchart TD
  A[OpenClaw PR patches] --> B[Production file filtering]
  B --> C[SQLite change detection]
  C --> D[Changed table or same-hunk column]
  D --> E[Stored review classification]
  E --> F[Warnings and compatibility checks]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test delta Production +14/-12; tests +166/-0 The small classifier adjustment is justified by a concrete false positive and supported by extensive boundary and output regressions.

Technical review

Best possible solution:

Keep schema warnings tied to concrete changed declarations while retaining conservative handling of incomplete schema patches and existing compatibility-proof gates.

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

Yes. On pinned main, unchanged CREATE TABLE context in one hunk combines with suffix: null in another to trigger the SQLite warning; source inspection establishes the path, and the contributor supplies a before/after runtime trace.

Is this the best way to solve the issue?

Yes. Reusing the existing hunk-local classification pattern and requiring ORM builder calls directly addresses the two false-positive mechanisms without adding configuration or a parallel detector.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This corrects misleading schema warnings and unnecessary review friction without evidence of an urgent runtime outage.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied macOS Node 24 trace exercises the compiled production classifiers against real SQLite schema outcomes at the reviewed head: the runtime-only false positive disappears and three genuine schema-change controls remain detected; hosted publication is explicitly outside this proof.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The supplied macOS Node 24 trace exercises the compiled production classifiers against real SQLite schema outcomes at the reviewed head: the runtime-only false positive disappears and three genuine schema-change controls remain detected; hosted publication is explicitly outside this proof.

Label justifications:

  • P2: This corrects misleading schema warnings and unnecessary review friction without evidence of an urgent runtime outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The supplied macOS Node 24 trace exercises the compiled production classifiers against real SQLite schema outcomes at the reviewed head: the runtime-only false positive disappears and three genuine schema-change controls remain detected; hosted publication is explicitly outside this proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied macOS Node 24 trace exercises the compiled production classifiers against real SQLite schema outcomes at the reviewed head: the runtime-only false positive disappears and three genuine schema-change controls remain detected; hosted publication is explicitly outside this proof.

Evidence

What I checked:

  • Applicable repository policy: Read the full root AGENTS.md and CONTRIBUTING.md. Applied the narrow-change, real-behavior-proof, review-only, and Bay-impact requirements. No nested AGENTS.md or maintainer-notes directory was found. (AGENTS.md:74, 5f3f045d394b)
  • Current main still contains the defect: Pinned main joins all patch hunks when finding table context and accepts colon-separated runtime values such as suffix: null as declarations. The introduced diff replaces both mechanisms; the supplied trigger therefore remains source-reproducible on main. (src/clawsweeper-change-detection.ts:245, f9deb128e547)
  • Introduced implementation and preserved boundaries: The changed detector uses individual hunks and separate SQL-column and ORM-call patterns. Direct table DDL, likely-schema uncertainty, production-path filtering, and the existing upgrade-proof evaluator remain intact. Input compaction preserves diff prefixes and hunk headers. (src/clawsweeper-change-detection.ts:245, 5f3f045d394b)
  • Regression coverage reaches contributor output: Read the complete added tests. They cover raw and normalized patches, cross-hunk isolation, runtime values, SQL and ORM declarations, direct DDL, report fields, visible warnings, readiness, and automation markers. The body reports 155 passing focused tests; this read-only review did not execute tests. (test/pr-surface-policy.test.ts:1315, 5f3f045d394b)
  • Real behavior proof at the reviewed head: The complete supplied PR body records macOS Node v24.20.0 output from the compiled production classifiers and real in-memory SQLite. The runtime-only fixture preserves sqlite_schema and table_info while classification changes from a false SQLite warning to no warning; three actual SQL schema-change controls remain detected. The proof explicitly excludes hosted publication. Embedded commands were inspected, not executed. (5f3f045d394b)
  • Area history and routing: Main-branch path history records repeated classifier work by Peter Steinberger and SQLite-warning work by Patrick Erichsen. Raw commit records were inspected for the listed commits. Deeper blame and pickaxe inspection could not complete because required historical objects were unavailable and GitHub DNS failed; no exact-line introduction is attributed. (src/clawsweeper-change-detection.ts, 9c5763013261)

Likely related people:

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

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.

@steipete
steipete merged commit 0c05db6 into main Sep 5, 2026
22 checks passed
@steipete
steipete deleted the steipete/magical-burnell-bca12a branch September 5, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant