Skip to content

docs(local): add read-only, audit and row-level rules to SQL profile - #1168

Open
shengzhaowei wants to merge 1 commit into
Tencent:mainfrom
shengzhaowei:docs/sql-readonly-audit-rules
Open

shengzhaowei wants to merge 1 commit into
Tencent:mainfrom
shengzhaowei:docs/sql-readonly-audit-rules

Conversation

@shengzhaowei

Copy link
Copy Markdown

What changed

local/skills/devflow/rules/profiles/sql.md had only 5 generic rules (parameterization, indexes, transactions, migrations, review coverage). It said nothing about the cases that actually hurt in practice: a read query that turns into a write, an unbounded read, a write with no audit trail, or a query that assumes the caller can only see their own rows.
This PR adds 5 rules (6-10) and a regression test asserting the key sentences exist in the profile:
6. Read-only first: queries are read-only by default. A write must first state why it is needed, its impact, and its rollback plan; do not run INSERT, UPDATE, DELETE, or DDL before write intent is confirmed.
7. Row and timeout limits: queries must have per-project row limits and timeouts. No unbounded reads; narrow the conditions first when a limit is hit, instead of pulling everything back and filtering afterwards.
8. Audit: every write and every sensitive query must leave an audit record (who, when, which statement, how many rows affected). Audit records are append-only, never rewritten. The audit scope for read-only queries depends on sensitivity.
9. Row-level permissions: data spanning multiple tenants, organizations, or scopes must first confirm the row-level isolation condition. Do not assume the caller can only see their own data; if the isolation condition is missing, fail closed and stop at the current stage.
10. Sensitive data: passwords, keys, ID numbers, phone numbers, and similar fields must not be written in plaintext to logs, artifacts, or audit records. Keep only a redacted form when needed; exporting sensitive data requires confirmed authorization first.
No project-specific table names, thresholds, or business details are included. Limits are per-project, following the existing rule against fixed thresholds without project evidence.

Scope

  • Portable (checked), Documentation only (checked); all other scope boxes unchecked.

Compatibility

No behavior change. No migration, no version bump, no Classic bundle change. Only the SQL profile text and its regression test change; other profiles and adapters are unaffected.

Validation

Run locally on 2026-11-21, base d58a85a: validate_config OK (adapters=7 logical_roles=10 host_agents=6 artifacts=11); unittest 31 tests OK (incl. test_sql_profile_documents_readonly_audit_and_row_level_rules); validate.sh [1/6]-[6/6] passed; build-classic-hosts.py --check OK; scan-secrets no leaks found; e2e 34 tests OK (skipped=1, playwright not installed); smoke-install passed; test-observability 131 tests OK, source tree clean. Not run: go test, go vet, check-public.py — no Go or public-surface changes in this PR.

Safety

All four safety boxes checked: no credentials/internal endpoints/production data/organization-specific infrastructure; preserved user files and unrelated changes; updated generated Classic host bundles when applicable; documented third-party content and licensing changes when applicable.

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.

1 participant