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
4 changes: 3 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ Read the ADRs, `README.md` and `docs/spec.html` before changing behaviour.
never let `ANTHROPIC_API_KEY`, `ANTHROPIC_AUTH_TOKEN`,
`ANTHROPIC_IDENTITY_TOKEN` or `ANTHROPIC_PROFILE` stay set: they outrank
federation and silently shadow it. The ids are not secrets but are still
flags.
flags. An actor on Agent Substrate uses federation only with
`--anthropic-identity-token-from-core`: its identity token is one the
core signs for it, asked at every exchange, never a file or a variable.
- **The connector is the boundary.** The prompt is best effort. A cluster is
reached only through a connector, whose tools are offered by exact name. By
default the core's tools are allowed by name (`tools.CoreTools`) and the
Expand Down
20 changes: 18 additions & 2 deletions cmd/tria-spot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"os"
"os/signal"
"strings"
"sync/atomic"
"syscall"
"time"

Expand Down Expand Up @@ -82,7 +83,16 @@ func supervise(cfg config.Config, errOut io.Writer) int {
return 1
}

model, err := newModel(ctx, cfg, log)
// The link is made after the model client, and the client asks for the
// identity token only at its first exchange: the holder is filled then.
var identityFrom atomic.Pointer[triggers.Link]
model, err := newModel(ctx, cfg, log, func(ctx context.Context) (string, error) {
l := identityFrom.Load()
if l == nil {
return "", errors.New("identity token: this process has no link to the core (a task actor has none)")
}
return l.IdentityToken(ctx)
})
if err != nil {
log.Error("model client", "err", err)
return 1
Expand Down Expand Up @@ -192,6 +202,7 @@ func supervise(cfg config.Config, errOut io.Writer) int {
}
if l, ok := tc.(*triggers.Link); ok {
link = l
identityFrom.Store(l)
// The server listens at once and the link starts with the core's first
// request, which the process then waits for.
shutdown, err := serve(cfg.Listen, l.Handler(), log)
Expand Down Expand Up @@ -288,7 +299,7 @@ func supervise(cfg config.Config, errOut io.Writer) int {

// newModel builds the model client for the configured provider and auth mode.
// It fails at once on a key file it cannot read or a mode with missing ids.
func newModel(ctx context.Context, cfg config.Config, log *slog.Logger) (llm.Client, error) {
func newModel(ctx context.Context, cfg config.Config, log *slog.Logger, identityToken func(context.Context) (string, error)) (llm.Client, error) {
log.Info("model", "provider", cfg.LLMProvider, "id", cfg.Model, "effort", cfg.Effort, "maxSteps", cfg.MaxSteps, "maxToolCalls", cfg.MaxToolCalls, "maxTurnTokens", cfg.MaxTurnTokens)
if cfg.LLMProvider == config.ProviderGemini {
o := llm.GeminiOptions{Auth: cfg.LLMAuth, Model: cfg.Model, KeyFile: cfg.GeminiKeyFile}
Expand All @@ -308,6 +319,11 @@ func newModel(ctx context.Context, cfg config.Config, log *slog.Logger) (llm.Cli
RuleID: cfg.FederationRuleID, OrganizationID: cfg.AnthropicOrgID, ServiceAccountID: cfg.AnthropicServiceAcctID,
WorkspaceID: cfg.AnthropicWorkspaceID, IdentityTokenFile: cfg.IdentityTokenFile,
}
if cfg.IdentityTokenFromCore {
o.Federation.IdentityToken = identityToken
log.Info("model auth: Anthropic workload identity federation with an identity token the core signs", "rule", cfg.FederationRuleID, "serviceAccount", cfg.AnthropicServiceAcctID)
break
}
// The kubelet projects the token; absent here only means it is not mounted yet.
if _, err := os.Stat(cfg.IdentityTokenFile); err != nil {
log.Warn("identity token file is not readable yet; the first exchange will fail until it is", "err", err)
Expand Down
9 changes: 5 additions & 4 deletions docs/spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,9 @@ <h3>Runtimes</h3>
<tr><td class="k">Reports</td><td>Kept until the supervisor is idle (no turn, no task, nothing waiting), then sent in this order: turns, stats, the wake reports last. The core may suspend the actor once it has the wake report, so nothing follows it. A frame that made no wake (the rooms had nothing new) is answered with <code>{&quot;wake&quot;:{&quot;reason&quot;:&quot;rooms&quot;,&quot;lane&quot;:&quot;long&quot;,&quot;outcome&quot;:&quot;idle&quot;}}</code>, which ends the outstanding wake and leaves the stored plan. The <code>schedule</code> frame follows hello only when the process holds a plan, because one without would replace the core&rsquo;s.</td></tr>
<tr><td class="k">What survives</td><td><code>/state</code>, the actor&rsquo;s durable directory: the usage ledger, the room cursors and read marks, the digest, the promises, the identity, and <code>window.json</code>: the tokens of the last hour (the hourly ceiling), the early wakes of the last hour (their cap), the issue state edges are told against and the plan the last wake left (the core holds it; an actor that reports a promise without having run a wake says it back). Held edges do not survive a suspension, so <code>--edge-cooldown</code> and <code>--chat-batch</code> are 0 in this runtime and the next tick reads whatever a cap left.</td></tr>
<tr><td class="k">Task actor</td><td><code>--task-actor</code> makes a process an actor the core made for one piece of work that Tria asked for (the core&rsquo;s ADR-109). It never joins: no certificate, no hello, no schedule, no rooms to poll, no lanes. It is an A2A agent (Agent2Agent protocol 0.3, <code>a2a-go</code> v0.3.15) and the core is its client; it serves, on <code>--listen</code>, <code>GET /readyz</code> (the substrate&rsquo;s probe), <code>GET /.well-known/agent-card.json</code> and the JSON-RPC endpoint at <code>/</code> (<code>message/send</code>, <code>tasks/get</code>, <code>tasks/cancel</code>; every other method is refused). The card is static and names no workspace, spot or core: <code>url</code> <code>/</code>, <code>preferredTransport</code> <code>JSONRPC</code>, <code>protocolVersion</code> <code>0.3.0</code>, push notifications on, streaming off, an <code>http</code> <code>bearer</code> security scheme and one required extension, <code>https://triageagent.dev/a2a/spot-task/v1</code>. The core sends one <code>message/send</code> with <code>Authorization: Bearer &lt;task token&gt;</code>: one text part (the goal), <code>contextId</code> the task key, <code>metadata</code> <code>triage.workspace</code>, <code>triage.task.key</code>, <code>triage.task.title</code> and <code>triage.task.replyTo</code>, and a <code>pushNotificationConfig</code> (the core&rsquo;s receiver, the key as its token, the task token as its bearer). The actor has no setting of its own and cannot verify the core&rsquo;s signature, so before it acts it confirms the task with the core: <code>GET /v2/messenger/spot/link/tasks/{key}</code> with the message&rsquo;s bearer, answered <code>{key, goal, title, replyTo}</code>. On 401, 403 or 404 the A2A task ends <code>rejected</code> and the actor stays free for the next message; it also ends <code>rejected</code> when the message has no bearer, the key is not the core&rsquo;s, the message&rsquo;s text differs from the core&rsquo;s goal (after trimming), or <code>triage.workspace</code> is not the workspace the actor was made for (<code>--tenant</code>). A second message, while the task runs or after it ended, is answered <code>rejected</code> (one task per actor). The message must also carry a push notification configuration whose URL has the scheme and host:port of <code>--core-api-url</code> (the path may differ), otherwise it ends <code>rejected</code> before the core is asked, and the actor never posts to any other URL; <code>tasks/get</code> and <code>tasks/cancel</code> are for the task&rsquo;s own bearer, or one the core confirms for the task (the core keeps no task token and mints a fresh one for the same task; the actor asks <code>GET /v2/messenger/spot/link/tasks/{key}</code> with it, once, within 5 s, and remembers it when the core answers 200 with the task&rsquo;s key). The bearer is written to <code>--core-token-file</code> (outside the state directory) and is the task&rsquo;s credential for its tools and its confirmation, for this task only: the core refuses it on hello, stats, schedule, control answers and any other workspace. One turn runs the goal (the task prompt, the usual caps, <code>schedule_next</code> and <code>start_task</code> refused, calls to the core always with the workspace of the token, the room <code>bus</code> only). The supervisor then writes the result as one memory item (<code>upsert_memory_item</code>, kind <code>note</code>, scope <code>global</code>, subject the task key, title the core&rsquo;s title, tags <code>task,spot:&lt;name&gt;</code>) and posts one line in the bus (<code>say_in_workspace</code>, <code>reply_to</code> the request, <code>memory</code> the item&rsquo;s id; the line is the result in one line of 300 bytes at most). A failed task is a result like any other (<code>failed: &hellip;</code>), and a note that cannot be saved is said in the line. The actor then flushes its spans and ends the A2A task <code>completed</code> (<code>failed</code> when the run failed) with one artifact holding a data part <code>{"memory": &lt;item id&gt;, "line": &lt;the bus line&gt;}</code>. The core learns the end from the push notification the SDK&rsquo;s sender posts to the configuration in the message (<code>Authorization: Bearer &lt;task token&gt;</code>, <code>X-A2A-Notification-Token: &lt;key&gt;</code>) at every state; the actor sends no wake report. <code>tasks/cancel</code> with the task&rsquo;s bearer stops the turn at its next step, as an operator&rsquo;s stop does for a task of a deployment spot, and ends the task <code>canceled</code>; another bearer cannot cancel it. The process keeps waiting for the core to end the actor. Spots and task actors report to memory and the bus, never to ego.</td></tr>
<tr><td class="k">Model</td><td><code>--llm-auth injected</code>: the Anthropic client sends a fixed placeholder <code>x-api-key</code> to <code>https://api.anthropic.com</code> (or <code>--llm-base-url</code>) and the environment is not read. The egress policy of the actor has a rule for that host whose effect replaces the header with the key of a Secret (<code>ate-secret://&hellip;</code>), and only a request that carries the header is changed; the spot never holds the key. Anthropic provider only. The other auth modes stay for the deployment runtime.</td></tr>
<tr><td class="k">Model</td><td><code>--llm-auth injected</code>: the Anthropic client sends a fixed placeholder <code>x-api-key</code> to <code>https://api.anthropic.com</code> (or <code>--llm-base-url</code>) and the environment is not read. The egress policy of the actor has a rule for that host whose effect replaces the header with the key of a Secret (<code>ate-secret://&hellip;</code>), and only a request that carries the header is changed; the spot never holds the key. Anthropic provider only. Or <code>--llm-auth federation</code> with <code>--anthropic-identity-token-from-core</code>, which needs no key anywhere: at every exchange the spot asks the core for an identity token (<code>GET /v2/messenger/spot/link/identity-token</code> with its access token from hello), a short-lived JWT the core signs that says which spot of which workspace it is, and exchanges it at Anthropic for a short-lived access token it keeps in memory. The core signs one only for the audiences its policy names (<code>spots.identity</code>), and Anthropic checks it with the core's public keys, so one federation rule serves every spot. A task actor has no link and cannot use this mode. The key, vertex and file-token modes stay for the deployment runtime.</td></tr>
<tr><td class="k">TLS</td><td>An <code>https</code> rule is intercepted by the egress gateway, which mints its certificates from its own CA. The template mounts a <code>systemInfo</code> volume with the trust bundle (<code>egress-mitm.ate.dev</code> and <code>system-roots.ate.dev</code>) at <code>/run/ate/egress-trust-bundle</code> and sets <code>SSL_CERT_FILE</code> to it, the one environment variable of the container and no credential. In-cluster names must be fully qualified (<code>&hellip;.svc.cluster.local</code>): the DNS relay forwards the name as asked, and no search domain completes it.</td></tr>
<tr><td class="k">No credential</td><td>The actor holds no model key, no token file and no enrollment key, and mounts no Secret or ConfigMap: connectors are given inline (<code>--connectors-json</code>), what ego checks on a request is put there by the egress policy, and the one-time enrollment key a spot needs for its first join (the core refuses a spot without one) is put on the join request by the egress too: the spot sends <code>X-Triage-Enroll-Key</code> with a placeholder (<code>--enroll-key-injected</code>) and the policy replaces it from a Secret. The one thing the actor keeps is its own key and certificate on <code>/state</code>.</td></tr>
<tr><td class="k">No credential</td><td>The actor holds no model key, no token file and no enrollment key (with federation it holds, in memory and for minutes, the identity token the core signed and the access token that bought), and mounts no Secret or ConfigMap: connectors are given inline (<code>--connectors-json</code>), what ego checks on a request is put there by the egress policy, and the one-time enrollment key a spot needs for its first join (the core refuses a spot without one) is put on the join request by the egress too: the spot sends <code>X-Triage-Enroll-Key</code> with a placeholder (<code>--enroll-key-injected</code>) and the policy replaces it from a Secret. The one thing the actor keeps is its own key and certificate on <code>/state</code>.</td></tr>
<tr><td class="k">Install</td><td>The manifests in <code>deploy/substrate/</code> (one ActorTemplate and one EgressPolicy, with <code>&lt;placeholders&gt;</code>) are applied with the substrate CLI: <code>kubectl ate create actor-template -f</code>, <code>create actor &lt;actor-name&gt; -a &lt;atespace&gt; --template &lt;atespace&gt;/&lt;template-name&gt;</code>, <code>create egress-policy &lt;actor-name&gt; -a &lt;atespace&gt; -f</code>. The actor name is the core’s (it returns it with the spot key). The template names the image by digest, the flags, <code>/state</code> as a durable directory, the wake-up probe, the volume snapshot and the limits. The policy has one rule per destination the spot uses, the one for the model API replacing <code>x-api-key</code> with the key of a Secret (http for in-cluster names, https for the rest, hostnames only). The Helm chart installs the deployment runtime only.</td></tr>
</table></div>
</section>
Expand Down Expand Up @@ -625,7 +625,8 @@ <h3>Model</h3>
<tr><td class="k"><code>--llm-base-url</code></td><td>empty</td><td>injected: the API&rsquo;s URL when it is not <code>https://api.anthropic.com</code>; only with <code>--llm-auth=injected</code></td></tr>
<tr><td class="k"><code>--anthropic-key-file</code></td><td>required with anthropic and key</td><td>Anthropic API key file; rejected with the others</td></tr>
<tr><td class="k"><code>--gemini-key-file</code></td><td>required with gemini and key</td><td>Gemini API key file; rejected with the others</td></tr>
<tr><td class="k"><code>--anthropic-identity-token-file</code></td><td>required with federation</td><td>projected identity token (JWT)</td></tr>
<tr><td class="k"><code>--anthropic-identity-token-file</code></td><td>required with federation, unless the token comes from the core</td><td>projected identity token (JWT)</td></tr>
<tr><td class="k"><code>--anthropic-identity-token-from-core</code></td><td><code>false</code></td><td>federation with <code>--runtime=substrate</code>: the identity token is one the core signs for the spot at every exchange; in place of the file</td></tr>
<tr><td class="k"><code>--anthropic-federation-rule-id</code></td><td>required with federation</td><td>federation rule id (<code>fdrl_...</code>)</td></tr>
<tr><td class="k"><code>--anthropic-org-id</code></td><td>required with federation</td><td>Anthropic organization id</td></tr>
<tr><td class="k"><code>--anthropic-service-account-id</code></td><td>required with federation</td><td>Anthropic service account id (<code>svac_...</code>)</td></tr>
Expand Down Expand Up @@ -683,7 +684,7 @@ <h3>Telemetry and logs</h3>

<section id="s8">
<div class="sechead"><span class="ord">08</span><h2>Credentials</h2></div>
<p><code>--llm-auth</code> picks the model auth mode; <code>federation</code> and <code>injected</code> are Anthropic only. With <code>injected</code> the spot holds no key: it sends a placeholder, and the egress in front of the API replaces it with the real one. Federation ids are not secrets, but they are flags.</p>
<p><code>--llm-auth</code> picks the model auth mode; <code>federation</code> and <code>injected</code> are Anthropic only. With <code>injected</code> the spot holds no key: it sends a placeholder, and the egress in front of the API replaces it with the real one. A substrate actor takes <code>injected</code>, or <code>federation</code> with <code>--anthropic-identity-token-from-core</code> (section 8). Federation ids are not secrets, but they are flags.</p>
<figure class="figscroll">
<svg viewBox="0 0 880 440" role="img" aria-label="Credentials: each Secret or projected token becomes a file in the pod or an identity binding, and one client reads each; connector credentials are not in the pod at all.">
<defs><marker id="ka" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" fill="#9C4A26"/></marker><marker id="kb" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" fill="#3F6478"/></marker><marker id="km" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" fill="#736F65"/></marker></defs>
Expand Down
Loading