Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(hosted-team): a Commenter can append comments only, never board activity (M1)

review3cae0524e5d9
diff --git a/docs/hosted-team-relay.md b/docs/hosted-team-relay.md
index 6a3fc9372..eccad2d31 100644
--- a/docs/hosted-team-relay.md
+++ b/docs/hosted-team-relay.md
@@ -208,7 +208,7 @@ session key** in the team store.
| `git:diff` | The cwd (with the repository rule above) **and** the file are jailed; a pathspec starting with `:` is refused; an untracked diff (`git diff --no-index`, which diffs any file) needs a real path inside. The file is relative to the cwd, not the repository's top level. |
| `git:show-file` | The cwd jailed, with the repository rule above; a ref starting with `-` is refused (it would become an option, and `--output=` writes a file). Any other revision is allowed. |
| `agent:subagent-snapshot` | The response is trimmed to shared nodes. |
-| `board-log:read/subscribe/unsubscribe` (+ `append` for Commenters) | Shared projects only. |
+| `board-log:read/subscribe/unsubscribe` (+ `append` for Commenters) | Shared projects only. A Commenter's `append` must be a comment (`kind: 'comment'`): an activity entry ("moved a card to Done") is Editor-only. |
**Outbound is deny-by-default too.** The core broadcasts to every attached client, so a non-editor
receives only the events `VIEW_EVENTS` lists: `canvas:mut`, `workspace:external-change` /
@@ -503,6 +503,9 @@ The human `team status` reads `state`, `idle` and `lastError` together:
"No team member has that key." Restart the service: every session is cut, members reconnect on
their own, and that device becomes a pending request again. (`team rotate-key` also works, but
invalidates every join code.)
+- **A board-log comment's author is what the commenter's tab says.** The entry is written as the
+ client sent it, author included (its presence name and color), so a Commenter can post a comment
+ under another member's name. The host checks the project and that it is a comment, not who wrote it.
- **Approved devices have no label** in `team.json` and `team status`, and there is no relabel verb.
- **Device mints are shared by the team.** The backend's free device-mint damper (10 per 24 h) is
keyed by the **host's** device id, so every joiner of one team draws from one budget. A device
diff --git a/src/core/relay/access-policy.test.ts b/src/core/relay/access-policy.test.ts
index 42b2cc533..1cd664c47 100644
--- a/src/core/relay/access-policy.test.ts
+++ b/src/core/relay/access-policy.test.ts
@@ -55,8 +55,19 @@ describe('access policy', () => {
it('commenter may chat and append to a shared board, viewer may not', () => {
expect(decideAccess('cast', IPC.presenceChat, ['hi'], ctx('viewer')).allow).toBe(false)
expect(decideAccess('cast', IPC.presenceChat, ['hi'], ctx('commenter')).allow).toBe(true)
- expect(decideAccess('req', IPC.boardLogAppend, ['P', {}], ctx('commenter')).allow).toBe(true)
- expect(decideAccess('req', IPC.boardLogAppend, ['Q', {}], ctx('commenter')).allow).toBe(false)
+ expect(decideAccess('req', IPC.boardLogAppend, ['P', { kind: 'comment' }], ctx('commenter')).allow).toBe(true)
+ expect(decideAccess('req', IPC.boardLogAppend, ['Q', { kind: 'comment' }], ctx('commenter')).allow).toBe(false)
+ })
+ it('M1: a commenter appends COMMENTS only — an activity entry ("moved card to Done") is refused', () => {
+ const COMMENTS_ONLY = 'Commenters can only add comments to the board log.'
+ const entry = (kind: unknown) => ({ id: 'e1', ts: 1, author: { name: 'Owner', color: '#fff' }, kind, event: { type: 'card-moved' } })
+ expect(decideAccess('req', IPC.boardLogAppend, ['P', entry('comment')], ctx('commenter'))).toEqual({ allow: true })
+ expect(decideAccess('req', IPC.boardLogAppend, ['P', entry('event')], ctx('commenter'))).toEqual({ allow: false, message: COMMENTS_ONLY })
+ for (const bad of [undefined, null, 'comment', ['comment'], {}]) {
+ expect(decideAccess('req', IPC.boardLogAppend, ['P', bad], ctx('commenter')).allow, String(bad)).toBe(false)
+ }
+ // Editors write activity entries (the board's own diff funnel runs in their tab).
+ expect(decideAccess('req', IPC.boardLogAppend, ['P', entry('event')], ctx('editor'))).toEqual({ allow: true })
})
it('outbound: non-shared canvas and agent events are dropped for non-editors only', () => {
const mutQ = JSON.stringify({ t: 'ev', channel: IPC.canvasMut, args: ['Q', {}] })
diff --git a/src/core/relay/access-policy.ts b/src/core/relay/access-policy.ts
index 51ff96c06..bfbea6b16 100644
--- a/src/core/relay/access-policy.ts
+++ b/src/core/relay/access-policy.ts
@@ -215,7 +215,14 @@ export const VIEW: Readonly<Record<string, Check>> = Object.freeze({
export const COMMENT: Readonly<Record<string, Check>> = Object.freeze({
[IPC.presenceChat]: pass,
- [IPC.boardLogAppend]: projectArg0
+ // Handler args: projectId, entry. The entry is written as the client sent it (board-log-handlers
+ // `boardLogAppend`), and the board renders `kind: 'event'` as ACTIVITY ("<author> moved <card> to
+ // Done"), so a Commenter may append comments only. The author is client-supplied either way (the
+ // presence identity): a comment under someone else's name is a documented limit.
+ [IPC.boardLogAppend]: (a, ctx) => {
+ if (!sharedProject(a[0], ctx)) return no('That project is not shared.')
+ return field(a[1], 'kind') === 'comment' ? OK : no('Commenters can only add comments to the board log.')
+ }
})
/**