Skip to content

Commit be60cfa

Browse files
committed
fix(tools): relabel contact reveals, RTR commands and mssql query as writes
Revealing a person's contact data (email, phone) for credits is `write`; company/firmographic lookups and verifications that only spend lookup credits are `read`. ToolEffect, the v2 catalog schema (and OpenAPI), check:tool-effects, the add-tools, add-integration, and validate-integration skills, and CLAUDE.md now state it that way. 37 contact reveals move to write: Prospeo, ZoomInfo, Findymail, LeadMagic, Datagma, Dropcontact, Enrow, and Hunter email/phone finders and person enrichment, Hunter domain search, Firecrawl enrich, and the Enrich, RB2B, Sixtyfour, People Data Labs, and PitchBook person contact lookups. The 14 GET tools among them carry `// tool-effect:`. crowdstrike_execute_rtr_command is write: the read-tier eventlog family includes export and backup subcommands that write files on the host, and a queue_offline session enqueues commands. mssql_query is write: its only guard is the lexical read-only screen, with no server-enforced read-only transaction. The screen now also rejects NEXT VALUE FOR, which advances a sequence from inside a single SELECT. oracledb_query is write too: its read-only transaction does not bind a function with an autonomous transaction or a package such as UTL_HTTP called from the SELECT.
1 parent 50f4daa commit be60cfa

51 files changed

Lines changed: 119 additions & 67 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/add-integration/SKILL.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ neither calls the other. Follow the full transport and handler rules in the `add
192192

193193
Every tool declares `effect: 'read' | 'write'`. `read` means the call changes nothing outside Sim:
194194
no create, update, delete, send, post, trigger, enqueue, consume, or mark-read; no job, run,
195-
conversation, history item, or other resource left in an account; no credit-funded reveal; no
196-
external delivery (usage billing for the call itself does not count). Anything else, anything that
197-
depends on its params, and anything you are unsure of is `write`. Classify from the API docs you researched in Step 1; the full rules are in `add-tools` →
195+
conversation, history item, or other resource left in an account; no contact data revealed for
196+
credits; no external delivery (usage billing for the call itself does not count). Anything else,
197+
anything that depends on its params, and anything you are unsure of is `write`. Revealing a
198+
person's contact data (email, phone) for credits is `write`; company/firmographic lookups and
199+
verifications that only spend lookup credits are `read`. Classify from the API docs you researched in Step 1; the full rules are in `add-tools` →
198200
Declaring the effect, and `bun run check:tool-effects` enforces them.
199201

200202
**types.ts:**

‎.agents/skills/add-tools/SKILL.md‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,28 @@ semantics, never the name alone.
195195

196196
`read` means the call changes nothing outside Sim: no create, update, delete, send, post, trigger,
197197
enqueue, consume, or mark-read; no job, run, conversation, history item, or other resource left in
198-
an account; no credit-funded reveal; no external delivery. Usage billing for the call itself does
199-
not count. `write` is anything else.
198+
an account; no contact data revealed for credits; no external delivery. Usage billing for the call
199+
itself does not count. `write` is anything else.
200+
201+
**Contact reveals:** revealing a person's contact data (email, phone) for credits is `write`;
202+
company/firmographic lookups and verifications that only spend lookup credits are `read`. An email
203+
or phone finder, a person enrichment that returns an email or phone, and a domain search that lists
204+
people's emails are `write` even over GET (carry `// tool-effect:`); a company enrichment, a people
205+
search that returns no email or phone, and an email verifier stay `read`.
200206

201207
- `read`: GET/HEAD reads, and POST endpoints the docs define as search, query, list, get, lookup, or
202208
verify; LLM, embedding, transcription, TTS, and media-generation calls that leave nothing in the
203-
provider account; enrichment that only spends lookup credits; queries the server enforces as
204-
read-only.
209+
provider account; company/firmographic enrichment and verifications that only spend lookup
210+
credits; queries the server enforces as read-only (a read-only transaction or setting, never a
211+
client-side screen alone).
205212
- `write`: an effect that depends on the params (a `method` param or function-valued
206213
`request.method` that can pick PUT/PATCH/DELETE or a mutating POST, raw SQL or Cypher the server
207214
does not restrict to reads, a generic RPC or command); a GET whose `transformResponse` or
208215
`postProcess` then writes; a read that consumes or acknowledges (a queue receive, mark-as-read);
209216
media generation, transcription, crawls, exports, and research or agent runs that leave a job,
210-
run, asset, or history item in the provider account; a chat that keeps a conversation; a reveal or
211-
enrichment that creates a resource or delivers to a webhook; anything that saves to the
212-
workspace. When unsure, `write`.
217+
run, asset, or history item in the provider account; a chat that keeps a conversation; a
218+
person's email or phone revealed for credits; a reveal or enrichment that creates a resource or
219+
delivers to a webhook; anything that saves to the workspace. When unsure, `write`.
213220
- PUT/PATCH/DELETE are `write`. A static GET/HEAD labelled `write`, or PUT/PATCH/DELETE labelled
214221
`read`, fails the audit unless the `effect` line carries `// tool-effect: <reason>` on one of the
215222
two lines above it; use it only for a genuine exception such as a GET that writes in `postProcess`.

‎.agents/skills/validate-integration/SKILL.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ For **every** tool file, check:
8181
- [ ] Every tool declares `effect`, and the label matches the API docs, not the name: `read` only
8282
when the call changes nothing outside Sim (no create, update, delete, send, trigger, consume,
8383
or mark-read, and no job, run, conversation, history item, or other resource left in the
84-
provider account); a param-dependent effect (method param, raw SQL, generic command), a GET
85-
whose `transformResponse`/`postProcess` writes, and anything uncertain are `write` (rules:
86-
`add-tools` → Declaring the effect)
84+
provider account, and no person's email or phone revealed for credits); a param-dependent
85+
effect (method param, raw SQL guarded only by a client-side screen, generic command), a GET
86+
whose `transformResponse`/`postProcess` writes, and anything uncertain are `write`;
87+
company/firmographic lookups and verifications that only spend lookup credits stay `read`
88+
(rules: `add-tools` → Declaring the effect)
8789
- [ ] Any `// tool-effect: <reason>` sits on a genuine verb/label exception, and
8890
`bun run check:tool-effects` passes
8991

‎CLAUDE.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Use the `test-audit` skill whenever you write, change, or review tests; mechanic
5959
Build order **Tools** → **Block** → **Icon** → optional **Trigger**, from the service's API docs, using `/add-integration` (or `/add-tools`, `/add-block`, `/add-trigger`).
6060

6161
- **Tool IDs are `snake_case`** (`service_action`), registered in `tools/registry.ts`; blocks register alphabetically in `blocks/registry-maps.ts`.
62-
- **Every tool declares `effect: 'read' | 'write'`**: `read` only when the call changes nothing outside Sim (no write, send, trigger, or consume, and no job, run, or other resource left in an account; usage billing aside); `write` otherwise, including param-dependent effects and anything uncertain (`check:tool-effects`; rules in `/add-tools`).
62+
- **Every tool declares `effect: 'read' | 'write'`**: `read` only when the call changes nothing outside Sim (no write, send, trigger, or consume, and no job, run, or other resource left in an account; usage billing aside); `write` otherwise, including param-dependent effects and anything uncertain. Revealing a person's contact data (email, phone) for credits is `write`; company/firmographic lookups and verifications that only spend lookup credits are `read` (`check:tool-effects`; rules in `/add-tools`).
6363
- **Type coercions go in `tools.config.params`** (runs at execution), never `tools.config.tool` (runs at serialization, where `Number()` destroys `<Block.output>` references).
6464
- **Requests made for a workspace use `outboundFetch`** (`@/lib/core/network/outbound-fetch.server`), never the global `fetch` or another imported `fetch`, so an organization with a dedicated egress gateway keeps its static IPs; `check:organization-egress` enforces this, and a request that rightly goes direct (Sim's own infrastructure, an operator-local server) takes `// egress-direct: <reason>`. AWS SDK clients signing with customer credentials take `organizationAwsRequestHandler()`: no audit catches a missing one, so reviewers check it.
6565
- A surface listing integrations to a viewer reads `useIntegrationAccess`, never a raw catalog (`check:integration-access`).

‎apps/docs/openapi-v2-resources.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21950,7 +21950,7 @@
2195021950
"effect": {
2195121951
"type": "string",
2195221952
"enum": ["read", "write"],
21953-
"description": "What running the tool does outside Sim. `read` changes nothing there: no create, update, delete, send, post, trigger, enqueue, consume, or mark-read; no job, run, conversation, history item, or other resource left in an account; no credit-funded reveal; no external delivery. Usage billing for the call itself does not count. `write` is anything else, including an effect that depends on the input."
21953+
"description": "What running the tool does outside Sim. `read` changes nothing there: no create, update, delete, send, post, trigger, enqueue, consume, or mark-read; no job, run, conversation, history item, or other resource left in an account; no contact data revealed for credits; no external delivery. Usage billing for the call itself does not count. `write` is anything else, including an effect that depends on the input. Revealing a person's contact data (email, phone) for credits is `write`; company/firmographic lookups and verifications that only spend lookup credits are `read`."
2195421954
},
2195521955
"hostedApiKey": {
2195621956
"type": "string",
@@ -22676,7 +22676,7 @@
2267622676
"effect": {
2267722677
"type": "string",
2267822678
"enum": ["read", "write"],
22679-
"description": "What running the tool does outside Sim. `read` changes nothing there: no create, update, delete, send, post, trigger, enqueue, consume, or mark-read; no job, run, conversation, history item, or other resource left in an account; no credit-funded reveal; no external delivery. Usage billing for the call itself does not count. `write` is anything else, including an effect that depends on the input."
22679+
"description": "What running the tool does outside Sim. `read` changes nothing there: no create, update, delete, send, post, trigger, enqueue, consume, or mark-read; no job, run, conversation, history item, or other resource left in an account; no contact data revealed for credits; no external delivery. Usage billing for the call itself does not count. `write` is anything else, including an effect that depends on the input. Revealing a person's contact data (email, phone) for credits is `write`; company/firmographic lookups and verifications that only spend lookup credits are `read`."
2268022680
},
2268122681
"hostedApiKey": {
2268222682
"type": "string",
@@ -32969,7 +32969,7 @@
3296932969
"additionalProperties": {
3297032970
"type": "string",
3297132971
"enum": ["read", "write"],
32972-
"description": "What running the tool does outside Sim. `read` changes nothing there: no create, update, delete, send, post, trigger, enqueue, consume, or mark-read; no job, run, conversation, history item, or other resource left in an account; no credit-funded reveal; no external delivery. Usage billing for the call itself does not count. `write` is anything else, including an effect that depends on the input."
32972+
"description": "What running the tool does outside Sim. `read` changes nothing there: no create, update, delete, send, post, trigger, enqueue, consume, or mark-read; no job, run, conversation, history item, or other resource left in an account; no contact data revealed for credits; no external delivery. Usage billing for the call itself does not count. `write` is anything else, including an effect that depends on the input. Revealing a person's contact data (email, phone) for credits is `write`; company/firmographic lookups and verifications that only spend lookup credits are `read`."
3297332973
}
3297432974
},
3297532975
"dynamicOutputs": {

‎apps/sim/lib/api/contracts/v2/catalog.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ const v2HostedApiKeySchema = z
414414
export const v2ToolEffectSchema = z
415415
.enum(['read', 'write'])
416416
.describe(
417-
'What running the tool does outside Sim. `read` changes nothing there: no create, update, delete, send, post, trigger, enqueue, consume, or mark-read; no job, run, conversation, history item, or other resource left in an account; no credit-funded reveal; no external delivery. Usage billing for the call itself does not count. `write` is anything else, including an effect that depends on the input.'
417+
"What running the tool does outside Sim. `read` changes nothing there: no create, update, delete, send, post, trigger, enqueue, consume, or mark-read; no job, run, conversation, history item, or other resource left in an account; no contact data revealed for credits; no external delivery. Usage billing for the call itself does not count. `write` is anything else, including an effect that depends on the input. Revealing a person's contact data (email, phone) for credits is `write`; company/firmographic lookups and verifications that only spend lookup credits are `read`."
418418
)
419419

420420
const v2ToolOAuthSchema = z.object({

‎apps/sim/lib/internal/mssql/query.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,17 @@ describe('validateReadOnlyQuery', () => {
8686
expect(result.error).toMatch(/backslash before a quote/)
8787
})
8888

89+
/** A sequence advances on every evaluation, so even a lone SELECT changes server state. */
90+
it.each([
91+
'SELECT NEXT VALUE FOR dbo.order_number',
92+
'SELECT id, NEXT VALUE\n FOR dbo.order_number AS n FROM dbo.orders',
93+
])('rejects the sequence advance %s', (query) => {
94+
const result = validateReadOnlyQuery(query)
95+
96+
expect(result.isValid).toBe(false)
97+
expect(result.error).toMatch(/NEXT VALUE/)
98+
})
99+
89100
it('rejects an unpaired quote', () => {
90101
expect(validateReadOnlyQuery(`SELECT * FROM dbo.t WHERE a = 'x`).isValid).toBe(false)
91102
})

‎apps/sim/lib/internal/mssql/query.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,14 @@ function matchStatementPhrase(masked: string): string | null {
292292
return null
293293
}
294294

295+
/**
296+
* `NEXT VALUE FOR`, the one expression a single SELECT can use to change server
297+
* state: each evaluation advances the sequence, permanently, even when the
298+
* statement's transaction rolls back.
299+
* @see https://learn.microsoft.com/en-us/sql/t-sql/functions/next-value-for-transact-sql
300+
*/
301+
const MSSQL_SEQUENCE_ADVANCE = /\bnext\s+value\s+for\b/i
302+
295303
/** Extended, OLE-automation, and system stored procedures, called with or without `EXEC`. */
296304
const MSSQL_PROCEDURE_PATTERN = /\b(?:xp_|sp_)\w+/i
297305

@@ -389,7 +397,8 @@ function hasUnreliableQuoting(value: string): boolean {
389397
* rather than by naming the anything; and it may not mention a
390398
* statement-introducing keyword or a stored procedure, which covers both the
391399
* semicolon-less batch and the `WITH x AS (...) DELETE FROM x` form that a
392-
* leading-token check alone would miss.
400+
* leading-token check alone would miss, nor `NEXT VALUE FOR`, which advances a
401+
* sequence from inside the SELECT itself.
393402
*
394403
* All screening runs over literal-masked text, so ordinary prose in a WHERE
395404
* clause does not trip it. The screens are lexical rather than a parser, so a
@@ -444,6 +453,7 @@ export function validateReadOnlyQuery(query: string): { isValid: boolean; error?
444453
const disallowed =
445454
MSSQL_STATEMENT_KEYWORDS.exec(masked)?.[0] ??
446455
MSSQL_PROCEDURE_PATTERN.exec(masked)?.[0] ??
456+
MSSQL_SEQUENCE_ADVANCE.exec(masked)?.[0] ??
447457
matchStatementPhrase(masked)
448458
if (disallowed) {
449459
return {

‎apps/sim/tools/crowdstrike/execute_rtr_command.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const crowdstrikeExecuteRtrCommandTool: InternalToolConfig<
1717
description:
1818
'Run a read-only Real Time Response command in an open CrowdStrike Falcon session (POST /real-time-response/entities/command/v1). baseCommand names the family only (cat, cd, clear, csrutil, env, eventlog, filehash, getsid, help, history, ifconfig, ipconfig, ls, mount, netstat, ps, reg, users); subcommands go in commandString. Host-modifying commands need the Active Responder or Admin endpoints. Requires the "Real time response: Read" API scope.',
1919
version: '1.0.0',
20-
effect: 'read',
20+
effect: 'write',
2121
oauth: CROWDSTRIKE_CREDENTIAL_OAUTH,
2222

2323
params: {

‎apps/sim/tools/datagma/enrich_person.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export const enrichPersonTool: ToolConfig<DatagmaEnrichPersonParams, DatagmaEnri
1717
description:
1818
"Enrich a person's profile using their email, LinkedIn URL, or full name and company. Returns job title, company, location, and social data. Uses 2 credits per match; add 30 credits when a phone number is found.",
1919
version: '1.0.0',
20-
effect: 'read',
20+
// tool-effect: the GET spends Datagma credits to reveal the person's email and phone
21+
effect: 'write',
2122

2223
hosting: datagmaHosting<DatagmaEnrichPersonParams>((params, output) => {
2324
const name = output.name as string | null

0 commit comments

Comments
 (0)