Skip to content

feat(sql-server): add the human-approved write tier - #12075

Merged
melodic-automation-lanes[bot] merged 4 commits into
mainfrom
work-resolve-issue/issue-11228-41339834239-1
Nov 1, 2026
Merged

melodic-automation-lanes[bot] merged 4 commits into
mainfrom
work-resolve-issue/issue-11228-41339834239-1

Conversation

@melodic-automation-lanes

@melodic-automation-lanes melodic-automation-lanes Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #11228

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Adds the write tier from #9909's Fix to the sql-server MCP server. A write tool is flagged _meta\["anthropic/requiresUserInteraction"\]: true and runs one INSERT/UPDATE/DELETE/MERGE in one batch (BEGIN TRANSACTION, the statement, ROWCOUNT compared with expectedRows, then COMMIT or ROLLBACK). An unflagged preview_write tool lists triggers and cascading foreign keys. Both tools appear on every registration, so tools/list never changes, but write refuses every call unless the server starts with --write and the environment's new write.auth block names a write principal separate from the read one. The decisions are recorded as an amendment to ADR 0086. Choices of means and their basis: the opt-in is a launch flag plus a config block, because ADR 0086 defines a registration by its launch arguments and asks for a separate write principal and registration. The write tool stays listed and refuses rather than being hidden, because #5940's Evidence found hidden tools still callable by name and section 2 requires a fixed list. The preview is a separate read tool that takes the target table, so it runs before approval and holds no transaction. S4's optional no-prompt mode is not built; the ADR amendment says it needs its own amendment.

Not verified

  • The plugin's unit tests (npm test in plugins/sql-server, node --test) were not executed here: this lane runs no node or npm command, and check-affected runs suites only with --tests. They are left to the PR's CI test-node lane. Every new assertion was traced by hand and by the review subagent.
  • ci-status green on the PR head is a PR CI check, left to the PR's CI.
  • tidy skipped: the change is over the tidy cutoffs (18 changed files and more than one area: plugins/sql-server with .changes/sql-server, docs/adr, docs/catalog.md).
  • That ROWCOUNT excludes rows changed by triggers and cascades rests on #5940's Evidence, not a primary source read this run. The README and the ADR amendment attribute it that way. Part 2's (#11229) integration run against a real server is where it can be confirmed.
  • The generated T-SQL (the write batch and the preview_write recursive CTE) has not run against a real SQL Server; part 2 (#11229) adds the integration script that does.
  • The setup skill's registration commands still leave out --write and do not forward the write principal's credential variables, so a write registration is added by hand, as the README says. Setup support was not part of this issue.
  • S4's optional no-prompt mode is not built; the ADR amendment records that it needs its own amendment. It is not in #9909's Fix.

Fix

  • plugins/sql-server/src/statement.mjs: new checkWriteStatement, a token-based write reject list. It accepts one INSERT, UPDATE, DELETE or MERGE, optionally led by WITH, and refuses a second statement (including a SELECT after INSERT ... VALUES), transaction control, a stray SET, SELECT ... INTO, OUTP
  • plugins/sql-server/src/tools.mjs: added the preview_write and write tools (write carries _meta anthropic/requiresUserInteraction true). Integer argument checking now enforces the declared minimum and maximum. callTool refuses write with WRITE_NOT_OPTED_IN when there is no write executor, and appends
  • plugins/sql-server/src/server.mjs: createServer accepts an optional writeExecutor and passes it to callTool.
  • plugins/sql-server/src/registration.mjs: added the --write flag. bindRegistration({ write }) requires environments.<env>.write.auth and refuses one naming the read principal's variables or Entra client id.
  • plugins/sql-server/src/main.mjs: a --write registration builds a second executor bound to the write principal, and both executors are closed on exit.
  • plugins/sql-server/src/launch.mjs: the usage comment names --write.
  • plugins/sql-server/src/executor.mjs: writeBatch (the one-batch guarded transaction), a write() method that throws on rollback, a missing verdict or a timeout (outcome unknown), and previewWrite() (recursive cascade CTE over sys.foreign_keys plus sys.triggers/sys.trigger_events).
  • plugins/sql-server/schemas/config.v1.schema.json: an optional environment write block with a required auth. This is an additive change, so schemaVersion stays 1.
  • plugins/sql-server/test/server.test.mjs: tests for the five-tool list (the same with and without opt-in), the write tool's flag, every read tool unflagged, write refused without opt-in, write on the write executor only, write reject-list refusals, the expectedRows bounds, preview_write, --write pars
  • plugins/sql-server/test/write-statement.test.mjs (new): accept and refuse cases for checkWriteStatement.
  • plugins/sql-server/test/executor.test.mjs: tests for the writeBatch shape, write commit and rollback, a missing verdict, an open transaction closing the connection, and previewWrite.
  • plugins/sql-server/test/config.test.mjs: a write block loads.
  • plugins/sql-server/test/fixtures/valid-write.json (new): environments with a write principal, without one, and with one that reuses the read principal.
  • docs/adr/0086-bound-the-sql-server-read-tier-by-a-read-only-principal-and-fixed-registrations.md: 'Amendment (2026-11-01): the write tier (S4)' recording the separate write principal, the per-registration opt-in, five fixed tools, the approval flag, the guarded batch with a row-count check, no trans
  • plugins/sql-server/README.md: five tools, --write, a new Writes section and the config write block.
  • plugins/sql-server/.claude-plugin/plugin.json and docs/catalog.md: the description now names the opt-in write tier and the five tools, kept under claude.ai's 500-character limit.
  • .changes/sql-server/work-resolve-issue-issue-11228-41339834239-1-13ba699a.md (new): minor-bump changelog fragment.

Verification

The runner ran each check from the base copy against bf2d5c1:

  • scripts/check-changelog-fragments.sh --check: passed
  • scripts/check-changed-skills.sh --merge-base: passed

The run reports:

  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-changelog-fragments: all 16 fragments valid
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-changed-skills: no changed skills, nothing to gate
  • /home/runner/work/claude-code-plugins/claude-code-plugins/.lane/checks/bin/check-affected: first run failed validate-plugins (plugin.json description was 563 chars, over 500); after shortening it, 11 passed, 7 skipped, 0 failed
  • Fresh-context review subagent over the whole diff: traced every new test assertion as passing. It found one high finding (a SELECT after INSERT ... VALUES got past the write reject list and took over ROWCOUNT), now fixed and covered by a test, plus low findings (more unreserved statement starters,
  • read https: //code.claude.com/docs/en/mcp: section 'Require approval for a specific tool' says _meta["anthropic/requiresUserInteraction"] must be the JSON Boolean true. Claude Code then prompts on every call even in acceptEdits, auto and bypassPermissions, allow rules do not skip it, dontAsk denie
  • read https: //learn.microsoft.com/en-us/sql/t-sql/functions/rowcount-transact-sql: ROWCOUNT returns int (use ROWCOUNT_BIG past 2 billion), and BEGIN TRANSACTION and COMMIT TRANSACTION reset it to 0
  • read https: //github.com/melodic-software/claude-code-plugins/issues /9909: the parent's Fix and the split note (part 1 = task-list lines 1 and 3, part 2 #11229 = the integration script)
  • read https: //github.com/melodic-software/claude-code-plugins/issues /5940: S4 text and the Evidence on write-tier controls (separate write principal, no transaction across approval, one guarded batch with a row-count check, a preview listing triggers and cascading foreign keys because ROWCOUNT sees
  • read https: //docs.appeon.com/pb2025/connection_reference/RecheckRows.html: a driver's affected-row count can include trigger rows, while SELECT ROWCOUNT reports the server value. Supporting context only; not cited in the change
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/41339834239

Left out: the items under Not verified.

Related

#11228

Lane-Activity: work-resolve-issue/resolve-issue
@melodic-automation-lanes

melodic-automation-lanes Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Unattended merge: native auto-merge leaves this pull request unarmed at head 4dd1a65beb91ce20ff2ba761551962ddd500239a. The lanes clear this reason on their own; the next scheduled run judges it again.

pr-merge's gate holds it on its risk score (evidence-unbound:claude-review: not bound: no-run;
  evidence-unbound:claude-security-review: not bound: no-run)

Lane-Activity: pr-unblock/resolve-conflicts
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 4dd1a65beb91ce20ff2ba761551962ddd500239a: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #12075, incremental since fb5aa6db

No security issues found. This round covered one change since fb5aa6db0d2308f784c14a2052fec527a721eca0. A changelog fragment was renamed from .changes/sql-server/work-resolve-issue-issue-11228-41339834239-1-13ba699a.md to .changes/sql-server/work-resolve-issue-issue-11228-41339834239-1-13069941.md. I read the whole file at the head commit.

critical-findings: 0

What I checked

  • What the change does. The incremental diff has no patch, only the rename status. The file at head is release-note text with a bump: minor front matter. It describes the write tier, preview_write and the write reject list. It runs no code and holds no configuration that any lane or the server reads at runtime.
  • Secrets. The file names no credential, token or connection string.
  • Controls. The fragment only describes the controls. It does not change the --write opt-in, the separate write principal check, requiresUserInteraction or checkWriteStatement. Those were reviewed in earlier rounds.

Scope

  • Trusted paths. The file matches no TRUSTED PATHS: glob.
  • Trust controls. The change touches none.
  • Instruction surface. It deletes, narrows or softens no standing instruction.
  • Plugin manifest. Not touched in this increment.
  • Embedded text. The fragment contains no instructions to the lane.
  • Prior findings. This lane's earlier posts reported 0 findings, so there is nothing to carry forward or repeat. Round cap: not past (0 of 3).
  • Spend. None.

@github-actions github-actions 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.

claude-review: 1 inline finding(s) on 13df95312c64c0db28d3c2c985946366affec900; the summary is in this lane's pull request comment.

claude-lane: claude-review

Comment thread plugins/sql-server/README.md Resolved
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 4dd1a65beb91ce20ff2ba761551962ddd500239a: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Code review (incremental): feat(sql-server): add the human-approved write tier (#12075)

This round covers only what changed since fb5aa6db0d2308f784c14a2052fec527a721eca0. The one change is that the changelog fragment was renamed from .changes/sql-server/work-resolve-issue-issue-11228-41339834239-1-13ba699a.md to .changes/sql-server/work-resolve-issue-issue-11228-41339834239-1-13069941.md. The API returned no patch for the rename, so I read the whole file at the head commit and compared it with the full PR diff.

No new findings.

  • Rename only. The fragment is the only file under .changes/sql-server/. No stale copy under the old name is left behind, so there is no duplicate entry.
  • Front matter: bump: minor is unchanged. It still fits the change: two new tools, a new --write flag and an additive config write block, with the write tier off by default.
  • Body: it still describes what ships: the write tool and its requiresUserInteraction flag, preview_write, checkWriteStatement, the ADR 0086 amendment, and the five-tool list. It also matches the README and the ADR text reviewed in earlier rounds.
  • PR description is stale (not a finding): its Fix list still names the old fragment filename (...-13ba699a.md). This has no effect on the code. The description can be updated whenever convenient.

Closing issue #11228: this rename does not affect its Done-when criteria. Both were assessed in earlier rounds and are still unverified by this lane. I did not run the unit-test cases. ci-status is a CI check I cannot see from here. The head commit's message says it fixes failing CI checks, but that is author-claimed and I did not verify it.

Plugin manifest: this increment does not touch it.

Prior findings: 1 round with findings before this review, against a cap of 3, so the cap did not apply. The PR context, settled-threads and prior-findings files contained no embedded instructions.

Lane-Activity: pr-unblock/address-feedback
Lane-Thread: PRRT_kwDOTCGFQM6yd1fp
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

pr-unblock / address-feedback finished round 1 of max 4 on fb5aa6d.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 4dd1a65beb91ce20ff2ba761551962ddd500239a.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Nov 1, 2026
Merged via the queue into main with commit 7544265 Nov 1, 2026
55 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-11228-41339834239-1 branch November 1, 2026 23:01
@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The post-merge check verified merge commit 7544265b9f929152536015f5ed9b5d2279f94d88; later checks count it verified from this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add the human-approved write tier to the SQL Server MCP plugin - part 1 of 2

0 participants