Skip to content

0023 - Read-Only Repository Access for Session Agents, Through Taskbase Tools

Status

Accepted 2026-10-27 by dunk in Taskbase decision task #1662:

A + docs: Taskbase MCP tools (list tree, read file) via Taskbase's own token, limited to the session's own project's linked repository, plus read access to the platform docs (Skatzi/platform docs/content) in every session. No access to other repositories; none in general chats except the docs. No search for now (add later if agents keep missing things).

Recorded in task #1754. The work is planned in the implementation tasks below; nothing is built yet.

History: Proposed 2026-10-25 in Taskbase task #1661 (epic #51, from request #1660 by dunk, built in agent session #65). The owner decides in task #1662; the project manager then plans the work in #1663.

Date

2026-10-25

Context

Chat-session agents — request-builder (ADR 0013), attention-helper (ADR 0015) and the general assistant (ADR 0016) — have only the Taskbase MCP tools. They cannot read a repository, so a factual question about the code or its docs gets "I don't know". In session #65 the request builder could not answer "does the runner support a Claude API key, and how do I add one?".

The request fixes three constraints:

  • Read-only: no writes, no pull requests, no code execution from a chat session.
  • Only the session's own project's linked repository, no other.
  • Owned by Taskbase (project 2); agent-runner (12) and skatzi-agents (14) are affected only.

This record compares how to give that access and recommends one. It does not implement it.

What exists today

Read on 2026-10-25 at Skatzi/taskbase main 0c519b6 (v1.235.0), Skatzi/agent-runner main a97f57f (v0.5.26) and Skatzi/skatzi-agents main c52a422.

  • A turn runs with no files and no shell. Each turn is a fresh agent process in an empty temporary directory with no clone. Claude runs with --tools "" --allowedTools mcp__taskbase; Codex runs with --sandbox read-only, features.shell_tool=false and web search off. The turn's environment drops the Gitea token and every variable named like a secret (Runners — Session turns, ADR 0013 §7).
  • The turn's read scope is per organization, not per project. TurnScope carries the turn, its session and OrganizationIDs, fixed at claim in session_turns.scope_org_ids (api/internal/authz/turnscope.go). A turn reaches every agent-open GET route of those organizations, so a route keyed by project id would reach every project of the organization. For a general session the scope is the owner's reach intersected with the runner's scope — usually several organizations.
  • Taskbase already reads Gitea with its own token for the persona sync and the model policy (gitea.ContentReader / FileReader in api/internal/gitea/contents.go, contents API, 1 MiB per file), the pipeline (api/internal/pipeline) and pull requests (api/internal/pullrequest). These refuse any repository outside the organization's gitea_org with 400 before calling Gitea, and cache for 60 s. Taskbase's token can also write (it creates and closes issues and PRs), so its read paths are read-only by code, not by token.
  • agent-runner has a read-only Gitea MCP server for task runs (internal/giteamcp, task 962): a fixed tool set on an allow-list of GET paths, using the run's own GITEA_TOKEN. Turns do not get it, and its paths cover issues, PRs and commit statuses, not files.
  • The runner's Gitea credential is one user token for every repository it works on (workspace.GitEnv: http.<gitea>/.extraHeader Basic auth with the runner's token), with push rights, because task runs open pull requests.
  • Secret helpers exist: session.LooksLikeSecret and session.MaskSecrets (api/internal/session/secret.go) refuse secret-like drafts and mask agent replies.
  • The personas forbid it today: request-builder.md, attention-helper.md and assistant.md list "reading or changing repositories" under Not, and request-builder.md says "Read a project's linked documentation only when the person names it" without a tool to do so.

Facts checked for this record

Fact Primary source
Gitea is 1.27.3. Its repository API has contents, raw, media, git/trees/{sha}?recursive=true (paged, truncated flag) and archive/{ref}.tar.gz; no code-search endpoint for a repository's content (/repos/search searches repository names) GET /api/v1/version and /swagger.v1.json on gitea.prod.skatzi.com
A Gitea access token is scoped by category (read:repository, write:issue, …), not by repository: CreateAccessTokenOption has only name and scopes same swagger
A per-repository read-only credential exists only as a deploy key (SSH; CreateKeyOption key, read_only, title) or as a separate Gitea user that is a read collaborator of that one repository same swagger
The repositories are private (Skatzi/agent-runner: private: true) GET /api/v1/repos/Skatzi/agent-runner
Sizes: recursive tree skatzi-agents 35 entries, agent-runner 327, platform 932, taskbase 940, none truncated; archive agent-runner 0.48 MB in 0.46 s, platform 2.6 MB in 0.59 s; one contents read 0.15–0.17 s; recursive tree of taskbase 0.31 s; shallow clone 0.5–1.5 s measured from the agent runner machine, 2026-10-25
Claude Code's file tools read outside the working directory unless permissions.blockReadsOutsideWorkingDirectories (v2.1.257+) or Read(...) deny rules say otherwise; outside interactive use the working-directory boundary is a permission check, not an OS sandbox Claude Code permissions, settings reference, security
Codex's read-only sandbox stops edits and commands, not reads ("the agent can inspect files"); with the shell tool off, as turns run today, Codex has no way to read files at all Codex sandboxing
Session #65 was a project_request session on project 14, skatzi-agents. The answer to its question is in Skatzi/agent-runner docs/secrets.md (Claude API key, agent-runner #1638) and Skatzi/platform docs/content/contribution/components/taskbase/runners.md get_task #1660, get_project 14, grep in both repositories

The last row matters: under the fixed constraint, session #65 would still not have been able to answer its own question, because the answer lives in two repositories that are not its project's. The request's fourth acceptance criterion holds only when the question is asked in a session on project 12 (agent-runner). This was open choice 1 below; the decision adds the platform docs to every session, which answers session #65 through runners.md.

Options considered

New GET routes on the API, behind the guard, and matching tools in mcp/:

  • GET /api/projects/{id}/repository/tree?path=&ref= → list_repository_files: the recursive tree of the project's gitea_repo (path, type, size), filtered by a path prefix, at most 2,000 entries.
  • GET /api/projects/{id}/repository/file?path=&ref=&offset=&limit= → read_repository_file: one text file, at most 64 KiB per call (offset/limit for more; the 1 MiB contents limit stays the hard cap), with its blob SHA and the commit it was read at.
  • Optional, see open choice 3: GET /api/projects/{id}/repository/search?q=&path= → search_repository: plain-text search, done by Taskbase over the repository's archive (Gitea has no content search API), cached per head commit, at most 50 hits.

Enforcement, failing closed:

  • Cannot change the repository: Taskbase calls only GET on an allow-list of Gitea paths, as giteamcp does, and the agent never holds a Gitea credential. The routes are GETs, so they fall under the turn's existing "GET only" rule; there is nothing to write with.
  • Cannot read other repositories: the repository is never a parameter — it is the project's gitea_repo under its organization's gitea_org. For a turn, the guard additionally requires {id} to be the session's project: TurnScope gains ProjectID (from the session at claim; 0 for a general session), and the new routes refuse a turn whose ProjectID differs or is 0. This is new: today's per-organization scope would let a turn read every project's repository in the organization. A run or a person keeps the ordinary organization rule.
  • Paths: normalised, no .., no absolute paths, no .git/; symlinks and submodules are listed but not followed.

Limits: 64 KiB per read, 2,000 tree entries, files over 1 MiB refused, binary files (a NUL byte in the first 8 KiB, or not UTF-8) refused with their size, at most 30 repository calls per turn (counted per turn id; the 3-minute turn timeout bounds it anyway). Responses cached 60 s per (repository, ref, path), like the pipeline.

Secret exposure: everything read goes to the model provider, as the turn's other tool results do. A deny list (.env*, *.pem, *.key, id_*, *.p12, *.pfx, *secret* outside *.md, *.sops.*, credentials*) answers "withheld: may hold a secret", and a file whose content LooksLikeSecret flags is withheld the same way. Replies are already masked. The repositories reviewed keep secrets in OpenBao and reference them through ExternalSecrets, so the deny list is a second line, not the first.

Cost and latency: no new infrastructure. ~0.15–0.3 s per uncached call; a typical answer needs 2–5 calls (tree, then one to three files), so 0.5–1.5 s on top of the turn, inside ADR 0013's budget for turns that call tools. No per-project setup: any project with gitea_repo works.

Works on both adapters unchanged — Claude and Codex already reach the Taskbase MCP server, and the runner does not narrow its tools (Runners — Session turns).

Option B — Runner-side read-only checkout with Read, Grep and Glob

The runner clones the session's repository into the turn's directory (0.5–1.5 s shallow, every turn, since turns are stateless and may move between runners) and enables only Claude's Read, Grep and Glob.

  • Cannot change the repository: the clone needs a credential that cannot push. The runner's own token pushes to every repository, so it must not be used. Gitea 1.27 has no per-repository token; the choices are a read-only deploy key per repository (added and rotated per project, stored on every runner) or a Taskbase endpoint that streams the archive to the runner under the turn scope — which is option A's read path with more steps.
  • Cannot read other repositories or other files: Claude's Read reads anywhere the runner's OS user can (its Claude login, agent-runner state, other workspaces) unless every turn passes blockReadsOutsideWorkingDirectories and deny rules — a permission check inside the CLI, not an OS boundary. Codex cannot do this at all without turning its shell back on, which breaks "no code execution"; a runner offers sessions only when every adapter can answer a turn, so runners with Codex would lose sessions or answer without the repository.
  • Secret files in the checkout are readable directly; the runner would have to delete deny-listed files after checkout and has no content scan on Grep output.
  • Gains: real grep across the whole tree, no new Taskbase routes.

Limits: the runner would have to set them itself, since the agent then reads files directly.

  • Clone size: git clone --depth 1 of the default branch only. A partial clone (--filter=blob:limit=1m, which Gitea accepts) does not keep large files out of the working tree, because checkout fetches every blob it needs; so after checkout the runner deletes files over 1 MiB, binary files (a NUL byte in the first 8 KiB) and deny-listed paths (option A's list), and refuses the turn's repository if the clone is over a fixed cap (e.g. 50 MB) or takes over 10 s.
  • Read and Grep output: bounded only by Claude Code's own per-call defaults; the runner cannot set a byte limit per tool call, and Grep returns matching lines from any remaining file.
  • Call count: --max-turns (Claude's print-mode flag) caps agent turns, not tool calls; the 3-minute turn timeout is the real bound. Taskbase sees none of these calls, so it cannot count them.

Changes per project:

  • Taskbase (2): the claim response carries the repository to clone (gitea_org/gitea_repo of the session's project, none for general). With deploy keys: a table of per-repository read-only keys, created through POST /repos/{owner}/{repo}/keys with read_only: true when gitea_repo is set, rotated and removed with it, and handed to the runner at claim (a secret over the claim response — new for turns, which today get no credential). Without deploy keys: a turn-scoped GET /api/sessions/turns/{id}/repository/archive that streams option A's archive read.
  • agent-runner (12): clone (or unpack the archive) into the turn directory with the key from the claim, never with its own token; the size and file clean-up above; Claude run with --tools "Read,Grep,Glob", --allowedTools mcp__taskbase,Read,Grep,Glob, settings permissions.blockReadsOutsideWorkingDirectories: true and Read deny rules for its home and state directories; remove the checkout after the turn; offer sessions only on adapters that can read (Claude), or answer Codex turns without the repository; docs in runners.md Session turns.
  • skatzi-agents (14): the same Look it up rule as option A, naming Read, Grep and Glob instead of the Taskbase tools.

Rejected: it needs a new credential per repository or a Taskbase proxy anyway, is enforced inside the CLI instead of on the server, and excludes Codex.

Option C — The published docs site only

Give turns a read tool for docs.prod.skatzi.com (or the docs/ tree of Skatzi/platform).

  • Cheapest, one source, no per-project work; would have answered session #65 through runners.md.
  • Fails the request: it is not the session's project's repository, and most repositories' README, ADRs and code are not on it.

The site has 146 pages (sitemap.xml) and a 2.5 MB search.json index of their text; one page is fetched in 0.15–0.25 s, and a long page such as runners/ is 271 KB of HTML (measured 2026-10-25).

Enforcement, failing closed: the tool lives in Taskbase, not in the runner, so it works for both adapters and no web access is turned on in the turn.

  • GET /api/docs/page?path= → read_platform_docs and GET /api/docs/search?q= → search_platform_docs in Taskbase and mcp/. The host is a server-side constant (https://docs.prod.skatzi.com); the agent passes only a path, which must appear in the site's sitemap.xml (cached). Anything else, a redirect to another host, or a non-text/html answer is refused.
  • Read-only: the site is static and the routes only GET it; there is nothing to write to.
  • The alternative — Claude's WebFetch allowed only for domain:docs.prod.skatzi.com — is enforced inside the CLI, is Claude-only (Codex turns run with web search off), and is rejected for the same reasons as option B.

Limits: HTML converted to text and cut to 64 KiB per call (offset for more); search over the cached search.json, at most 20 hits with the page path; at most 30 calls per turn, counted per turn id as in option A; site responses cached for 10 minutes.

Secret exposure: none beyond what is already public — the site is served without sign-in.

Changes per project:

  • Taskbase (2): the two routes and MCP tools, the sitemap and index cache, the per-turn call count; the routes are allowed for every turn, general included, since the content is public; docs in sessions.md.
  • agent-runner (12): none; one line in runners.md Session turns naming the tools.
  • skatzi-agents (14): a Look it up rule pointing to search_platform_docs and read_platform_docs for questions about the platform, Taskbase and the runner; the Not lines about repositories stay.

Kept as a possible addition (open choice 1), not as the answer. The decision took the addition in a different form: the platform docs are read from Skatzi/platform docs/content in the repository, through option A's tools and limits, not from the published site (see Decision).

Taskbase mirrors each linked repository and serves full-text search. Strong search, but storage, a sync loop and an index per repository — far more than the request needs. Option A's archive search (open choice 3) covers the same need on demand.

A: Taskbase tools B: runner checkout C: docs site
Read-only enforced by Taskbase code, GET allow-list; agent holds no credential the credential (deploy key) static site, GET only from Taskbase
Other sources refused by server: turn's ProjectID, repo from the project the credential's reach; local files by CLI settings server: fixed host, path must be in the sitemap
Limits 64 KiB/read, 2,000 entries, 30 calls/turn, set by Taskbase clone cap and file clean-up by the runner; per-call output by CLI defaults; turn timeout 64 KiB/read, 20 hits, 30 calls/turn, set by Taskbase
Adapters Claude and Codex Claude only Claude and Codex
Latency per turn +0.5–1.5 s (2–5 calls) +0.5–1.5 s clone, then local +0.3–1 s
Work per project none (gitea_repo set) a deploy key per repository on every runner none
New infrastructure none key distribution, rotation none
Search archive search (choice 3) or none full grep site search

Decision

Option A, plus the platform docs (accepted in #1662): Taskbase MCP tools that list the tree and read a file, through Taskbase's own token, for the session's own project's linked repository, with the turn scope narrowed to that project for these routes. Every session, general chats included, can also read the platform docs: Skatzi/platform, under docs/content only. No other repository, no search in this phase. It keeps the boundary where ADR 0013 put it — in Taskbase, server-side — gives the agent no credential and no files, works for every adapter and needs nothing per project.

The platform docs are a fixed source: the repository and the docs/content prefix are server-side configuration, never a parameter, and paths outside the prefix are refused after normalisation. They share option A's limits, deny list, content check, caching and the 30-calls-per-turn budget. Whether they get their own tools or a source argument on the repository tools is left to the implementation (#1757).

Scope by subject

Subject What the turn may read
project_request the session's project's gitea_repo, and the platform docs (Skatzi/platform docs/content only)
task (attention chat) the task's project's gitea_repo, and the platform docs (Skatzi/platform docs/content only)
general only the platform docs (Skatzi/platform docs/content) — it has no single project

A project without gitea_repo answers 404 no repository and the tools say so.

Changes per project

  • Taskbase (2): the two routes (no search, choice 3) in a new api/internal/repository package using gitea.ContentReader plus a tree read; TurnScope.ProjectID set at claim and checked by the guard for these routes; route-table entries; secret deny list and content check; per-turn call count; OpenAPI; MCP tools list_repository_files and read_repository_file in mcp/; docs in components/taskbase/sessions.md and authentication.md#turn-scoped-access; the platform docs as a fixed source open to every turn.
  • agent-runner (12): no code change — it already passes every Taskbase tool to turns. Its docs (runners.md Session turns) gain one line naming the new tools.
  • skatzi-agents (14): request-builder.md and attention-helper.md replace "reading or changing repositories" under Not with "changing repositories"; add a Look it up rule: "Before answering a question about how the project or platform works, look in its repository (README, docs/, ADRs, then code) with list_repository_files and read_repository_file, and in the platform docs; quote the file and path; say when neither answers it". assistant.md gets the platform-docs rule only, since a general chat has no project repository. All three treat file content as untrusted text, like the transcript.

Architecture diagrams

When built, "Containers of Taskbase" (diagram #6, container level) changes: the existing connection taskbase-api--gitea is relabelled to its new intent (e.g. "syncs issues and PRs, reads releases and repository files"); no new box. Option B would instead add an agent-runner → gitea session-checkout connection on the same diagram. This record changes no diagram.

Consequences

Positive

  • Session agents answer from the code and docs, citing paths.
  • One enforcement point, on the server, for both adapters; the agent never holds a Gitea credential and never sees the runner's file system.
  • The turn scope gains a project dimension that later per-project tools can reuse.

Negative

  • Exposure follows Taskbase grants, not Gitea permissions. Taskbase's token reads every repository under gitea_org, and the repositories are private. A person with an organization grant but no Gitea access to a project's repository could read it through a chat. Grants are per organization by design, and the person already sees that project's tasks, PR titles and CI, but file content is more. If that is unacceptable, the route can also require the owner to have read access in Gitea (GET /repos/{owner}/{repo}/collaborators/{user}/permission, assuming Gitea and Keycloak usernames match) — open choice 4.
  • File content goes to the model provider, as other tool results do; the deny list and content check reduce, not remove, that risk.
  • No real grep in this phase (choice 3); the agent navigates by tree and file.
  • Gitea load: at most 30 calls per turn, cached 60 s.

Open choices (resolved in #1662)

  1. Scope: the session's own project's repository plus the platform docs (Skatzi/platform docs/content) in every session. No other repository. Proposed was the own project only; the alternative "any linked repository of the organization" was not taken.
  2. General chats: the platform docs only, no project repository. Proposed was nothing.
  3. Search: none in this phase — tree and file only. search_repository is deferred until agents keep missing things.
  4. Gitea permission check: none; Taskbase grants decide, as proposed. The decision does not mention it, so the proposal stands.

Deferred

Left out Trigger that brings it back
search_repository over a cached archive (choice 3) agents keep missing things they would find by searching
Reading other repositories of the organization (choice 1) a new decision; none planned
Gitea permission check on the session owner (choice 4) Taskbase grants turn out to reach people who must not read a repository's files

Implementation tasks

Planned by the project manager in #1663, all follow_up_of #1662 in epic #51:

Task Project Change
#1755 Taskbase (2) TurnScope.ProjectID fixed at claim
#1756 Taskbase (2) list_repository_files and read_repository_file for the session's project's repository
#1757 Taskbase (2) the platform docs (Skatzi/platform docs/content) for every session, general chats included
#1758 skatzi-agents (14) persona Look it up rules for the repository and the platform docs
#1759 agent-runner (12) the new tools in agent-runner's chat-turn docs
#1760 platform (1) platform docs (runners.md) and the diagram #6 relabel of taskbase-api → gitea
#1761 Taskbase (2) end-to-end check: a request session answers the Claude API key question
#1754 platform (1) this record marked Accepted