-
Notifications
You must be signed in to change notification settings - Fork 0
feat(trust): multi-agent workspaces — provenance chips, per-agent grant scoping, rate budgets (#59) #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat(trust): multi-agent workspaces — provenance chips, per-agent grant scoping, rate budgets (#59) #74
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --- | ||
| "@boardstate/schema": minor | ||
| "@boardstate/core": minor | ||
| "@boardstate/server": minor | ||
| "@boardstate/lit": minor | ||
| --- | ||
|
|
||
| Multi-agent workspaces (#59, SPEC §17.3): several agents sharing one board, distinguishable | ||
| and separately governed. | ||
|
|
||
| - **Per-agent grant scoping (schema + engine).** A capability grant gains an optional | ||
| operator-set `agents?: string[]` — the ACTOR dimension of the AND-gate. Absent ⇒ all agents | ||
| (back-compat, zero migration); present ⇒ only those agent actors pass, at BOTH tool-set | ||
| assembly (the agent-tool adapter surfaces a scoped grant only to a bound, listed agent — | ||
| covering the direct `readOnly` path) and invoke/read time (`dashboard.action.invoke` / | ||
| `dashboard.connector.read` fail-safe recheck). Operator-set ONLY (the approve verb); | ||
| `tool_search` REQUEST / `workspace.replace` / import can never write or widen it — any scope | ||
| drift on a still-granted grant re-pends the whole grant, and every re-pend (manifest drift, | ||
| replace/import, REQUEST, TTL expiry, revoke) strips it, exactly like `autoConfirm`/`expiresAt`. | ||
| - **Actor authenticity (load-bearing).** The acting agent is bound from the server-side | ||
| session/tool-registration identity (threaded `RequestContext → RpcHandlerContext`), NEVER a | ||
| request param. A parked mutation records the server-bound requester and the confirm-time | ||
| re-gate re-checks scope against IT. The WS transport threads no identity, so a scoped grant | ||
| FAILS CLOSED for an unauthenticated networked caller (`capability_pending`) — a client-claimed | ||
| `actor` can never pass another agent's scope (wire-contract tested). | ||
| - **Per-agent rate budgets.** The per-connector invoke limit gains an optional | ||
| `perAgentInvokeRateMax`: an agent's ceiling becomes `min(connector, per-agent)`. Unset ⇒ | ||
| connector-only, byte-identical to prior behavior. | ||
| - **Provenance chips + filter (lit).** On a board with ≥2 distinct agent authors, each widget | ||
| header shows a compact deterministically-coloured chip (short id, full actor on hover) and a | ||
| toolbar affordance filters/highlights one agent's widgets. The approvals widget renders each | ||
| grant's per-agent scope. Zero schema change; single-agent boards are unchanged. New i18n keys | ||
| added to the five complete locales. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| // Render-model coverage for the multi-agent provenance chips (SPEC §17.3, #59): the pure | ||
| // helpers the view + cell consume. No DOM here — the view integration is exercised in | ||
| // boardstate-view.test.ts. | ||
|
|
||
| import { describe, expect, it } from "vitest"; | ||
| import type { DashboardWorkspace } from "@boardstate/core"; | ||
| import { | ||
| agentChipFor, | ||
| agentHue, | ||
| distinctAgentActors, | ||
| isMultiAgentBoard, | ||
| shortAgentId, | ||
| } from "./agent-provenance.js"; | ||
|
|
||
| function board(...createdBy: (string | undefined)[]): DashboardWorkspace { | ||
| return { | ||
| schemaVersion: 1, | ||
| workspaceVersion: 1, | ||
| capabilitiesRegistry: {}, | ||
| prefs: { tabOrder: ["t"] }, | ||
| tabs: [ | ||
| { | ||
| slug: "t", | ||
| title: "T", | ||
| hidden: false, | ||
| widgets: createdBy.map((actor, i) => ({ | ||
| id: `w${i}`, | ||
| kind: "builtin:markdown", | ||
| title: "W", | ||
| grid: { x: 0, y: 0, w: 1, h: 1 }, | ||
| collapsed: false, | ||
| ...(actor ? { createdBy: actor } : {}), | ||
| })), | ||
| }, | ||
| ], | ||
| } as unknown as DashboardWorkspace; | ||
| } | ||
|
|
||
| describe("agentHue", () => { | ||
| it("is deterministic and in [0, 360)", () => { | ||
| const a = agentHue("agent:alice"); | ||
| expect(a).toBe(agentHue("agent:alice")); | ||
| expect(a).toBeGreaterThanOrEqual(0); | ||
| expect(a).toBeLessThan(360); | ||
| }); | ||
|
|
||
| it("spreads distinct actors to (usually) distinct hues", () => { | ||
| expect(agentHue("agent:alice")).not.toBe(agentHue("agent:bob")); | ||
| }); | ||
| }); | ||
|
|
||
| describe("shortAgentId", () => { | ||
| it("passes through short ids and ellipsizes long ones", () => { | ||
| expect(shortAgentId("alice")).toBe("alice"); | ||
| expect(shortAgentId("a-very-long-agent-identifier")).toHaveLength(10); | ||
| expect(shortAgentId("a-very-long-agent-identifier").endsWith("…")).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe("distinctAgentActors + isMultiAgentBoard", () => { | ||
| it("counts only distinct agent actors, ignoring user/system/unstamped", () => { | ||
| const ws = board("agent:alice", "agent:bob", "agent:alice", "user", "system", undefined); | ||
| expect(distinctAgentActors(ws)).toEqual(["agent:alice", "agent:bob"]); | ||
| expect(isMultiAgentBoard(ws)).toBe(true); | ||
| }); | ||
|
|
||
| it("is NOT multi-agent with a single agent (chips stay hidden)", () => { | ||
| const ws = board("agent:alice", "agent:alice", "user"); | ||
| expect(isMultiAgentBoard(ws)).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe("agentChipFor", () => { | ||
| it("returns null for a non-agent author", () => { | ||
| expect(agentChipFor("user", null)).toBeNull(); | ||
| expect(agentChipFor("system", null)).toBeNull(); | ||
| }); | ||
|
|
||
| it("builds a chip and marks it dimmed only when another agent is highlighted", () => { | ||
| const chip = agentChipFor("agent:alice", "agent:bob"); | ||
| expect(chip).toMatchObject({ actor: "agent:alice", agentId: "alice", short: "alice" }); | ||
| expect(chip!.dimmed).toBe(true); | ||
| expect(agentChipFor("agent:alice", "agent:alice")!.dimmed).toBe(false); | ||
| expect(agentChipFor("agent:alice", null)!.dimmed).toBe(false); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This scope comparison only runs when the incoming grant is still
status:"granted", so an untrusteddashboard.workspace.replacecan writeagentsonto arequestedorrevokedcapability and have it persist. That operator-only scope is then rendered in the approvals row as if it were operator-authored, violating the new single-writer invariant foragents; stripagentsfrom non-granted/re-pended grants on the replace path as well.Useful? React with 👍 / 👎.