Skip to content

Commit 561981b

Browse files
committed
feat: add delegated access settings to Slack channel modal
Signed-off-by: Tiberiu Socaci <tsocaci@makeitfuture.com>
1 parent 9e553ce commit 561981b

13 files changed

Lines changed: 422 additions & 39 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ product overview.
1818
1919
## Unreleased
2020

21+
- Add a manager/admin-only Access page to Slack channel settings for mode, Full access, Lean,
22+
network, use/manage policy, and named guest/manager lists. Recheck live membership and current
23+
roles on save; immediately acknowledge submissions while validation runs. Admin-author-only
24+
engine bypass and existing ordinary-tab access remain unchanged.
25+
2126
- Settings: replace the Testing with AI checkbox list with a compact searchable user selector,
2227
removable selection chips, keyboard navigation and a bounded results list that fits narrow screens.
2328

‎FEATURES.md‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ A categorized catalog of what's shipped. Cross-linked to `TEST-PLAN.md` checks.
6464
channel pages rather than nested beneath Tools; enabled skills sort first and the channel-level
6565
Grant Tier switch is gone.
6666
- **Slack settings for authorized users:** replies requested by anyone allowed to use the agent add a
67-
requester-bound **⚙️ Settings** footer button. Its four-tab Block Kit console mirrors the web
67+
requester-bound **⚙️ Settings** footer button. Its Block Kit console mirrors the web
6868
setup concepts: Engine & model can be changed by every authorized user in this console; MCP Connections
6969
rotates/removes the write-only Composio, Toolbox and Make MCP credentials plus inherited-token
7070
policy, and edits the Composio account label shared with the web setup form. Labels are shown
@@ -78,6 +78,12 @@ A categorized catalog of what's shipped. Cross-linked to `TEST-PLAN.md` checks.
7878
so historic controls cannot retain revoked access. Cloud MCP actions additionally re-check admin
7979
status. Secrets can be edited in every channel mode, including through `/secrets`; file-edit
8080
permissions and the separate `/model` command policy are unchanged.
81+
**Access** is a fifth tab, visible only to current admins/channel managers. They can edit the
82+
base mode, Full access, Lean, network, use/manage policy and named guest/manager lists. Selecting
83+
Full access does not grant anyone an administrator role; bypass still requires an admin author.
84+
Saves acknowledge immediately with a progress view, validate named users against live human
85+
channel membership, re-check management and roles at the write boundary, and audit policy changes.
86+
DMs keep the existing four tabs. Work-dir and gateway-wide settings are not exposed here.
8187
→ TEST-PLAN: Conversation settings + on-demand memory.
8288
- **Truthful guest access:** approved members appear selected because they already have access;
8389
admins are selected and locked, while explicit guest grants remain independently editable.
@@ -1379,10 +1385,9 @@ A categorized catalog of what's shipped. Cross-linked to `TEST-PLAN.md` checks.
13791385
model/effort) live under an **Advanced** disclosure. → TEST-PLAN: channel access model.
13801386
- **Two-axis access model** (per channel, both editable in the admin UI): **Who can use** (`meta.access`:
13811387
Approved members / Admins only / Locked) and **Who can manage** (`meta.manageAccess`: Org admins only /
1382-
Channel members / Custom + `meta.managers[]`). A channel manager may change SAFE settings (capability
1383-
up to Autonomous, skills, connectors, the MCP allowlist) but **never** Full-access / network / work-dir —
1384-
those stay org-admin-only. Enforced in the gateway control MCP (`requireManage` vs `requireAdmin`) and
1385-
the in-thread `/mode` command; default `admins` means relaxing it is strictly opt-in. Settings →
1388+
Channel members / Custom + `meta.managers[]`). The Slack Access page delegates channel mode, Full access, Lean, network and use/manage policy to
1389+
current managers. Work-dir stays org-admin-only. The gateway control MCP (`requireManage` vs
1390+
`requireAdmin`) and in-thread `/mode` command retain their narrower admin checks; default `admins` means relaxing it is strictly opt-in. Settings →
13861391
**Reset all channels' access to default** (confirm-gated, audit-logged) restores use/manage to defaults
13871392
and clears custom guest + manager lists, leaving capability/skills/tokens untouched.
13881393
→ TEST-PLAN: channel access model.

‎TEST-PLAN.md‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ a pass.
112112
Automated: `test/channel-memory.test.js`, `test/memory-search.test.js`,
113113
`test/memory-snapshot-run.test.js`, `test/channel-members-ui.test.js`,
114114
`test/access-grants.test.js`, `test/gateway-mcp-authz.test.js`,
115-
`test/mcp-control-plane-approval.test.js`, `test/channel-settings-modal.test.js`.
115+
`test/mcp-control-plane-approval.test.js`, `test/channel-settings-modal.test.js`,
116+
`test/access-settings.test.js`.
116117

117118
- [x] Large MEMORY.md and topic writes succeed without a character-capacity failure.
118119
- [x] On an engine without FTS5 (Node 22.13) the database opens, migration 17 is skipped with a warning, and `search_channel_memory` answers from the plain scan with AND semantics, diacritic folding and bracketed excerpts; `ensureMemoryFtsTable` is idempotent and creates the index the moment the engine supports it.
@@ -141,6 +142,35 @@ Automated: `test/channel-memory.test.js`, `test/memory-search.test.js`,
141142
authorization and Slack membership before every mutation. Cloud MCP is hidden from non-admins
142143
and its controls reject revoked admin status; all authorized users can edit runtime and secrets
143144
in every channel mode regardless of manager policy.
145+
- [x] Automated Access: ordinary authorized users cannot see/forge the fifth tab; admins,
146+
approved members under Members policy and named managers under Custom policy can edit it.
147+
DMs keep four tabs. Independent base-mode/Full-access/Lean/network flags round-trip; preset
148+
flags and stored profile agree. Unknown fields cannot change workDir, credentials or roles.
149+
Real store saves preserve unrelated settings and audit only policy. Departed actors,
150+
outsiders/bots in named lists, revoked channel grants and global role revocation during the
151+
final membership request are rejected. Submission acknowledgment precedes asynchronous work.
152+
- [ ] Live Access UI (engine-independent Slack callback case): create disposable Slack channel
153+
`access-settings-qa`, join an admin actor, an approved member, a named external guest, and
154+
the bot. Start with Worker, network/Full access/Lean off, Approved use, Admins manage, and
155+
no explicit grants. From a fresh reply open Settings as each actor. Only admin sees Access.
156+
Change manage to Members; approved actor now sees Access, guest does not. Save Autonomous,
157+
Full access, Lean, network, named guest, and Custom management with the approved actor
158+
named. Reopen Slack and web settings: all values agree; unrelated model/tokens are unchanged;
159+
audit identifies actor/channel and contains no secrets. Clear special flags/lists and save:
160+
all clear. Try a bot and a user outside the channel: save fails without changing metadata.
161+
Revoke management or remove the actor with the editor open: old submit fails. Delay Slack
162+
membership responses beyond three seconds: immediate progress view, then one final result;
163+
no Slack timeout or double save. Restore/delete fixture. Pending live execution.
164+
- [ ] Live Access Claude and Codex (one run each in disposable channel `access-settings-qa`):
165+
select engine explicitly, Worker base, Full access on, Lean/network off, Members management.
166+
As approved non-admin, prompt “Create access-proof.txt containing access proof and report
167+
whether permission bypass is active.” As admin, repeat with a different filename. Pass when
168+
per-run launch evidence has bypass only for the admin author and both runs stay in their
169+
declared container mounts. Enable Lean and start a fresh thread: “List the connectors and
170+
skills available in this run.” Pass when runtime evidence shows the lean tool/skill policy.
171+
Toggle network and ask “Is network use allowed here?”; compare the answer and launch policy
172+
to the stored setting (advisory network is not an egress isolation claim). Restore fixture
173+
settings/files; retain launch/audit evidence. Pending live execution for both engines.
144174
- [ ] Live Claude: in `cg-testing-claude-auto`, keep Who can manage set to Admins and Apps approved
145175
but not a manager. Let Apps request a fresh reply and open **⚙️ Settings**. Pass when Apps
146176
can change to another valid engine/model/effort and restore it; cannot see or operate Cloud MCP;

‎public/app.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ const ACCESS_HELP = {
248248
none: "Locked — nobody can use the bot here until you add them by name in the Users tab (Allowed users).",
249249
};
250250
const MANAGE_HELP = {
251-
admins: "Only gateway admins can change this channel's settings (from Slack or here). (Default.)",
252-
members: "Any approved member of this channel can change the safe settings (capability up to Autonomous, skills, connectors) — but never Full access, network or work-dir.",
251+
admins: "Only gateway admins can edit the Slack Access page. Other authorized users can edit the ordinary Settings tabs. (Default.)",
252+
members: "Any approved channel member can edit Slack Access settings: mode, Full access, Lean, network, access policy and named users/managers. Permission bypass still requires an admin author. Work-dir stays admin-only.",
253253
};
254254
function channelProfileOf(m = {}) {
255255
if (m.profile && PROFILE_FLAGS[m.profile]) return m.profile;

‎public/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ <h2 class="ch-name"></h2>
11161116
<label class="togglerow ch-network-wrap">
11171117
<input type="checkbox" class="ch-network" />
11181118
<span class="switch"></span>
1119-
<span class="t"><b>Network</b><small>tells the engine whether this channel is meant to use the network; the container itself stays on the bridge network until the egress proxy ships — needs Bash, admin-only</small></span>
1119+
<span class="t"><b>Network</b><small>tells the engine whether this channel is meant to use the network; the container itself stays on the bridge network until the egress proxy ships — editable by admins and channel managers in Slack Access settings</small></span>
11201120
</label>
11211121
</label>
11221122

‎src/config/store.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export function defaultChannelMeta({ channelId, name, type, isDM, platform }) {
181181
platform: isPlatformId(platform) ? platform : DEFAULT_PLATFORM,
182182
access: "approved", // who can USE the channel: "approved" | "admins" | "none" (set from the gateway
183183
// default at join). Governs who's auto-granted in a channel; allowedUsers is the manual override.
184-
manageAccess: "admins", // who can MANAGE (change safe settings) from Slack: "admins" | "members" | "custom".
184+
manageAccess: "admins", // who can MANAGE the Access page from Slack: "admins" | "members" | "custom".
185185
managers: [], // when manageAccess="custom": Slack user ids allowed to manage this channel.
186186
profile: isDM ? undefined : "read", // capability preset: read|worker|auto|full|lean|custom (see modes.js);
187187
// expands to the flags below on save. undefined/legacy channels derive it from the flags.

‎src/gateway/gateway-usage/references/administration.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ and friends read `SUPABASE_ACCESS_TOKEN` / `VERCEL_TOKEN` without being told to.
157157
The Slack **Settings** reply button is available to every authorized agent user, including channel
158158
guests. It allows editing engine/model/effort, channel skills and templates, MCP connection tokens
159159
and labels, and write-only secrets. Cloud MCP is visible and editable only by current admins.
160+
A separate **Access** tab is visible only to admins and current channel managers. It edits mode,
161+
Full access, Lean, network, who may use/manage the channel, and named guests/managers. Manager
162+
policy applies to this entire page; changing Full access still leaves run-time bypass admin-author-only.
160163
Every interaction re-checks agent access and channel membership. This console does not grant
161164
admin rights or change the permissions required by separate gateway control tools.
162165

‎src/gateway/modes.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,15 @@ export function isAuthorized(meta, authorId, isDM, { isAdminUser = false, isAppr
125125
}
126126

127127
// ── Who can manage a channel ──────────────────────────────────────────────────
128-
// "Manage" = change this channel's SAFE settings (capability profile up to Autonomous, skills,
129-
// connectors) from inside Slack. Governed by meta.manageAccess (default "admins"), so existing
128+
// "Manage" authorizes the Slack Access page (mode, Full access, Lean, network, use/manage
129+
// policy and named users). Engine permission bypass still requires an admin author. Governed by
130+
// meta.manageAccess (default "admins"), so existing
130131
// channels are unchanged and relaxing it is strictly opt-in per channel:
131132
// - "admins" → gateway admins only (default)
132133
// - "members" → any approved member (membership is implied by posting in the channel)
133134
// - "custom" → only the users listed in meta.managers[]
134-
// The DANGEROUS escalations (Full-access / network / work-dir) are NEVER delegated here — the call
135-
// sites keep requiring an admin author for those. This function only answers "safe-manage?".
135+
// Individual MCP tools and /mode keep their narrower admin checks for Full access/network;
136+
// work-dir remains admin-only. Ordinary Slack Settings tabs use agent authorization separately.
136137
export function canManage(meta = {}, { authorId = "", isAdminUser = false, isApprovedUser = false } = {}) {
137138
if (isAdminUser) return true;
138139
const mode = meta.manageAccess || "admins";

‎src/slack/access-settings.js‎

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// Channel access editor. Personal admin status and gateway-wide settings are never writable here.
2+
import { canManage, isAuthorized, PROFILE_FLAGS, channelProfile } from "../gateway/modes.js";
3+
4+
export const ACCESS_EDIT_ACTION_ID = "cg_channel_settings_access_edit";
5+
export const ACCESS_CALLBACK_ID = "cg_channel_settings_access_form";
6+
export const ACCESS_MODE_BLOCK_ID = "settings_access_mode";
7+
const text = (value) => ({ type: "plain_text", text: value });
8+
const option = (label, value) => ({ text: text(label), value });
9+
const selects = {
10+
mode: [["Read-only", "read"], ["Worker", "worker"], ["Autonomous", "auto"]],
11+
access: [["Approved members", "approved"], ["Admins only", "admins"], ["Locked — named users only", "none"]],
12+
manageAccess: [["Org admins only", "admins"], ["Approved channel members", "members"], ["Named managers", "custom"]],
13+
};
14+
const labels = { mode: "Mode", access: "Who can use it here", manageAccess: "Who can manage this channel" };
15+
const flags = [["Full access — permission bypass for admin authors", "adminMode"], ["Lean — bare model without skills or connectors", "cleanMode"], ["Network — tell the engine network use is allowed", "allowNetwork"]];
16+
17+
export function accessSettingsSnapshot(meta = {}) {
18+
return {
19+
mode: meta.autoMode ? "auto" : meta.allowBash ? "worker" : "read",
20+
adminMode: Boolean(meta.adminMode), cleanMode: Boolean(meta.cleanMode), allowNetwork: Boolean(meta.allowNetwork),
21+
access: meta.access || "approved", manageAccess: meta.manageAccess || "admins",
22+
allowedUsers: meta.allowedUsers || [], managers: meta.managers || [],
23+
};
24+
}
25+
26+
export function assertAccessManager(meta, actor) {
27+
if (meta.isDM || !isAuthorized(meta, actor.authorId, false, actor) || !canManage(meta, actor)) {
28+
throw new Error("Only admins and current channel managers can change access settings.");
29+
}
30+
}
31+
32+
export function buildAccessEditorView(meta, privateMetadata) {
33+
const current = accessSettingsSnapshot(meta);
34+
const flagOptions = flags.map(([label, value]) => option(label, value));
35+
const initialFlags = flagOptions.filter((entry) => current[entry.value]);
36+
return {
37+
type: "modal", callback_id: ACCESS_CALLBACK_ID, private_metadata: privateMetadata,
38+
title: text("Channel access"), submit: text("Save"), close: text("Cancel"),
39+
blocks: [
40+
{ type: "section", text: { type: "mrkdwn", text: "Changes apply to this channel's next runs. Full access bypasses permissions only for admin authors. If the operator enabled whole-home access, Full access also exposes the gateway home to this channel. Network is advisory; the container stays on its bridge network." } },
41+
...Object.entries(selects).map(([key, choices]) => {
42+
const options = choices.map(([label, value]) => option(label, value));
43+
return { type: "input", block_id: `settings_access_${key}`, label: text(labels[key]), element: {
44+
type: "static_select", action_id: key, options,
45+
initial_option: options.find((entry) => entry.value === current[key]) || options[0],
46+
} };
47+
}),
48+
{ type: "input", block_id: "settings_access_flags", optional: true, label: text("Special modes & network"), element: {
49+
type: "checkboxes", action_id: "flags", options: flagOptions,
50+
...(initialFlags.length ? { initial_options: initialFlags } : {}),
51+
} },
52+
...[["allowedUsers", "Guest access — named users"], ["managers", "Named managers (when selected above)"]].map(([key, label]) => ({
53+
type: "input", block_id: `settings_access_${key}`, optional: true, label: text(label),
54+
hint: text("Select current human members of this channel. Membership is checked when you save."),
55+
element: { type: "multi_users_select", action_id: key, max_selected_items: 100,
56+
...(current[key].length ? { initial_users: current[key] } : {}),
57+
},
58+
})),
59+
],
60+
};
61+
}
62+
63+
export function readAccessForm(view = {}) {
64+
const values = view.state?.values || {};
65+
const form = {};
66+
for (const key of Object.keys(selects)) form[key] = values[`settings_access_${key}`]?.[key]?.selected_option?.value;
67+
const chosen = values.settings_access_flags?.flags?.selected_options;
68+
if (!Array.isArray(chosen)) throw new Error("Access form is incomplete. Reopen Settings and try again.");
69+
if (chosen.some((entry) => !flags.some(([, key]) => key === entry.value))) throw new Error("Unknown access option.");
70+
for (const [, key] of flags) form[key] = chosen.some((entry) => entry.value === key);
71+
for (const key of ["allowedUsers", "managers"]) {
72+
const selected = values[`settings_access_${key}`]?.[key];
73+
if (!selected || !Array.isArray(selected.selected_users)) throw new Error("Access form is incomplete. Reopen Settings and try again.");
74+
form[key] = selected.selected_users;
75+
}
76+
return form;
77+
}
78+
79+
// Validate both UI values and the latest policy inside the metadata transaction. A stale editor
80+
// cannot restore its own revoked management grant or overwrite unrelated channel settings.
81+
export function accessSettingsPatch(meta, form, actor) {
82+
assertAccessManager(meta, actor);
83+
for (const [key, choices] of Object.entries(selects)) {
84+
if (!choices.some(([, value]) => form[key] === value)) throw new Error(`Invalid ${labels[key]}.`);
85+
}
86+
for (const [, key] of flags) if (typeof form[key] !== "boolean") throw new Error("Invalid access option.");
87+
for (const key of ["allowedUsers", "managers"]) {
88+
if (!Array.isArray(form[key]) || form[key].length > 100 || form[key].some((id) => typeof id !== "string" || !/^[UW][A-Z0-9]+$/.test(id))) {
89+
throw new Error("Choose up to 100 valid users per list.");
90+
}
91+
}
92+
const patch = {
93+
...PROFILE_FLAGS[form.mode], adminMode: form.adminMode, cleanMode: form.cleanMode,
94+
allowNetwork: form.allowNetwork, access: form.access, manageAccess: form.manageAccess,
95+
allowedUsers: [...new Set(form.allowedUsers)], managers: [...new Set(form.managers)],
96+
};
97+
patch.profile = Object.entries(PROFILE_FLAGS).find(([, preset]) => Object.keys(preset).every((key) => patch[key] === preset[key]))?.[0] || "custom";
98+
return patch;
99+
}
100+
101+
export function accessSummary(meta) {
102+
const current = accessSettingsSnapshot(meta);
103+
return `*Mode:* ${channelProfile(meta)}\n*Full access:* ${current.adminMode ? "on" : "off"} · *Lean:* ${current.cleanMode ? "on" : "off"} · *Network:* ${current.allowNetwork ? "on" : "off"}\n*Who can use:* ${current.access} · *Who can manage:* ${current.manageAccess}\n*Named users:* ${current.allowedUsers.length} · *Named managers:* ${current.managers.length}`;
104+
}

0 commit comments

Comments
 (0)