Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ jobs:
claude plugin install stackone@stackone
claude plugin details stackone@stackone | tee details.txt
grep -q "MCP servers (1)" details.txt
grep -q "Skills (2)" details.txt
grep -q "Skills (3)" details.txt
grep -q "stackone-actions" details.txt
grep -q "stackone-connection" details.txt
grep -q "stackone-policies" details.txt

codex:
name: Codex / ChatGPT (install from source)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ stackone-plugin/
├── .mcp.json # server config read by Claude Code, Grok Build, Codex
├── skills/stackone-actions/SKILL.md # Connected-app workflow
├── skills/stackone-connection/SKILL.md # Account linking and setup
├── skills/stackone-policies/SKILL.md # Runtime policy rules
├── assets/logo.png, logo.svg
└── scripts/check-manifests.py
```
Expand Down
156 changes: 156 additions & 0 deletions skills/stackone-policies/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
name: stackone-policies
description: Use when the user wants to restrict, block, guard or limit what their AI agents can do in a connected app, control who can run which actions, mask or hide fields such as emails or salaries, or enforce, disable, change or remove an existing runtime policy (rule). Covers reading, writing, testing and retiring Cedar policies and who they apply to. Not for linking or reconnecting accounts (stackone-connection), not for running a provider action, and not for reading logs to diagnose a failed call.
---

# Managing runtime policies

A runtime policy is a rule, written in Cedar, that decides what a project's agents may do on a tool
call: let it through, refuse it, or mask fields in the response. Each policy also says who it covers.
A wrong rule blocks real work or leaves a gap the user believes is closed, so read first, confirm
every write, and test before and after saving.

If this session has no policy tools (`stackone_get_policies`, `stackone_create_policy` and the
rest), policies are not available here: tell the user to manage them in the StackOne dashboard at
app.stackone.com, and do not attempt the steps below. Every policy tool needs a project admin; when
one is refused, tell the user to ask a project admin.

## Read before you write

- List what exists with `stackone_get_policies`, or `stackone_get_policies {id}` for one. Find
every id this way; never ask the user for a policy id.
- If an existing rule already does what is asked, say which one and change nothing. If one nearly
does, propose changing it rather than adding a second rule.
- Policies marked organization-wide also bind this project, but only an organization admin can
change them.

## Say who it reaches

A policy only decides calls made by a signed-in StackOne user: an AI client connected through OAuth
(Claude, Cursor, ChatGPT and similar), the dashboard playground and agent, or a person's own
personal API key. Calls made with a project API key, or through a connect session belonging to a
customer's end user, are never checked, even by a rule assigned to `everyone`. Tell the user this
whenever their request is about those callers or could be read that way.

## Build the rule from what the actions do

1. Find the connector key with `stackone_get_connectors` and the accounts with
`stackone_get_accounts {connector_key: ["<key>"], expand: "connector,connector_profile"}`.
2. List the actions that can run: `stackone_get_connector_profiles {connector_key: ["<key>"]}`, then
`stackone_get_connector_profiles {id}` for each profile, which returns its enabled action ids.
Where `stackone_search_actions` is available, use it to read an action's description and inputs.
3. Stop only what the user asked to stop, choosing actions by effect, not by a word in the name.
"Block deletes" means every action that destroys or ends something: delete, remove, terminate,
archive, cancel, deactivate, purge and the like. "Stop changes" means every write (create,
update, delete and the like), so reads keep working; name the reads left allowed. List each
chosen id to the user, and say which near misses you left out and why.
4. Cover every part of the request: each connector, each person, and each action that reaches the
same outcome (a record created by two different actions needs both). Before writing, go through
every enabled action on every profile of the connector, including generic ones such as an
update-any-record or update-table-row action that can make the same change as the named ones.
Include each or say why it is left out.
5. Name tools by exact id. Never match with a name glob such as `resource.name like "*delete*"`: it
misses actions named differently and catches ones it should not. The rule covers the listed ids
only. If the user asks whether it will catch actions added later, answer plainly: no, it lists
today's ids, new actions must be added to it, and you can do that when they appear. Change
nothing else for this: no connector or profile settings, no pinned version, no disabled actions.

Deny wins over allow, and a `permit` on its own restricts nothing, so a restriction is a `forbid`.
One statement per check. The policy's name goes in `name`, never in an annotation such as `@name`.

```cedar
// Stop agents deleting or ending records in HiBob
forbid (principal, action == StackOne::Action::"invokeTool", resource)
when { resource in [StackOne::Tool::"<delete action id>", StackOne::Tool::"<terminate action id>"] };
```

Only when the user wants every action of one connector stopped, use
`context.account in StackOne::Connector::"<connector key>"`. For one account use
`context.account == StackOne::Account::"<account id>"`.

## Conditions on what the call sends

When the restriction depends on a value in the call, read the action's input names first, then test
them through `context.args`. Each value needs both guards, `hasTag` and `has`, or the save is
refused. Text is under `str`, a whole number under `num`, any number under `dec` (compare amounts
with `dec` and `decimal("1000.0")`), a boolean under `bool`. A nested input is keyed by its path, such
as `compensation.amount`. If the user defines a category by several fields together, the condition
tests all of them, not one field that looks similar.

```cedar
forbid (principal, action == StackOne::Action::"invokeTool", resource)
when { resource == StackOne::Tool::"<create action id>"
&& context.args.hasTag("employment_type") && context.args.getTag("employment_type") has str
&& context.args.hasTag("country") && context.args.getTag("country") has str
&& context.args.getTag("employment_type").str == "contractor"
&& context.args.getTag("country").str == "US" };
```

## Who it covers

`principals` on create, and on `stackone_replace_policy_assignments`, is `[{type: "everyone"}]` or
users and groups by id: `{type: "user", id}`, `{type: "group", id}`. No management tool lists users or
groups, so ask the user for the StackOne user id or group id. Never put a name or an email where an id goes. "Only Jessica may use UKG" is a rule for
everyone with Jessica left out:

```cedar
forbid (principal, action == StackOne::Action::"invokeTool", resource)
when { context.account in StackOne::Connector::"<ukg connector key>" }
unless { principal == StackOne::User::"<Jessica's user id>" };
```

Replacing assignments replaces the whole set: send everyone who should stay, not just the change.

## Masking or refusing fields

To mask what a response returns use `readField`; to refuse a write use `writeField`. Look up the exact
label with `stackone_get_policy_labels` and never invent one. If no label fits, or the list is empty,
say so. A client condition needs its guard:

```cedar
forbid (principal, action == StackOne::Action::"readField", resource)
when { resource in StackOne::Label::"<label name>"
&& context has client && context.client == StackOne::Client::"claude" };
```

## Confirm, then write

Before every write, tell the user in plain words what will change and who it affects, and wait for
their yes.

- Create with `stackone_create_policy {name, definition, principals}`. Leave out `project_id`,
`enforcement_level` and `expires_at`: it starts `monitored`, which records and blocks nothing.
- Edit with `stackone_update_policy {id, definition, expected_version}`, where `expected_version` is
`current_version` from `stackone_get_policies`. An edit to an enforced rule acts on the next call.
- Never move a policy to `enforced` or `disabled`, and never delete one, unless the user asks. When
they only want a rule to stop applying, offer `stackone_set_policy_enforcement_level {id,
enforcement_level: "disabled"}`, which keeps it; use `stackone_delete_policy` only on an explicit ask.
- If a save is refused, fix each listed problem and retry. Tell the user every warning returned.

## Test before and after

Dry-run with `stackone_evaluate_policy`, never by running a real write or delete. Test both sides:
calls the rule must stop, and calls it must leave alone. A persona is a real member (`user_id`) or a
stand-in with any `group_ids`, which matches a rule assigned to everyone.

```
stackone_evaluate_policy {
tool_name: "<delete action id>", account_id: "<account id>", connector_id: "<connector key>",
draft_definition: "<the Cedar>",
personas: [
{ id: "any-agent", group_ids: ["stand-in"], expectation: "deny" },
{ id: "reads-still-work", group_ids: ["stand-in"], expectation: "allow",
call: { tool_name: "<a read action id>", account_id: "<account id>", connector_id: "<connector key>" } }
]
}
```

Add `args` to the call for argument rules, `client` for client rules, and `draft_audience` when the
rule is not for everyone. For a saved policy pass `policy_id` (with `draft_definition` for an edit).
The policy is judged as if enforced: `deniedByThis` means this rule refused it. Show each verdict,
fix the rule if one is wrong, and test again after saving.

## Finish

Report the policy's name, enforcement level, who it covers, the exact actions or fields it stops,
and the test verdicts. Say what is left, such as moving it to `enforced`, and who it cannot reach.