Skip to content
Merged
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
13 changes: 13 additions & 0 deletions services/platform/backend/core/sandbox/tool_names.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
IMAGE_GENERATION_TOOL,
imageGenerationGuidance,
KNOWLEDGE_READ_TOOLS,
KNOWLEDGE_TOOLS_GUIDANCE,
normalizeToolGrants,
PROJECT_AGENT_ONLY_TOOLS,
readTurnOpRef,
Expand Down Expand Up @@ -98,6 +99,18 @@ describe('the catalog', () => {
});

describe('grantedToolsGuidance', () => {
it('names discovery as a separate MCP tool, never a grantable operation', () => {
for (const guidance of [
KNOWLEDGE_TOOLS_GUIDANCE,
grantedToolsGuidance(['task_get']),
imageGenerationGuidance('/agent/output/task_1'),
]) {
expect(guidance).toContain('separate workspace_status MCP tool with {}');
}
expect(normalizeToolGrants(['workspace_status', 'task_get'])).toEqual([
'task_get',
]);
});
it('is undefined when nothing beyond the baseline is granted', () => {
expect(grantedToolsGuidance([])).toBeUndefined();
});
Expand Down
10 changes: 6 additions & 4 deletions services/platform/backend/core/sandbox/tool_names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export const KNOWLEDGE_TOOLS_GUIDANCE =
'"workspace_tool" MCP tool: rag_search {query} finds the most relevant ' +
"passages, rag_fetch {ref} reads one hit's full source (a document file " +
'id or a crawled page URL). Use them when you need organization facts ' +
'that are not in your staged files; call workspace_status to see ' +
'that are not in your staged files; call the separate workspace_status ' +
'MCP tool with {} to see ' +
'everything granted.';

/**
Expand All @@ -71,7 +72,8 @@ export function imageGenerationGuidance(outputDir: string): string {
"organization's image model and saves them into " +
`${outputDir}/ — name a file there (no subfolders: only the box's top ` +
'level is delivered) or a path under /agent/workspace/ — answering ' +
'with the saved paths; call workspace_status for the argument details. ' +
'with the saved paths; call the separate workspace_status MCP tool ' +
'with {} for the argument details. ' +
'Every image is billed to the organization and counts against this ' +
`turn's spend allowance, at most ${SANDBOX_TURN_MAX_GENERATED_IMAGES} ` +
'images a turn — create what the task needs, not variations for their ' +
Expand Down Expand Up @@ -178,8 +180,8 @@ export function grantedToolsGuidance(
'This agent is additionally granted these workspace tools (call them ' +
'through the "workspace_tool" MCP tool as {tool, args}): ' +
tools.join(', ') +
'. Call workspace_status once for their argument shapes before first ' +
'use.' +
'. Call the separate workspace_status MCP tool with {} for their ' +
'argument shapes.' +
(hasWrite
? ' The write tools change real organization data (tasks, documents) ' +
'with no further approval — act deliberately and prefer the ' +
Expand Down
27 changes: 27 additions & 0 deletions services/platform/backend/domains/sandbox/dispatch-routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,33 @@ describe('POST /api/tools/execute — the turn a token serves', () => {
dispatchWorkspaceToolImpl.mockResolvedValue({ status: 'ok', output: {} });
});

it('keeps discovery out of domain grants without disabling a granted task call [SBX-R6]', async () => {
getSessionTokenByHash.mockResolvedValue({
...TOKEN_ROW,
scope: { toolGrants: ['task_get'] },
});
const refused = await post(
JSON.stringify({ tool: 'workspace_status', args: {} }),
);
expect(await refused.json()).toMatchObject({
status: 'unavailable',
blockers: [{ code: 'not_granted' }],
});
expect(dispatchWorkspaceToolImpl).not.toHaveBeenCalled();

const granted = await post(
JSON.stringify({ tool: 'task_get', args: { taskId: 'task_1' } }),
);
expect(await granted.json()).toEqual({ status: 'ok', output: {} });
expect(dispatchWorkspaceToolImpl).toHaveBeenCalledExactlyOnceWith(
expect.anything(),
expect.objectContaining({
tool: 'task_get',
callArgs: { taskId: 'task_1' },
}),
);
});

it('hands the token scope’s turnOp to the dispatch, never the body’s [SBX-R5]', async () => {
getSessionTokenByHash.mockResolvedValue({
...TOKEN_ROW,
Expand Down
2 changes: 1 addition & 1 deletion services/platform/tests/manual/reference/automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ Legend: ✅ fully automated · 🔶 partially automated · ⛔ manual-only (no s
| [tasks](../suites/tasks.md) / [automations](../suites/automations.md) | An imported title or description is cut on a grapheme boundary (`Intl.Segmenter`): a ZWJ family, a flag, a skin-tone modifier, a keycap or a letter with its combining mark is kept whole or dropped whole, never split, and one grapheme longer than the cap leaves only the "…". The workflow natives `task.upsert` and `task.upsert_issues` answer a blank title with the shared empty-title sentence before any write (a batch names the item, `issues.<n>:`), and return the title the task carries — cut on a create, the stored one after a source-snapshot reconcile — never the title sent; their connector mocks cut alike and refuse with the same sentence, which a test run reports under `MOCK_BODY_FAILED` where a live run answers `INPUT_INVALID`, and the action schema no longer pre-empts `''` with a generic `minLength`. The GitHub and GlitchTip importers seed a task's description with the domain's own cut, never a local 50,000-unit slice. The refusal guard also reads every `AutomationError` an automations-domain function reached from a task door throws, and every `AutomationError`, `ProjectError`, `RestRefusal` and `FolderError` a door's own file builds: `AUTOMATION_PROJECT_FORBIDDEN` no longer repeats the `workflowSlug` sent and is one shared sentence at both throw sites, and the REST task door's `AUTOMATION_NOT_DEPLOYED` no longer repeats the slug either. The board names the caps a save breaks: a description draft over 20,000 code units names the cap under the field — a sentence that stays the same while the draft stays over, so a screen reader hears it once — shows a `used / max` counter outside that live region — the trimmed length a save keeps, grouped in the reader's language, and describing the field so it is read on focus — and holds **Save** and **Create task**; `TASK_TITLE_INVALID` and `TASK_DESCRIPTION_INVALID` toast the cap in the reader's language instead of the generic error; the inline title takes at most 200; the label pickers use the shared label caps; the EN/DE/FR task pages state the two caps the domain holds. REST `data.issues` names a string cap in UTF-16 code units, as the OpenAPI and Markdown references' example does | 🔶 unit + Postgres | `backend/core/tasks/helpers.test.ts`, `lib/connectors/natives/platform-tasks.test.ts` (the mocks run in the node-vm runner against the domain helpers), `backend/domains/tasks/external-ref.test.ts`, `backend/domains/connectors/task-store.upsert.test.ts`, `backend/domains/tasks/errors.test.ts`, `backend/domains/automations/store.begin-run.test.ts`, `backend/rest/shared.test.ts`, `backend/rest/v1-tasks.test.ts`, `lib/connectors/dispatcher.test.ts`, `lib/connectors/issue-import.test.ts`, `lib/engine/core/validate/schema.test.ts`, `app/features/tasks/components/editable-description.test.tsx`, `app/features/tasks/components/task-modal.limits.test.tsx`, `packages/ui/src/components/forms/textarea.test.tsx`, `backend/core/tasks/limits_docs.test.ts`, `app/features/tasks/lib/task-limit-refusal.test.ts`, `backend/integration-check.ts` (`checkTaskExternalIssueSync`: a source reconcile and a batch create answer the stored title); how the over-cap line reads and wraps stays manual (`TASK-B11`) |
| [tasks](../suites/tasks.md) | Native settled-review repair is a separate tagged `resumeFrom` branch: strict old-boundary refusal, stored decision readback, exact source and unchanged human intent, current delegation authority on new admissions and same-manager replay, original issuer provenance, concurrent dedupe, ordinary next-review completion, busy/dependency/hourly limits, and rollback of run, queue and status if receipt persistence fails. A newer human or pending review hides the historical native decision. No UI or model judgment is inferred. | ✅ unit + real PostgreSQL + native HTTP | `backend/core/node_only/sandbox/workspace_tools_bridge.repair.test.ts`, `backend/domains/tasks/review-decision.test.ts`, `backend/domains/tasks/review-repair.integration.ts` (through `checkAgentTaskReviews`), existing `checkDelegatedAgentStartTool` question controls |
| [tasks](../suites/tasks.md) / [automations](../suites/automations.md) | An agent's task reads cover a whole queue: `task_find` answers pages of at most 50 with `isDone` and a signed `continueCursor` bound to its order, filters and scope (another filter, order, project or organization, and a malformed, cut or edited cursor, answer `invalid_args`, never a first page), `totalFound` only when one page holds every match, and walks 260 tasks tied on rank and creation millisecond each once in the database's own `(status, rank, id)` or `(created_at, id)` order; in created order a pass lists a task at most once while the board moves, in board order a task moved past the cursor is listed again and one moved behind it is skipped. `task_get` names subtasks, blockers and comments by id (never another project's task), pages comments past the newest 50 with `commentCursor` and project-agent runs newest-created first with `runCursor`, reads a queued or running run as `live`, a finished one with `settledAt` and `failureCode`, and explicit `retryPending` using the task card's shared retry calculation (armed versus unarmed, retired, spent, superseded, historical and deleted-agent failures; an absent field on an older reader stays unknown), an automation run's `waitingFor` `ask`/`approval` and a `pendingReview`, with a 500-character feedback excerpt and no transcript, error text, result or workspace handle; a failed run read answers `error`, never an idle task. The routine-question protocol's read half: a worker's agent-authored question starts nothing (its @mention is inert), the manager's answer reads back as its comment, `done` stays refused and the review pending, and a pass checkpoint saved in a comment is found past the newest 50 by a later run, whose cursor resumes the pass so both legs list every task exactly once | ✅ unit + real Postgres | `backend/core/node_only/sandbox/workspace_tools_bridge.task_reads.test.ts`, `backend/domains/tasks/service.agent-list.test.ts`, `backend/domains/tasks/agent-work-state.test.ts`, `backend/domains/tasks/agent-runs.test.ts`, `backend/domains/chat/shim.test.ts`, `backend/domains/tasks/agent-read-tools.integration.ts` (`checkAgentTaskReadTools` in `backend:integration`); the restart itself (`task_start_agent`) is its own lane's |
| [tasks](../suites/tasks.md) / [automations](../suites/automations.md) | `workspace_status` names the release label of the backend that answered: `platform.version` is that process's `TALE_VERSION` (the image's build stamp unless the environment overrides it), trimmed, when it has the release shape (`0.5.64`, a prerelease such as `0.6.0-rc.1`), and `null` with a fixed note otherwise — an unset or blank stamp, `dev`, the Build workflow's `candidate-sha-…`, `pr-…-sha-…` and `sha-…` images, a `v`-prefixed or partial label — whose label is never echoed. The door adds it after the session-token check, beside the tool listing it answers unchanged (the grants, or the no-tools note); nothing but the bearer token is read from the request, so a forged body, query or header changes nothing, and a refused token still gets the bare 401. The in-sandbox bridge relays the answer byte for byte and sends `{}` whatever the model passes; its tool description calls the value a label of that backend, not proof of what is deployed or of its health | ✅ unit + Postgres | `backend/domains/sandbox/dispatch-routes.test.ts`, `lib/shared/release-version.test.ts`, `services/sandbox-runtime/daemon/src/tale-connectors-mcp.test.ts`, `backend/integration-check.ts` (`checkSandboxSpawner`: a release stamp, a no-grants token, a forged body, an expired token and a candidate stamp through `/api/tools/status`) |
| [tasks](../suites/tasks.md) / [automations](../suites/automations.md) | `workspace_status` names the release label of the backend that answered: `platform.version` is that process's `TALE_VERSION` (the image's build stamp unless the environment overrides it), trimmed, when it has the release shape (`0.5.64`, a prerelease such as `0.6.0-rc.1`), and `null` with a fixed note otherwise — an unset or blank stamp, `dev`, the Build workflow's `candidate-sha-…`, `pr-…-sha-…` and `sha-…` images, a `v`-prefixed or partial label — whose label is never echoed. The door adds it after the session-token check, beside the tool listing it answers unchanged (the grants, or the no-tools note); nothing but the bearer token is read from the request, so a forged body, query or header changes nothing, and a refused token still gets the bare 401. The in-sandbox bridge relays the answer byte for byte and sends `{}` whatever the model passes. A mistakenly nested `workspace_tool({tool:"workspace_status"})` uses that same authenticated status door, never the execution grant gate or an execution fallback; authentication failures remain failures, ordinary task calls remain grant-gated, and near-miss or missing names keep their existing refusals. Guidance names the separate `workspace_status` MCP tool with `{}`, never a new grant. Its tool description calls the value a label of that backend, not proof of what is deployed or of its health | ✅ unit + Postgres | `backend/domains/sandbox/dispatch-routes.test.ts`, `lib/shared/release-version.test.ts`, `services/sandbox-runtime/daemon/src/tale-connectors-mcp.test.ts`, `backend/integration-check.ts` (`checkSandboxSpawner`: a release stamp, a no-grants token, a forged body, an expired token and a candidate stamp through `/api/tools/status`) |
| [accessibility](../suites/accessibility.md) / [tasks](../suites/tasks.md) | Error labels and explanations retain AA contrast on page, card and muted form surfaces in both themes; destructive alerts and actions remain readable | ✅ Chromium | `packages/ui/src/components/forms/label.browser.test.tsx`; over-cap copy wrapping remains manual (`TASK-B11`) |
| [auth](../suites/auth.md) | Authenticator label and issuer name the client, the product and a non-production environment (`Example plus Tale Platform TE`; `Tale Platform` with neither set) in both enrollment and existing-secret URIs; re-display preserves the secret, and invalid client names or environment labels are refused. The web tier hands the page both settings, normalized, and leaves out one the backend would refuse; backup codes download under the same words from the enrollment wall and from Account | ✅ backend + server + component + e2e | `lib/shared/authenticator-name.test.ts`, `backend/auth/auth.totp-issuer.test.ts`, `backend/env.test.ts`, `server.test.ts`, `vite-plugins/inject-env.test.ts`, `app/features/settings/account/lib/download-backup-codes.test.ts`, `tests/e2e/specs/auth-account.spec.ts` (*enrolls with a generated TOTP code*); `AUTH-F31` checks a real authenticator app, `AUTH-F32` the saved file. |
| [auth](../suites/auth.md) | Trusted headers: a key is minted once and only its hash stored, the door resolves the organization from the key, JIT-creates inside it with the clamped role, refuses strangers, paused organizations and revoked keys, and binds role + organization to the session; the card's switch, create and revoke flows | ✅ automated | `backend/domains/trusted_headers/service.test.ts`, `backend/domains/trusted_headers/routes.test.ts`, `backend/domains/sso/trusted-headers.test.ts`, `app/features/settings/trusted-headers/components/trusted-headers-section.test.tsx`, `app/features/settings/trusted-headers/components/embedding-section.test.tsx`, `lib/org-frame-ancestors.test.ts`, `server.test.ts` (frame ancestors), `backend/lib/http-hygiene.test.ts` (frameable variant), `backend/domains/sso/admin-routes.discovery.test.ts` (proxy probe), `backend/domains/sso/trusted-headers.mint.test.ts` (transparent sign-in on the app's own GET, hold cookie, no POST, no cross-site), `app/features/auth/login-proxy-handoff.test.tsx` (login page hands off, loop guard, hold + Continue, refusal shown in page, bfcache reload), `app/components/user-button.test.tsx` (no Log out for a proxied session), `app/hooks/use-session-idle-watchdog.test.tsx` (hold cookie on inactivity sign-out), `backend/integration-check.ts` (`checkTrustedHeaders`) |
Expand Down
Loading