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: 4 additions & 0 deletions .github/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ eve discovers every capability from the filesystem under `agent/`. There is no c
agent/
agent.ts # model configuration (defineAgent): compaction threshold + a session usage limit that asks before continuing
instructions.ts # defineInstructions: the orchestrator prompt, resolved at build time (injects FACTORY_REPO)
instructions/pretriage.ts # dynamic instruction: the triage result, in place before the first turn on a labeled issue or a ticket
channels/
github.ts # eve GitHub channel via Vercel Connect; botName resolved from the connector's app slug; wires the four hooks from lib/github/hooks.ts and the per-turn checkout from lib/github/checkout.ts
linear.ts # eve Linear channel via Connect; Agent Sessions; stamps trusted (workspace membership is the gate), injects requester name
Expand Down Expand Up @@ -69,6 +70,8 @@ agent/
decisions.ts # the decision-model question sets and thresholds: triageWorkItem, laneFor, diagnoseCiFailure
github.ts # the gh reads and writes triage needs: fetchIssue, fetchLabels, findDuplicateCandidates, applyLabels, fetchChecks, fetchFailedLogs
ci.ts # diagnosePullRequestChecks: a pull request's check status and, when a failed log can be read, its cause
run.ts # runTriage: read the item, ask the decision model, apply its labels; shared by the tool and pre-triage
pretriage.ts # triage before the orchestrator's first turn: which runs get it, and the instruction it writes
intake/
ticket.ts # the ticket schema, ticket id and caller-bound address derivation, callback allowlist, HMAC signature helpers, publicError, readLimitedText
callbacks.ts # the signed status callbacks: turnSettledCallback, interactionOpenedCallback, sessionEndedCallback, postCallback
Expand Down Expand Up @@ -209,6 +212,7 @@ There is no application database. Anything that must outlive a session (for exam
- **Intake idempotency and isolation.** With an `externalId`, the ticket id is a digest of the verified caller and that id, so a retry lands on the session the first submission started, two callers can't collide or guess each other's ids, and the delivery carries a matching idempotency key for two submissions racing each other. Status reads resolve the session through the ticket's own address, never a raw session id, so the API cannot be used to read a session GitHub or Linear started. The address also carries a digest of the caller, so a ticket is bound to the caller that submitted it: another caller with a valid credential gets the same `404` as for an unknown id. A ticket is one run; resubmitting its `externalId` is a no-op by design, so an answer to clarifying questions needs a new ticket with a new `externalId`.
- **Intake callbacks are allowlisted and signed.** A caller-supplied URL the server will POST to is a request-forgery vector, so a `callbackUrl` must be HTTPS, carry no credentials, and match an entry in `FACTORY_INTAKE_CALLBACK_HOSTS` exactly (an entry is a host, which allows any port on it, or `host:port`; there are no wildcards and no subdomain matching); otherwise the ticket is refused with `callback_not_allowed`. Callbacks are sent only when `FACTORY_INTAKE_CALLBACK_SECRET` is set, and a ticket with a `callbackUrl` is refused with `callback_not_configured` when it is not. They carry `x-factory-signature` (hex HMAC-SHA256 of the body), `sentAt` inside the signed body so a receiver can refuse a replayed one, and an `idempotency-key` header so it can drop a repeat. They do not follow redirects, time out after 10 seconds, and never fail the run: `GET /intake/v1/tickets/:ticketId` stays the source of truth. A failed run is reported to API callers as a stable code and an id to quote, never the runtime's own error message, which can name internals.
- **Prompt-injection surface:** the factory reads third-party issue bodies, comments, diffs, and intake tickets, and its stations execute repository code (tests, lint) inside sandboxes. The bounds are structural: the orchestrator has no shell for any caller, unattended sessions run under the denied-by-default autonomous principal, triage is a decision model that can only pick among given options (the worst a hostile issue body earns is a wrong label), the Linear connection denies unattended writes, a station's shell command holds a read-only credential at most, the credentials that write are leased only to commands the runtime parsed and approved and are scoped so that none of the orchestrator's can push or merge (Residual risks says what a taken-over implementer run can do with its push), and everything that ships needs a human. Instruction-following on injected text remains model judgment; the evals' prompt-injection case keeps a floor under it.
- **Triage before the first turn:** on a labeled issue or an intake ticket the run triages the work item itself, before the orchestrator's first model call, and gives it the result as an instruction (`agent/instructions/pretriage.ts`, `agent/lib/triage/pretriage.ts`). It applies labels only where the label policy lets that caller apply them without a person, and the instruction holds closed-list values, label names, and issue numbers, never text a stranger wrote. A triage that fails or takes more than a minute yields no instruction, and the orchestrator calls `triage_work_item` as on any other run.
- **Trace content:** the factory records every session's prompts, tool arguments, and responses in its traces (`agent/instrumentation/otel.ts`), not only those of public conversations, which is eve's default. Vercel Agent Runs therefore holds a private repository's issue text, code excerpts, and model output for the trace retention period, and eve keeps each session's run data for the default period instead of deleting it when the run ends. A deployment that should not send that content there narrows the policy or removes the file.
- **Sandbox egress:** each sandbox the factory defines (the root's and the analyst's, implementer's, and reviewer's, the four that hold the repository) opens with an allowlist (`agent/lib/github/egress.ts`): GitHub's hosts and the public package registries, by exact hostname. A request to any other host is refused at the sandbox firewall, so a run steered by what it reads cannot send a private repository's contents to a host of its choosing or fetch a payload from one. Credential leases are laid over the allowlist and end by restoring it. A deployer adds hosts with `FACTORY_SANDBOX_ALLOWED_DOMAINS` (a private registry, an API the tests call) or removes the allowlist with `FACTORY_SANDBOX_EGRESS=open`. The template build is not held to it, since it has to install `gh` from the image's package archive. The classifier and the researcher define no sandbox: they have no checkout and no GitHub credential, they run in eve's default sandbox, and the allowlist does not apply there.
- **Install scripts:** station sessions tell npm, pnpm, and Yarn not to run install scripts before `FACTORY_SETUP_COMMAND` runs (`agent/lib/github/install-scripts.ts`), because a dependency's install script is the usual way a compromised package runs code, and the implementer's push later runs in the same sandbox. `FACTORY_ALLOW_INSTALL_SCRIPTS=1` opts out; a repository whose install step does real work in a script names that step in the setup command instead.
Expand Down
3 changes: 2 additions & 1 deletion AGENTS.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions agent/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ Only non-interactive flags work. You never write code, commit, or push. Commands

## 1. Ground the work item first

- Read before you route. Read the actual GitHub issue, pull request, or Linear issue in full before starting. Never invent issue numbers, titles, states, or links, and always cite issues by number, like #12.
- Read before you route. Read the actual GitHub issue, pull request, or Linear issue in full before starting. When triage ran before your turn, read the item once and not again. Never invent issue numbers, titles, states, or links, and always cite issues by number, like #12.
- Load the \`writing-quality\` skill before drafting any prose meant for humans: pull request descriptions, issue comments, review reports, Linear replies.
- For a work item that arrived from a GitHub issue or mention, load the \`triaging-issues\` skill and follow it.
- For a work item that arrived from a GitHub issue or mention, load the \`triaging-issues\` skill and follow it. When triage ran before your turn, load it only if the lane is \`duplicate\` or \`clarify\`.
- When the item spans GitHub and Linear (a Linear issue about a GitHub bug, or the reverse), load the \`github-linear-bridging\` skill and follow its conventions for linking the two.

## 2. Triage

Call \`triage_work_item\` first, for every work item: with \`issue_number\` for a GitHub issue, or with the item's \`title\` and \`body\` verbatim for anything else. One call classifies the item (type, priority, complexity), applies the repository's own labels to a GitHub issue, checks it against likely duplicates, and returns a \`lane\` that says what happens next:
Every work item is triaged first. When a triage result for the item is already in your context, the run did that before your turn: use it and do not call \`triage_work_item\` again. Otherwise call \`triage_work_item\` first: with \`issue_number\` for a GitHub issue, or with the item's \`title\` and \`body\` verbatim for anything else. One call classifies the item (type, priority, complexity), applies the repository's own labels to a GitHub issue, checks it against likely duplicates, and returns a \`lane\`. Either way, the \`lane\` says what happens next:

- \`pipeline\`: the item is clear enough to build. Go to the stations (section 3). When \`needs_research\` is true, run the researcher first (section 5).
- \`clarify\`: the item is too thin or ambiguous to build. Call \`run_classifier\` with the item verbatim to get the specific questions to ask, then follow section 4.
Expand Down
50 changes: 50 additions & 0 deletions agent/instructions/pretriage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { decide } from "eve/ai";
import { defineDynamic, defineInstructions } from "eve/instructions";
import type { LeaseSandbox } from "../lib/github/lease.js";
import { pretriage, pretriageTarget } from "../lib/triage/pretriage.js";
import { sandboxGhRunner } from "../lib/triage/run.js";

/**
* The triage result, in place before the orchestrator's first turn on a
* labeled issue or an intake ticket (`agent/lib/triage/pretriage.ts`).
*
* @remarks
* A dynamic instruction runs before every model call, so the work sits in
* a memo keyed on the turn: triage runs once when the turn starts, and a
* later turn in the same session (an issue labeled again after its
* questions were answered) is triaged afresh. A failed triage is kept as
* null like any other result, so it is not retried before every call.
*
* Every other run returns before the sandbox is asked for, so a mention, a
* Linear session, or the dev TUI never starts one here. The result is a
* user instruction: it joins the conversation once, ahead of the turn's
* input.
*/
export default defineDynamic(async (ctx) => {
const auth = ctx.session.auth.current;
const message = (ctx.turn?.input ?? [])
.flatMap((part) => (part.kind === "text" ? [part.text] : []))
.join("\n");
const target = pretriageTarget(auth, message);
if (target === null || ctx.turn === null) {
return null;
}
const content = await ctx.memo(["pretriage", ctx.turn.id], async () => {
try {
const sandbox = await ctx.getSandbox();
if (!("setNetworkPolicy" in sandbox && "name" in sandbox)) {
return null;
}
return await pretriage(target, auth, {
decide,
gh: sandboxGhRunner(sandbox as unknown as LeaseSandbox),
});
} catch (error) {
console.warn("[factory] Triage before the first turn failed:", error);
return null;
}
});
return content === null
? null
: defineInstructions({ content, role: "user" });
});
13 changes: 9 additions & 4 deletions agent/lib/github/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import {
type GitHubPullRequestEvent,
} from "eve/channels/github";
import { FACTORY_BRANCH_PREFIX, FACTORY_LABEL } from "../constants.js";
import { stampAutonomous, stampSummary, stampTrusted } from "../trust.js";
import {
stampAutonomous,
stampIssueIntake,
stampSummary,
stampTrusted,
} from "../trust.js";
import { mentionPattern, resolveBotName } from "./bot-name.js";

/**
Expand Down Expand Up @@ -104,8 +109,8 @@ const isTrustedLabeler = async (

/**
* Task injected into an unattended intake session (an issue labeled with the
* factory label). The issue's content is already in the session's context
* when this runs.
* factory label). The session starts with the issue's number and title
* only; the orchestrator reads the rest itself.
*/
export const FACTORY_INTAKE_TASK = [
`This issue was handed to the factory with the "${FACTORY_LABEL}" label, and this run is unattended: nobody is watching to answer a question or approve an action, so never attempt an action that needs approval.`,
Expand Down Expand Up @@ -233,7 +238,7 @@ export const onIssue = async (
return null;
}
return {
auth: stampAutonomous(defaultGitHubAuth(ctx), issue.issueNumber),
auth: stampIssueIntake(defaultGitHubAuth(ctx), issue.issueNumber),
context: [FACTORY_INTAKE_TASK],
};
};
Expand Down
2 changes: 1 addition & 1 deletion agent/lib/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const MODELS = {
classifier: "openai/gpt-6.1-terra-fast",
decision: "google/gemini-decision-1",
implementer: "anthropic/claude-fable-5.2",
orchestrator: "anthropic/claude-fable-5.2",
orchestrator: "anthropic/claude-opus-5.5-fast",
researcher: "anthropic/claude-opus-5.5",
reviewer: "openai/gpt-6.1-sol-fast",
} as const;
Expand Down
Loading
Loading