From 6aa502bba45bf483420359c639b488f22d48a092 Mon Sep 17 00:00:00 2001 From: Wayne Sun Date: Fri, 11 Sep 2026 21:30:53 -0400 Subject: [PATCH 1/6] docs(adr): route runtime and model per task from a config policy Every runtime/model/effort/persona choice is static per agent (ADR 0091, ADR 0104); CEL overlays cannot set model or effort and the normalized event carries no diff size, so a one-line docs change and a 2,000-line CI refactor get the same opus-at-high review. #5777, #6891, #2842 and agents#497 ask for a cheaper model or effort on trivially scoped changes, agents#535 for a deeper review on security signals, #6560 for a cost preview, and #6964 / agents#1225 record the retry-on-unavailable incident class that a pre-sandbox served-model check would end. ADR 0112 decides that `fullsend run` resolves the four fields an `agents:` entry holds per task, on the host, before the sandbox exists, from a `routing:` block in config.yaml: rules keyed on system-derived task facts only (never PR text), a precedence slot between the per-run overrides and the static entry, guards (allowed set, runtime capability matrix, never-downgrade set kept as #6527 wrote it, persona floors, served-model preflight), effort before model, every choice echoed, a shadow mode, and learning that lands only as a reviewed policy change. The two rejected options are per-prompt routing inside the sandbox (the #6361 draft) and routing in an LLM gateway, which stays an optional provider. Living documents: a Decided line under Agent Runtime in architecture.md and annotations on the open questions in adaptive-agent-selection, cross-run-memory and operational-observability. No code change. Assisted-by: Claude Claude-Session: https://claude.ai/code/session_01BCAjgeumZBcuaRSVvsbAkY Signed-off-by: Wayne Sun --- ...2-task-grain-routing-policy-on-the-host.md | 149 ++++++++++++++++++ docs/architecture.md | 1 + docs/problems/adaptive-agent-selection.md | 4 +- docs/problems/cross-run-memory.md | 2 +- docs/problems/operational-observability.md | 2 +- 5 files changed, 154 insertions(+), 4 deletions(-) create mode 100644 docs/ADRs/0112-task-grain-routing-policy-on-the-host.md diff --git a/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md b/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md new file mode 100644 index 0000000000..08376861e8 --- /dev/null +++ b/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md @@ -0,0 +1,149 @@ +--- +title: "112. Runtime and model are routed per task by a config policy, on the host" +status: Accepted +relates_to: + - adaptive-agent-selection + - agent-architecture + - operational-observability +topics: + - config + - runtime + - routing + - cost +--- + +# 112. Runtime and model are routed per task by a config policy, on the host + +Date: 2026-09-11 + +## Status + +Accepted + + + +## Context + +A repo can say *which* runtime, model, effort and per-persona model an agent +uses ([ADR 0091](0091-per-agent-runtime-model-effort.md), +[ADR 0104](0104-per-persona-model-resolution.md)), but not *when*. Every +choice is static per agent, so a one-line docs change and a 2,000-line CI +refactor get the same opus-at-high review. CEL overlays cannot set `model` +or `effort` ([ADR 0088](0088-cel-guarded-overlays.md): both are operational, +not forge-specific), and the normalized event carries no diff size or paths. +Open issues ask for the next step from three directions: a cheaper model or +effort for trivially scoped changes +([#5777](https://github.com/fullsend-ai/fullsend/issues/5777), +[#6891](https://github.com/fullsend-ai/fullsend/issues/6891), +[#2842](https://github.com/fullsend-ai/fullsend/issues/2842), +[agents#497](https://github.com/fullsend-ai/agents/issues/497)), deeper +review when security signals are present +([agents#535](https://github.com/fullsend-ai/agents/issues/535)), and a way +to see the cost effect of a model change before merging it +([#6560](https://github.com/fullsend-ai/fullsend/issues/6560)). + +Two facts bound the design. The runtime-parity rule that *the deciding +session is never downgraded* ([#6527](https://github.com/fullsend-ai/fullsend/issues/6527)) +still holds. And catalog membership is not availability: four incidents +([#6964](https://github.com/fullsend-ai/fullsend/issues/6964), +[agents#1225](https://github.com/fullsend-ai/agents/issues/1225)) discovered +an unservable id at the first model call, after the sandbox existed, and +retried on opus at several times the cost. A closed draft +([#6361](https://github.com/fullsend-ai/fullsend/pull/6361)) prototyped +per-prompt routing with Claude Code hooks inside the sandbox and measured a +13-issue by 3-model grid on the code agent (opus a median 3.6× haiku; every +model stopped early on the no-change issues); it measured cost and +completion, not quality. +[adaptive-agent-selection.md](../problems/adaptive-agent-selection.md) asks +how selection should learn from outcomes and names the constraints any +learned policy must keep: selection only, shadow mode first, safety as a +constraint rather than an objective, no self-deployment. + +## Options + +**Per-prompt routing inside the sandbox** (the #6361 hooks). Rejected: the +sandbox sees only the prompt, which is author-controlled text; routing state +is per sandbox and lost; it is Claude-Code-only; and the decision comes after +the review has already read a diff it could have sized for free. + +**Routing in an LLM gateway.** Rejected as the place for the decision, kept +as an optional provider. On Vertex the model is addressed in the URL path, so +a gateway can route only if the client moves to the Anthropic Messages +endpoint and the gateway holds the credential the sandbox never sees today; a +silent rewrite also breaks the status-comment model echo, `per_model_usage` +and ADR 0104's closed set. Nothing a gateway sees carries the outcome that +arrives on a later forge event. + +**A heuristic in the GitHub Route job** (#6891's proposal). Rejected: GitHub +only, and a second place that decides model and effort next to the ADR 0091 +chain. + +## Decision + +`fullsend run` resolves runtime, model, effort and persona models **per task, +on the host, before the sandbox exists**, from a `routing:` block in +`.fullsend/config.yaml`. + +1. **Shape.** `routing.rules[]` each carry `agents:`, a CEL `when:` and a + `set:` that holds exactly the four fields an `agents:` entry holds + (`runtime`, `model`, `effort`, `subagents`); nothing else is routable. + All matching rules merge, later entries win per field (the ADR 0088 + semantics). `routing.mode` is `off`, `shadow` or `enforce`. +2. **Inputs are system-derived.** Rules see a `task` variable beside `event`, + `runtime` and `config`: change stats and paths from the forge files API, + a deterministic change pattern, actor kind and role, labels, attempt + count, linked-issue metadata. PR title, body, comments, commit messages + and branch names are never routing inputs. A downgrade rule may key on + labels only from `routing.trusted_labels`; an escalation rule may key on + any label. +3. **Precedence.** A rule sits below the `--runtime`/`--model`/`--effort` + flags and `FULLSEND_*` variables and above the agent's `agents:` entry, + so an explicit per-run override still wins and a rule only refines the + static choice. +4. **Guards, validated at config time and before the sandbox.** Every model a + rule names is in `routing.allowed_models` ∩ the catalog; a runtime change + must keep the agent's needs (no persona roster on codex, fallback chain + on Claude only); `routing.never_downgrade` (default `triage`, + `prioritize`, and the review orchestrator by implication) may only be + moved to an equal or higher tier, so a downgrade rule for `review` moves + effort and `subagents`, never the orchestrator's model; persona + `min_tier` floors from the persona files hold; the resolved model and + every persona model are checked against the project's served list once + per run, falling to the next fallback entry or the static entry on a + miss, never retried inside the sandbox. +5. **Effort before model, model before runtime.** A downgrade lowers effort + on the same model first, then moves within a vendor tier, then across + vendors; a runtime move is never a downgrade rule's job. +6. **Every choice is echoed** with the rule that fired: plan block, + `metrics.json` (`routing.{mode,rule,applied,static_model,static_effort}`), + root-span attributes `fullsend.routing.*`, status-comment footer. In + `shadow` the rules are evaluated and recorded and the static choice runs. +7. **Learning is offline and lands as a pull request.** The root span carries + the routing ledger (choice, rule, task facts, cost, status, verdict) on + the OTLP path of [ADR 0050](0050-distributed-tracing-instrumentation.md); + a replay over that ledger scores a candidate policy, and the only path + from a learned change to production is a reviewed edit to `routing:`. + No in-run adaptation, no self-deployment. + +## Consequences + +- A repo can express "sonnet at low effort for docs-only changes" and "opus + at xhigh with opus security and challenger personas when `internal/scaffold/` + changes" as reviewed config, resolving the downgrade and escalation issues + above with the same mechanism. +- Shadow mode plus the ledger produce the quality evidence #6361 lacked + before any default changes; cost is judged per work item including + re-review and fix rounds, never per run. +- The served-model preflight ends the retry-on-unavailable incident class for + routed and static runs alike. +- Presets may not ship `routing.rules` until the layered merge records which + layer a key came from (the provenance gap ADR 0104 deferred); a lower layer + may only tighten `never_downgrade` and `allowed_models`. +- The review orchestrator's model can move only by amending #6527's wording + in a later ADR, on shadow `per_model_usage` evidence; persona routing on the + Claude Code runtime remains the second half of ADR 0104. diff --git a/docs/architecture.md b/docs/architecture.md index b2a21e1ec1..2bad4cd3c0 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -237,6 +237,7 @@ flowchart TB **Decided (implementation):** - The `fullsend run` runner delegates in-sandbox agent execution to a `runtime.Runtime` interface; production orgs default to Claude Code, with [pi](https://github.com/earendil-works/pi) available as an opt-in second runtime (`runtime: pi`, Claude-on-Vertex through the same WIF credential path) and [codex](https://github.com/openai/codex) as a third (`runtime: codex`, OpenAI-only through a custom model provider whose bearer token comes from a runner-seeded file, with the sandbox tool hooks behind a translating adapter — [ADR 0099](ADRs/0099-codex-agent-runtime.md) and [ADR 0100](ADRs/0100-codex-sandbox-hooks.md)). Runtime selection is configured per repo with `runtime:` in `.fullsend/config.yaml` (per-agent `runtime`/`model`/`effort`/`subagents` on the agent's `agents:` entry sit above it and below the `--runtime`/`--model`/`--effort` flags and `FULLSEND_*` variables, [ADR 0091](ADRs/0091-per-agent-runtime-model-effort.md)) and resolved via `runtime.ResolveForAgent()`. Test-only runtimes — **dummy** (scripted operations) and **dummy-playback** (playlist-based replay of canned results) — execute in the real OpenShell sandbox for behaviour tests without inference. Bootstrap uses a portable `BootstrapInput` interface with optional extensions such as `SandboxHooksBootstrap` for the runtime-neutral sandbox tool hooks ([ADR 0090](ADRs/0090-runtime-neutral-sandbox-hooks-contract.md)); runtimes declare further capabilities through small optional interfaces (`DebugLogNamer`, `ContextBridger`) rather than `Name()` checks in the runner. Transcript and debug artifact handling use a separate `TranscriptHandler` interface. See [runtimes.md](runtimes.md) for the per-runtime security feature matrix required when adding a new backend. +- Runtime, model, effort and persona models are routed **per task** by a `routing:` policy in `.fullsend/config.yaml`, resolved by `fullsend run` on the host before the sandbox exists, from system-derived task facts only (forge change stats and paths, actor kind, allowlisted labels, attempt count — never PR text); a rule sits below the per-run flags and variables and above the agent's `agents:` entry, is bounded by `allowed_models`, a never-downgrade set, persona floors and a served-model preflight, and is echoed in the plan block, `metrics.json`, the root span and the status comment; `shadow` mode records the decision without acting on it, and learning lands only as a reviewed policy change ([ADR 0112](ADRs/0112-task-grain-routing-policy-on-the-host.md)). - Plugins are runtime-scoped harness resources: a harness declares `plugins:` as one list of directories in its own repository (same trust and fetch path as skills), and each entry's format decides which runtime loads it — a `plugin.json` bundle is Claude Code's, a directory pi's `-e` loader resolves is uploaded and loaded after a tree-hash preflight computed from the host copy. Each runtime names and skips the entries in the other format, so the list survives a runtime switch. Because `--no-extensions` plus explicit `-e` closes the set of code that can register tools, no per-tool declaration is needed ([ADR 0094](ADRs/0094-pi-extensions-are-harness-resources.md)). ### Behaviour testing diff --git a/docs/problems/adaptive-agent-selection.md b/docs/problems/adaptive-agent-selection.md index 30c274d56b..ddff4eb79c 100644 --- a/docs/problems/adaptive-agent-selection.md +++ b/docs/problems/adaptive-agent-selection.md @@ -203,9 +203,9 @@ The experiment should actively pressure-test three assumptions: - GA vs. Thompson Sampling — or both at different layers? TS for team/config selection, GA for workflow evolution is the leading hypothesis, but it needs validation. - How fine-grained should context tuples be? A hierarchical split-on-variance approach avoids committing to a fixed schema, but adds implementation complexity. - How do we handle model version changes — reset fitness data, apply a discount, or version-tag and keep history? -- Should the fitness function include a cost term from the start, or should cost optimization be a separate experiment after quality optimization is validated? +- Should the fitness function include a cost term from the start, or should cost optimization be a separate experiment after quality optimization is validated? (For runtime and model selection, [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) judges cost per work item including re-review and fix rounds, and requires shadow-mode outcome evidence before any routed default changes; the composite fitness question remains open.) - What is the right exploration budget, and how should it decay? Too high wastes runs on poor configurations; too low starves new options. - Can fitness data transfer across repos with similar characteristics, and how do we measure "similar"? -- How should the adaptive layer interact with the deterministic safety model — is selection-only sufficient, or are there edge cases where the choice of configuration implicitly affects safety coverage? +- How should the adaptive layer interact with the deterministic safety model — is selection-only sufficient, or are there edge cases where the choice of configuration implicitly affects safety coverage? (Partially decided in [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) for the runtime/model surface: selection only over four config fields, with a never-downgrade set, persona floors and a closed model set as constraints, and no author-controlled input as a routing key.) - What prevents a well-scoring configuration from being well-scoring only because it is assigned to a biased subset of tasks (selection bias in the evaluation)? - Should there be a human-in-the-loop approval step before any configuration is retired, or is soft retirement with recovery probing sufficient? diff --git a/docs/problems/cross-run-memory.md b/docs/problems/cross-run-memory.md index 24cb6ba5da..acfee64bf5 100644 --- a/docs/problems/cross-run-memory.md +++ b/docs/problems/cross-run-memory.md @@ -127,7 +127,7 @@ Retry loops can become flapping when the system does not converge. See [flapping ## Open questions -- Which run outcomes are safe to feed forward automatically, and which require human review first? +- Which run outcomes are safe to feed forward automatically, and which require human review first? (For routing decisions, [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md): none automatically — outcomes feed an offline replay whose result is a reviewed config change; the general question remains open.) - Should memory entries be observations only, or can any of them become instructions? - How should future agents distinguish system-derived facts from agent-authored interpretations? - Can non-review-gated memory be made safe enough, or should all durable memory promotion go through reviewed repo instructions or skills? diff --git a/docs/problems/operational-observability.md b/docs/problems/operational-observability.md index 05e45b5aec..61f4e4bae6 100644 --- a/docs/problems/operational-observability.md +++ b/docs/problems/operational-observability.md @@ -191,7 +191,7 @@ This works for early experimentation when the volume is low and the operators ar - ~~How do we keep the triggering event and the agent run linked in the GitHub Actions UI for debugging?~~ Decided in [ADR 0041](../ADRs/0041-synchronous-workflow-call-event-dispatch.md) (synchronous `workflow_call` dispatch for the event path). - How should trace access be controlled? (JSONL trace exposure decided in [ADR 0021](../ADRs/0021-jsonl-reasoning-trace-exposure.md): owner-scoped storage with credential scanning as defense-in-depth. Broader question of balancing security and transparency for non-JSONL observability data remains open.) - What retention policy applies to traces? Indefinite retention supports audit requirements but increases storage cost and data sensitivity exposure. Time-bounded retention (e.g., 90 days) limits exposure but may lose traces needed for incident investigation. -- How do we measure "is the system getting better"? What metrics constitute a meaningful quality signal for an autonomous software factory? Merge revert rate? Human override rate? Time-to-review? Cost per decision? Some composite score? The choice of metric shapes what gets optimized. First-ship trend scores (trace fitness on wild runs, local `eval-measurements.jsonl`) are [ADR 0087](../ADRs/0087-eval-measurements-online-trace-scoring.md); richer quality signals remain open. +- How do we measure "is the system getting better"? What metrics constitute a meaningful quality signal for an autonomous software factory? Merge revert rate? Human override rate? Time-to-review? Cost per decision? Some composite score? The choice of metric shapes what gets optimized. First-ship trend scores (trace fitness on wild runs, local `eval-measurements.jsonl`) are [ADR 0087](../ADRs/0087-eval-measurements-online-trace-scoring.md); richer quality signals remain open. Routing decisions and the task facts behind them are recorded on the root span (`fullsend.routing.*`) so cost can be compared per work item across model choices ([ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md)). - Should trace scoring cover run *health*, not just trace *health*? Trace *fitness* ([ADR 0087](../ADRs/0087-eval-measurements-online-trace-scoring.md)'s `trace_fitness`) checks that a run's telemetry is well-formed — span tree, identity, model, usage, cost, and exit present and coherent — but not whether the run *behaved* correctly. A separate class of failure is structurally decidable straight from the trace, with no model in the loop: a tool that returned an error the run then ignored, an errored result reused by a later side-effecting call, no-progress loops, or a job that reports success despite an in-trace failure (e.g. [#6621](https://github.com/fullsend-ai/fullsend/issues/6621)). Two questions follow. First, does the eval-measure layer grow a second scorer for these run-*health* defects — the deterministic complement to the statistical evals in [testing-agents.md](testing-agents.md), catching what is provable from a single trace rather than what needs repeated runs — or does behavioral correctness belong with the review and retro agents instead? Second, there is a prerequisite either way: the structured-trace ideal described above records each tool call's result, but tool *results* are only partly on the trace: `execute_tool` spans carry per-call error status (`error.type=tool_error` when a result is flagged `is_error`, [ADR 0108](../ADRs/0108-tool-call-span-topology.md)) only for id-bearing calls — Claude Code today; pi and codex emit no call ids ([#7414](https://github.com/fullsend-ai/fullsend/issues/7414)) — and result content is recorded only at opt-in Level 3 ([ADR 0050](../ADRs/0050-distributed-tracing-instrumentation.md)), again on Claude runs only. The highest-value rules therefore still depend on extending capture across runtimes and levels — itself a telemetry-contract decision. Prior discussion in [#7246](https://github.com/fullsend-ai/fullsend/issues/7246). - At what scale does a dedicated LLM observability platform justify its operational overhead (Postgres, ClickHouse, Redis, S3 for something like Langfuse)? Is there a threshold of agent activity below which structured logging suffices? Score files are local JSONL ([ADR 0087](../ADRs/0087-eval-measurements-online-trace-scoring.md)); remote scores reuse `OTEL_EXPORTER_OTLP_*`. Platform choice remains open. - ~~How do we handle the bootstrapping problem — the factory needs observability to improve, but building the observability infrastructure is itself work that competes with building the factory?~~ Decided in [ADR 0050](../ADRs/0050-distributed-tracing-instrumentation.md): zero-configuration baseline (local JSONL + summary files) eliminates infrastructure requirements for initial observability; OTLP export adds backends when the org is ready. From 488238fa56d645faf25919cf7e691e189299e109 Mon Sep 17 00:00:00 2001 From: Wayne Sun Date: Fri, 11 Sep 2026 21:48:54 -0400 Subject: [PATCH 2/6] docs(adr): note the routing advisor as a deferred follow-on to ADR 0112 Rules cannot read a diff; a short read-only run on the fast tier can. Record the advisor as a follow-on decision and fix the one constraint this ADR owns for it: an assessment read from author-controlled content may fire an escalation rule alone but may satisfy a downgrade rule only together with a system-derived fact, and it never widens the allowed set or crosses the never-downgrade floor. Assisted-by: Claude Claude-Session: https://claude.ai/code/session_01BCAjgeumZBcuaRSVvsbAkY Signed-off-by: Wayne Sun --- .../0112-task-grain-routing-policy-on-the-host.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md b/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md index 08376861e8..4c170971e0 100644 --- a/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md +++ b/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md @@ -147,3 +147,16 @@ on the host, before the sandbox exists**, from a `routing:` block in - The review orchestrator's model can move only by amending #6527's wording in a later ADR, on shadow `per_model_usage` evidence; persona routing on the Claude Code runtime remains the second half of ADR 0104. + +### Deferred + +- **A routing advisor.** Rules cannot read a diff; a short, read-only run on + the fast tier can, and its schema-validated verdict (`scope`, `risk`, + `domains`) can become a `task.assessment` fact beside the system-derived + ones, with an in-run counterpart that lets a worker consult a stronger + model without switching session model + ([#6531](https://github.com/fullsend-ai/fullsend/issues/6531)). That is a + follow-on decision. The constraint this record fixes for it: an assessment + read from author-controlled content may fire an escalation rule alone but + may satisfy a downgrade rule only together with a system-derived fact, and + it never widens the allowed set or crosses the never-downgrade floor. From 573339ccf515626cfadfcf00bf49712de6d18c37 Mon Sep 17 00:00:00 2001 From: Tim Pouyer Date: Mon, 28 Sep 2026 10:10:51 -0400 Subject: [PATCH 3/6] docs(adr): tighten ADR 0112 guards and inputs per review Define downgrade classification from an ordered allowed_models list and the effort scale, name review in the never-downgrade defaults, merge routed subagents per persona key as ADR 0104 does, pin fail-closed defaults and the preflight miss path, redact author-controlled event and linked-issue fields from routing inputs, and drop the undefined persona min_tier floor. Drop the cross-run-memory annotation to stay within relates_to, and link ADR 0091's precedence chain to 0112. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Tim Pouyer --- .../0091-per-agent-runtime-model-effort.md | 3 + ...2-task-grain-routing-policy-on-the-host.md | 68 +++++++++++-------- docs/architecture.md | 2 +- docs/problems/adaptive-agent-selection.md | 2 +- docs/problems/cross-run-memory.md | 2 +- 5 files changed, 47 insertions(+), 30 deletions(-) diff --git a/docs/ADRs/0091-per-agent-runtime-model-effort.md b/docs/ADRs/0091-per-agent-runtime-model-effort.md index 9dab0c4af8..5a935ed3de 100644 --- a/docs/ADRs/0091-per-agent-runtime-model-effort.md +++ b/docs/ADRs/0091-per-agent-runtime-model-effort.md @@ -111,6 +111,9 @@ Config-layer addition, slotting in below per-run overrides: > default ``` +[ADR 0112](0112-task-grain-routing-policy-on-the-host.md) adds per-task +`routing.rules` between the `FULLSEND_*` variables and the `agents:` entry. + The repo-wide `runtime:` key is kept as the default for agents that set none — deliberately not removed: existing configs, `fullsend github setup --runtime` and the behaviour-test installs depend on it, and a default is diff --git a/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md b/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md index 4c170971e0..bd99651bf5 100644 --- a/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md +++ b/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md @@ -93,38 +93,51 @@ on the host, before the sandbox exists**, from a `routing:` block in `set:` that holds exactly the four fields an `agents:` entry holds (`runtime`, `model`, `effort`, `subagents`); nothing else is routable. All matching rules merge, later entries win per field (the ADR 0088 - semantics). `routing.mode` is `off`, `shadow` or `enforce`. -2. **Inputs are system-derived.** Rules see a `task` variable beside `event`, - `runtime` and `config`: change stats and paths from the forge files API, - a deterministic change pattern, actor kind and role, labels, attempt - count, linked-issue metadata. PR title, body, comments, commit messages - and branch names are never routing inputs. A downgrade rule may key on - labels only from `routing.trusted_labels`; an escalation rule may key on - any label. + semantics); `subagents` merges per persona key with ADR 0104's rules, + `~` tombstones included, as one more layer above the `agents:` entry. + `routing.mode` is `off` (the default when omitted), `shadow` or + `enforce`. A malformed `routing:` block is a config-time error and the + static choice runs. +2. **Inputs are system-derived.** Rules see a `task` variable beside + `runtime`, `config` and a redacted `event`: change stats and paths from + the forge files API, a deterministic change pattern, actor kind and role, + labels, attempt count, and the linked issue's number, state and labels. + PR and issue titles, bodies and comments, commit messages and branch + names are never routing inputs: they are removed from `event`, and a + `when:` that references them fails config validation. A downgrade rule + may key on PR or issue labels only from `routing.trusted_labels`; an + escalation rule may key on any label. 3. **Precedence.** A rule sits below the `--runtime`/`--model`/`--effort` flags and `FULLSEND_*` variables and above the agent's `agents:` entry, so an explicit per-run override still wins and a rule only refines the static choice. -4. **Guards, validated at config time and before the sandbox.** Every model a - rule names is in `routing.allowed_models` ∩ the catalog; a runtime change - must keep the agent's needs (no persona roster on codex, fallback chain - on Claude only); `routing.never_downgrade` (default `triage`, - `prioritize`, and the review orchestrator by implication) may only be - moved to an equal or higher tier, so a downgrade rule for `review` moves - effort and `subagents`, never the orchestrator's model; persona - `min_tier` floors from the persona files hold; the resolved model and - every persona model are checked against the project's served list once - per run, falling to the next fallback entry or the static entry on a - miss, never retried inside the sandbox. +4. **Guards, validated at config time and before the sandbox.** A rule is a + *downgrade* when any model or effort it resolves, for the agent or a + persona, sits below the static choice: effort by `low` < `medium` < + `high` < `xhigh` < `max`, model by its position in + `routing.allowed_models`, which is ordered lowest tier first; any other + rule is an escalation, and every guard below applies to that computed + result. Every model a rule names is in `routing.allowed_models` ∩ the + catalog, and persona models stay in ADR 0104's closed set; a runtime + change must keep the agent's needs (no persona roster on codex, fallback + chain on Claude only). The agents in `routing.never_downgrade` (default + `triage`, `prioritize` and `review`; config can add to the set but never + remove a default) keep their static model or move to a higher one, so a + downgrade rule for `review` moves effort and `subagents`, never the + orchestrator's model. The resolved model and every persona model are + checked against the project's served list once per run; a routed model + that is not served falls back to the static choice, and a static model + that is not served fails the run before the sandbox exists, naming the + model. Nothing is retried inside the sandbox. 5. **Effort before model, model before runtime.** A downgrade lowers effort on the same model first, then moves within a vendor tier, then across vendors; a runtime move is never a downgrade rule's job. -6. **Every choice is echoed** with the rule that fired: plan block, - `metrics.json` (`routing.{mode,rule,applied,static_model,static_effort}`), +6. **Every choice is echoed** with the rules that set each field: plan block, + `metrics.json` (`routing.{mode,rules,applied,static_model,static_effort}`), root-span attributes `fullsend.routing.*`, status-comment footer. In `shadow` the rules are evaluated and recorded and the static choice runs. 7. **Learning is offline and lands as a pull request.** The root span carries - the routing ledger (choice, rule, task facts, cost, status, verdict) on + the routing ledger (choice, rules, task facts, cost, status, verdict) on the OTLP path of [ADR 0050](0050-distributed-tracing-instrumentation.md); a replay over that ledger scores a candidate policy, and the only path from a learned change to production is a reviewed edit to `routing:`. @@ -144,9 +157,9 @@ on the host, before the sandbox exists**, from a `routing:` block in - Presets may not ship `routing.rules` until the layered merge records which layer a key came from (the provenance gap ADR 0104 deferred); a lower layer may only tighten `never_downgrade` and `allowed_models`. -- The review orchestrator's model can move only by amending #6527's wording - in a later ADR, on shadow `per_model_usage` evidence; persona routing on the - Claude Code runtime remains the second half of ADR 0104. +- A rule can raise the review orchestrator's model; lowering it needs a later + ADR that amends #6527, on shadow `per_model_usage` evidence. Persona + routing on the Claude Code runtime remains the second half of ADR 0104. ### Deferred @@ -158,5 +171,6 @@ on the host, before the sandbox exists**, from a `routing:` block in ([#6531](https://github.com/fullsend-ai/fullsend/issues/6531)). That is a follow-on decision. The constraint this record fixes for it: an assessment read from author-controlled content may fire an escalation rule alone but - may satisfy a downgrade rule only together with a system-derived fact, and - it never widens the allowed set or crosses the never-downgrade floor. + may satisfy a downgrade rule only together with system-derived facts that + would justify the downgrade on their own, and it never widens the allowed + set or crosses the never-downgrade floor. diff --git a/docs/architecture.md b/docs/architecture.md index 2bad4cd3c0..0cd7f69006 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -237,7 +237,7 @@ flowchart TB **Decided (implementation):** - The `fullsend run` runner delegates in-sandbox agent execution to a `runtime.Runtime` interface; production orgs default to Claude Code, with [pi](https://github.com/earendil-works/pi) available as an opt-in second runtime (`runtime: pi`, Claude-on-Vertex through the same WIF credential path) and [codex](https://github.com/openai/codex) as a third (`runtime: codex`, OpenAI-only through a custom model provider whose bearer token comes from a runner-seeded file, with the sandbox tool hooks behind a translating adapter — [ADR 0099](ADRs/0099-codex-agent-runtime.md) and [ADR 0100](ADRs/0100-codex-sandbox-hooks.md)). Runtime selection is configured per repo with `runtime:` in `.fullsend/config.yaml` (per-agent `runtime`/`model`/`effort`/`subagents` on the agent's `agents:` entry sit above it and below the `--runtime`/`--model`/`--effort` flags and `FULLSEND_*` variables, [ADR 0091](ADRs/0091-per-agent-runtime-model-effort.md)) and resolved via `runtime.ResolveForAgent()`. Test-only runtimes — **dummy** (scripted operations) and **dummy-playback** (playlist-based replay of canned results) — execute in the real OpenShell sandbox for behaviour tests without inference. Bootstrap uses a portable `BootstrapInput` interface with optional extensions such as `SandboxHooksBootstrap` for the runtime-neutral sandbox tool hooks ([ADR 0090](ADRs/0090-runtime-neutral-sandbox-hooks-contract.md)); runtimes declare further capabilities through small optional interfaces (`DebugLogNamer`, `ContextBridger`) rather than `Name()` checks in the runner. Transcript and debug artifact handling use a separate `TranscriptHandler` interface. See [runtimes.md](runtimes.md) for the per-runtime security feature matrix required when adding a new backend. -- Runtime, model, effort and persona models are routed **per task** by a `routing:` policy in `.fullsend/config.yaml`, resolved by `fullsend run` on the host before the sandbox exists, from system-derived task facts only (forge change stats and paths, actor kind, allowlisted labels, attempt count — never PR text); a rule sits below the per-run flags and variables and above the agent's `agents:` entry, is bounded by `allowed_models`, a never-downgrade set, persona floors and a served-model preflight, and is echoed in the plan block, `metrics.json`, the root span and the status comment; `shadow` mode records the decision without acting on it, and learning lands only as a reviewed policy change ([ADR 0112](ADRs/0112-task-grain-routing-policy-on-the-host.md)). +- Runtime, model, effort and persona models are routed **per task** by a `routing:` policy in `.fullsend/config.yaml`, resolved by `fullsend run` on the host before the sandbox exists, from system-derived task facts only (forge change stats and paths, actor kind, allowlisted labels, attempt count — never PR text); a rule sits below the per-run flags and variables and above the agent's `agents:` entry, is bounded by `allowed_models`, a never-downgrade set, ADR 0104's closed persona-model set and a served-model preflight, and is echoed in the plan block, `metrics.json`, the root span and the status comment; `shadow` mode records the decision without acting on it, and learning lands only as a reviewed policy change ([ADR 0112](ADRs/0112-task-grain-routing-policy-on-the-host.md)). - Plugins are runtime-scoped harness resources: a harness declares `plugins:` as one list of directories in its own repository (same trust and fetch path as skills), and each entry's format decides which runtime loads it — a `plugin.json` bundle is Claude Code's, a directory pi's `-e` loader resolves is uploaded and loaded after a tree-hash preflight computed from the host copy. Each runtime names and skips the entries in the other format, so the list survives a runtime switch. Because `--no-extensions` plus explicit `-e` closes the set of code that can register tools, no per-tool declaration is needed ([ADR 0094](ADRs/0094-pi-extensions-are-harness-resources.md)). ### Behaviour testing diff --git a/docs/problems/adaptive-agent-selection.md b/docs/problems/adaptive-agent-selection.md index ddff4eb79c..13ea2fc054 100644 --- a/docs/problems/adaptive-agent-selection.md +++ b/docs/problems/adaptive-agent-selection.md @@ -206,6 +206,6 @@ The experiment should actively pressure-test three assumptions: - Should the fitness function include a cost term from the start, or should cost optimization be a separate experiment after quality optimization is validated? (For runtime and model selection, [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) judges cost per work item including re-review and fix rounds, and requires shadow-mode outcome evidence before any routed default changes; the composite fitness question remains open.) - What is the right exploration budget, and how should it decay? Too high wastes runs on poor configurations; too low starves new options. - Can fitness data transfer across repos with similar characteristics, and how do we measure "similar"? -- How should the adaptive layer interact with the deterministic safety model — is selection-only sufficient, or are there edge cases where the choice of configuration implicitly affects safety coverage? (Partially decided in [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) for the runtime/model surface: selection only over four config fields, with a never-downgrade set, persona floors and a closed model set as constraints, and no author-controlled input as a routing key.) +- How should the adaptive layer interact with the deterministic safety model — is selection-only sufficient, or are there edge cases where the choice of configuration implicitly affects safety coverage? (Partially decided in [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) for the runtime/model surface: selection only over four config fields, with a never-downgrade set and a closed model set as constraints, and no author-controlled input as a routing key.) - What prevents a well-scoring configuration from being well-scoring only because it is assigned to a biased subset of tasks (selection bias in the evaluation)? - Should there be a human-in-the-loop approval step before any configuration is retired, or is soft retirement with recovery probing sufficient? diff --git a/docs/problems/cross-run-memory.md b/docs/problems/cross-run-memory.md index acfee64bf5..24cb6ba5da 100644 --- a/docs/problems/cross-run-memory.md +++ b/docs/problems/cross-run-memory.md @@ -127,7 +127,7 @@ Retry loops can become flapping when the system does not converge. See [flapping ## Open questions -- Which run outcomes are safe to feed forward automatically, and which require human review first? (For routing decisions, [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md): none automatically — outcomes feed an offline replay whose result is a reviewed config change; the general question remains open.) +- Which run outcomes are safe to feed forward automatically, and which require human review first? - Should memory entries be observations only, or can any of them become instructions? - How should future agents distinguish system-derived facts from agent-authored interpretations? - Can non-review-gated memory be made safe enough, or should all durable memory promotion go through reviewed repo instructions or skills? From 3a5467d41df1f54dfc41af26b3876a92b560b7db Mon Sep 17 00:00:00 2001 From: Tim Pouyer Date: Mon, 28 Sep 2026 11:42:26 -0400 Subject: [PATCH 4/6] docs(adr): align ADR 0112 with the routing plan and entity-first dispatch Classify downgrades by an ordinal catalog tier, define persona min_tier as a floor on routed models only, and reject routed subagents a runtime cannot serve, applying subagents.default on Claude Code through CLAUDE_CODE_SUBAGENT_MODEL. Give rules ADR 0098's redacted entity and nullable event, source attempt count from handled-state evidence, tie trusted labels to 0098's label provenance, fail closed on actorless poll runs, and join outcomes on the entity's stable identity. Gate enforce on replay, pin advisor containment, require gateway providers to report the serving model, cite escalate-only prompt routing as prior art, and open the question of a decision model (Jev, Laya) as the advisor's classifier. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Tim Pouyer --- ...2-task-grain-routing-policy-on-the-host.md | 109 +++++++++++++----- docs/architecture.md | 2 +- docs/problems/adaptive-agent-selection.md | 2 +- 3 files changed, 81 insertions(+), 32 deletions(-) diff --git a/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md b/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md index bd99651bf5..bcfb05a24c 100644 --- a/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md +++ b/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md @@ -70,14 +70,18 @@ constraint rather than an objective, no self-deployment. sandbox sees only the prompt, which is author-controlled text; routing state is per sandbox and lost; it is Claude-Code-only; and the decision comes after the review has already read a diff it could have sized for free. +Prompt routing that only ever escalates, as it does in our internal chai +bot, is the safe case, since steering it costs only spend; fullsend's hard +case is the downgrade. **Routing in an LLM gateway.** Rejected as the place for the decision, kept as an optional provider. On Vertex the model is addressed in the URL path, so a gateway can route only if the client moves to the Anthropic Messages endpoint and the gateway holds the credential the sandbox never sees today; a silent rewrite also breaks the status-comment model echo, `per_model_usage` -and ADR 0104's closed set. Nothing a gateway sees carries the outcome that -arrives on a later forge event. +and ADR 0104's closed set, so a gateway provider must report the model that +served and fullsend accounts against that model. Nothing a gateway sees +carries the outcome that arrives on a later forge event. **A heuristic in the GitHub Route job** (#6891's proposal). Rejected: GitHub only, and a second place that decides model and effort next to the ADR 0091 @@ -87,7 +91,9 @@ chain. `fullsend run` resolves runtime, model, effort and persona models **per task, on the host, before the sandbox exists**, from a `routing:` block in -`.fullsend/config.yaml`. +`.fullsend/config.yaml`. Routing configures a run that dispatch has already +authorized and matched ([ADR 0098](0098-entity-first-harness-evaluation.md)); +it never decides whether a run happens. 1. **Shape.** `routing.rules[]` each carry `agents:`, a CEL `when:` and a `set:` that holds exactly the four fields an `agents:` entry holds @@ -99,39 +105,54 @@ on the host, before the sandbox exists**, from a `routing:` block in `enforce`. A malformed `routing:` block is a config-time error and the static choice runs. 2. **Inputs are system-derived.** Rules see a `task` variable beside - `runtime`, `config` and a redacted `event`: change stats and paths from - the forge files API, a deterministic change pattern, actor kind and role, - labels, attempt count, and the linked issue's number, state and labels. + `runtime`, `config`, a redacted `entity` and a redacted, nullable `event` + (ADR 0098's CEL environment; `event` is null on a poll-dispatched run): + change stats and paths from the forge files API, a deterministic change + pattern, actor kind and role, labels, attempt count (from ADR 0098's + handled-state evidence), and the linked issue's number, state and labels. PR and issue titles, bodies and comments, commit messages and branch - names are never routing inputs: they are removed from `event`, and a - `when:` that references them fails config validation. A downgrade rule - may key on PR or issue labels only from `routing.trusted_labels`; an - escalation rule may key on any label. + names are never routing inputs: they are removed from `event` and from + the entity's history, and a `when:` that references them fails config + validation. A downgrade rule may key on PR or issue labels only from + `routing.trusted_labels`, and only when ADR 0098's label provenance shows + the label was applied by someone other than the PR author holding at + least write permission; an escalation rule may key on any label. A run + with no actor (a scheduled poll) never satisfies a downgrade rule that + keys on actor kind or role. 3. **Precedence.** A rule sits below the `--runtime`/`--model`/`--effort` flags and `FULLSEND_*` variables and above the agent's `agents:` entry, so an explicit per-run override still wins and a rule only refines the static choice. 4. **Guards, validated at config time and before the sandbox.** A rule is a *downgrade* when any model or effort it resolves, for the agent or a - persona, sits below the static choice: effort by `low` < `medium` < - `high` < `xhigh` < `max`, model by its position in - `routing.allowed_models`, which is ordered lowest tier first; any other + persona, sits below the static choice: effort by `low` < `medium` < `high` + < `xhigh` < `max`, model by the ordinal `tier` (economy < standard < + premium) that each catalog entry carries beside its `vendor`; any other rule is an escalation, and every guard below applies to that computed result. Every model a rule names is in `routing.allowed_models` ∩ the - catalog, and persona models stay in ADR 0104's closed set; a runtime - change must keep the agent's needs (no persona roster on codex, fallback - chain on Claude only). The agents in `routing.never_downgrade` (default - `triage`, `prioritize` and `review`; config can add to the set but never - remove a default) keep their static model or move to a higher one, so a - downgrade rule for `review` moves effort and `subagents`, never the - orchestrator's model. The resolved model and every persona model are - checked against the project's served list once per run; a routed model - that is not served falls back to the static choice, and a static model - that is not served fails the run before the sandbox exists, naming the - model. Nothing is retried inside the sandbox. + catalog, and persona models stay in ADR 0104's closed set. A persona file + may declare `min_tier:`, a floor on *routed* persona models only: a rule + cannot place the persona below it, while a static `subagents.` + entry still resolves by ADR 0104's order. A runtime change must keep the + agent's needs (fallback chain on Claude only), and routed `subagents` must + be servable on the resolved runtime: on codex, which has no persona + roster, any `subagents` key is rejected; on Claude Code, + `subagents.default` is applied through `CLAUDE_CODE_SUBAGENT_MODEL` (never + `CLAUDE_CODE_SUBAGENT_MODEL_FORCE`, which would override persona + frontmatter) and named-persona keys are rejected until ADR 0104's Claude + half lands. The agents in `routing.never_downgrade` (default `triage`, + `prioritize` and `review`; config can add to the set but never remove a + default) keep their static model or move to a higher one, so a downgrade + rule for `review` moves effort and `subagents`, never the orchestrator's + model. The resolved model and every persona model are checked against the + project's served list once per run; a routed model that is not served + falls back to the static choice, and a static model that is not served + fails the run before the sandbox exists, naming the model. Nothing is + retried inside the sandbox. 5. **Effort before model, model before runtime.** A downgrade lowers effort - on the same model first, then moves within a vendor tier, then across - vendors; a runtime move is never a downgrade rule's job. + on the same model first, then moves to a lower catalog tier on the same + vendor, then across vendors; a runtime move is never a downgrade rule's + job. 6. **Every choice is echoed** with the rules that set each field: plan block, `metrics.json` (`routing.{mode,rules,applied,static_model,static_effort}`), root-span attributes `fullsend.routing.*`, status-comment footer. In @@ -139,8 +160,10 @@ on the host, before the sandbox exists**, from a `routing:` block in 7. **Learning is offline and lands as a pull request.** The root span carries the routing ledger (choice, rules, task facts, cost, status, verdict) on the OTLP path of [ADR 0050](0050-distributed-tracing-instrumentation.md); - a replay over that ledger scores a candidate policy, and the only path - from a learned change to production is a reviewed edit to `routing:`. + the outcome (merged, rework rounds) comes from later forge events joined + on the entity's stable identity, never from the agent that ran; a replay + over that ledger scores a candidate policy, and the only path from a + learned change to production is a reviewed edit to `routing:`. No in-run adaptation, no self-deployment. ## Consequences @@ -151,7 +174,9 @@ on the host, before the sandbox exists**, from a `routing:` block in above with the same mechanism. - Shadow mode plus the ledger produce the quality evidence #6361 lacked before any default changes; cost is judged per work item including - re-review and fix rounds, never per run. + re-review and fix rounds, never per run. A downgrade rule moves from + `shadow` to `enforce` only after replay shows it never downgraded a PR + whose review later requested changes. - The served-model preflight ends the retry-on-unavailable incident class for routed and static runs alike. - Presets may not ship `routing.rules` until the layered merge records which @@ -173,4 +198,28 @@ on the host, before the sandbox exists**, from a `routing:` block in read from author-controlled content may fire an escalation rule alone but may satisfy a downgrade rule only together with system-derived facts that would justify the downgrade on their own, and it never widens the allowed - set or crosses the never-downgrade floor. + set or crosses the never-downgrade floor. The advisor is an ordinary + sandboxed `fullsend run` on the repo's own inference path, never an + external classifier or decision API; an unsure, timed-out or failed + assessment leaves the static choice in place; and the advisor never + labels its own outcome. +- **A decision model as the advisor's classifier (open question).** Our + internal chai bot classifies each request with a small general model that + reads plain-language tier descriptions and answers with a tier, a + confidence and a one-line reason; every decision is logged, and a + human-labelled case set scores the classifier before it changes. A + decision model such as [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) + or [Laya](https://www.layer3labs.io/guides/laya-explained) could take the + fast-tier LLM's place. These models generate no text: one pass returns a + calibrated probability for each label of a closed set, in tens to hundreds + of milliseconds by their vendors' figures, so the `scope`, `risk` and + `domains` enums map onto them directly, a confidence floor reads a real + probability, and the ledger records the distribution in place of a + reason. With no tools and no free-text output, a steered input can only + pick a wrong label, which the asymmetric-trust rule already bounds. Open: + whether one matches a fast-tier LLM on a labelled set of fullsend tasks, + since these models are not built for multi-step reasoning over a diff; + whether a call this narrow still needs a sandboxed run or can be made from + the host; and serving. An open-weight, self-hosted model (Laya) fits the + repo's own inference path; a hosted decision API (Jev today) fails the + constraint above unless it becomes a provider on that path. diff --git a/docs/architecture.md b/docs/architecture.md index 0cd7f69006..fda22c0f05 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -237,7 +237,7 @@ flowchart TB **Decided (implementation):** - The `fullsend run` runner delegates in-sandbox agent execution to a `runtime.Runtime` interface; production orgs default to Claude Code, with [pi](https://github.com/earendil-works/pi) available as an opt-in second runtime (`runtime: pi`, Claude-on-Vertex through the same WIF credential path) and [codex](https://github.com/openai/codex) as a third (`runtime: codex`, OpenAI-only through a custom model provider whose bearer token comes from a runner-seeded file, with the sandbox tool hooks behind a translating adapter — [ADR 0099](ADRs/0099-codex-agent-runtime.md) and [ADR 0100](ADRs/0100-codex-sandbox-hooks.md)). Runtime selection is configured per repo with `runtime:` in `.fullsend/config.yaml` (per-agent `runtime`/`model`/`effort`/`subagents` on the agent's `agents:` entry sit above it and below the `--runtime`/`--model`/`--effort` flags and `FULLSEND_*` variables, [ADR 0091](ADRs/0091-per-agent-runtime-model-effort.md)) and resolved via `runtime.ResolveForAgent()`. Test-only runtimes — **dummy** (scripted operations) and **dummy-playback** (playlist-based replay of canned results) — execute in the real OpenShell sandbox for behaviour tests without inference. Bootstrap uses a portable `BootstrapInput` interface with optional extensions such as `SandboxHooksBootstrap` for the runtime-neutral sandbox tool hooks ([ADR 0090](ADRs/0090-runtime-neutral-sandbox-hooks-contract.md)); runtimes declare further capabilities through small optional interfaces (`DebugLogNamer`, `ContextBridger`) rather than `Name()` checks in the runner. Transcript and debug artifact handling use a separate `TranscriptHandler` interface. See [runtimes.md](runtimes.md) for the per-runtime security feature matrix required when adding a new backend. -- Runtime, model, effort and persona models are routed **per task** by a `routing:` policy in `.fullsend/config.yaml`, resolved by `fullsend run` on the host before the sandbox exists, from system-derived task facts only (forge change stats and paths, actor kind, allowlisted labels, attempt count — never PR text); a rule sits below the per-run flags and variables and above the agent's `agents:` entry, is bounded by `allowed_models`, a never-downgrade set, ADR 0104's closed persona-model set and a served-model preflight, and is echoed in the plan block, `metrics.json`, the root span and the status comment; `shadow` mode records the decision without acting on it, and learning lands only as a reviewed policy change ([ADR 0112](ADRs/0112-task-grain-routing-policy-on-the-host.md)). +- Runtime, model, effort and persona models are routed **per task** by a `routing:` policy in `.fullsend/config.yaml`, resolved by `fullsend run` on the host before the sandbox exists, from system-derived task facts only (forge change stats and paths, actor kind, allowlisted labels, attempt count — never PR text); a rule sits below the per-run flags and variables and above the agent's `agents:` entry, is bounded by `allowed_models`, a never-downgrade set, persona `min_tier` floors on routed models and a served-model preflight, and is echoed in the plan block, `metrics.json`, the root span and the status comment; `shadow` mode records the decision without acting on it, and learning lands only as a reviewed policy change ([ADR 0112](ADRs/0112-task-grain-routing-policy-on-the-host.md)). - Plugins are runtime-scoped harness resources: a harness declares `plugins:` as one list of directories in its own repository (same trust and fetch path as skills), and each entry's format decides which runtime loads it — a `plugin.json` bundle is Claude Code's, a directory pi's `-e` loader resolves is uploaded and loaded after a tree-hash preflight computed from the host copy. Each runtime names and skips the entries in the other format, so the list survives a runtime switch. Because `--no-extensions` plus explicit `-e` closes the set of code that can register tools, no per-tool declaration is needed ([ADR 0094](ADRs/0094-pi-extensions-are-harness-resources.md)). ### Behaviour testing diff --git a/docs/problems/adaptive-agent-selection.md b/docs/problems/adaptive-agent-selection.md index 13ea2fc054..717cbf9049 100644 --- a/docs/problems/adaptive-agent-selection.md +++ b/docs/problems/adaptive-agent-selection.md @@ -206,6 +206,6 @@ The experiment should actively pressure-test three assumptions: - Should the fitness function include a cost term from the start, or should cost optimization be a separate experiment after quality optimization is validated? (For runtime and model selection, [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) judges cost per work item including re-review and fix rounds, and requires shadow-mode outcome evidence before any routed default changes; the composite fitness question remains open.) - What is the right exploration budget, and how should it decay? Too high wastes runs on poor configurations; too low starves new options. - Can fitness data transfer across repos with similar characteristics, and how do we measure "similar"? -- How should the adaptive layer interact with the deterministic safety model — is selection-only sufficient, or are there edge cases where the choice of configuration implicitly affects safety coverage? (Partially decided in [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) for the runtime/model surface: selection only over four config fields, with a never-downgrade set and a closed model set as constraints, and no author-controlled input as a routing key.) +- How should the adaptive layer interact with the deterministic safety model — is selection-only sufficient, or are there edge cases where the choice of configuration implicitly affects safety coverage? (Partially decided in [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) for the runtime/model surface: selection only over four config fields, with a never-downgrade set, persona floors on routed models and a closed model set as constraints, and no author-controlled input as a routing key.) - What prevents a well-scoring configuration from being well-scoring only because it is assigned to a biased subset of tasks (selection bias in the evaluation)? - Should there be a human-in-the-loop approval step before any configuration is retired, or is soft retirement with recovery probing sufficient? From 3e2289efcab672d855c4119219d3ed270837e332 Mon Sep 17 00:00:00 2001 From: Tim Pouyer Date: Mon, 28 Sep 2026 16:22:58 -0400 Subject: [PATCH 5/6] docs(adr): close ADR 0112 review gaps on labels, floors and inputs Require trusted downgrade labels to come from a human non-author with write, and default trusted_labels and allowed_models to empty. Fail the run on a malformed routing block. Forbid routed persona tombstones and floor never-downgrade personas at their static tier unless they opt in. Classify escalation versus downgrade on the fully resolved result, keep escalations from being undercut by later downgrade matches, and recast effort-before-model as guidance. Describe routing's CEL environment as its own allowlist, make task.actor null on poll runs, narrow the no-retry claim, make the advisor constraint checkable, and prefix tier uses. Mark the architecture.md line as decided but not implemented. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Tim Pouyer --- ...2-task-grain-routing-policy-on-the-host.md | 149 ++++++++++-------- docs/architecture.md | 2 +- docs/problems/adaptive-agent-selection.md | 2 +- 3 files changed, 88 insertions(+), 65 deletions(-) diff --git a/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md b/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md index bcfb05a24c..6cc5b5df25 100644 --- a/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md +++ b/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md @@ -97,39 +97,53 @@ it never decides whether a run happens. 1. **Shape.** `routing.rules[]` each carry `agents:`, a CEL `when:` and a `set:` that holds exactly the four fields an `agents:` entry holds - (`runtime`, `model`, `effort`, `subagents`); nothing else is routable. - All matching rules merge, later entries win per field (the ADR 0088 - semantics); `subagents` merges per persona key with ADR 0104's rules, - `~` tombstones included, as one more layer above the `agents:` entry. - `routing.mode` is `off` (the default when omitted), `shadow` or - `enforce`. A malformed `routing:` block is a config-time error and the - static choice runs. -2. **Inputs are system-derived.** Rules see a `task` variable beside - `runtime`, `config`, a redacted `entity` and a redacted, nullable `event` - (ADR 0098's CEL environment; `event` is null on a poll-dispatched run): - change stats and paths from the forge files API, a deterministic change - pattern, actor kind and role, labels, attempt count (from ADR 0098's - handled-state evidence), and the linked issue's number, state and labels. - PR and issue titles, bodies and comments, commit messages and branch - names are never routing inputs: they are removed from `event` and from - the entity's history, and a `when:` that references them fails config - validation. A downgrade rule may key on PR or issue labels only from - `routing.trusted_labels`, and only when ADR 0098's label provenance shows - the label was applied by someone other than the PR author holding at - least write permission; an escalation rule may key on any label. A run - with no actor (a scheduled poll) never satisfies a downgrade rule that - keys on actor kind or role. + (`runtime`, `model`, `effort`, `subagents`); nothing else is routable. All + matching rules merge, later entries win per field (the ADR 0088 + semantics), except that when any matching rule for an agent is an + escalation, no field of the merged result falls below the static choice. + `subagents` merges per persona key with ADR 0104's rules, as one more + layer above the `agents:` entry, but a routed value may not tombstone + (`~`) a persona. When omitted, `routing.mode` is `off` (the others are + `shadow` and `enforce`) and `routing.allowed_models` and + `routing.trusted_labels` are empty, so no rule may name a model or key a + downgrade on a label. `fullsend run` validates `routing:` itself on every + run, as it does `agents:` (ADR 0091); a malformed block fails the run + before the sandbox exists rather than running without its escalations. +2. **Inputs are system-reported and allowlisted.** Rules evaluate in + routing's own CEL environment: ADR 0088's `runtime` and `config`, an + allowlisted view of ADR 0098's `entity` and nullable `event` (kind, id, + source system, state, and labels with their provenance; fields the + normalized schema gains later stay hidden until this list names them), and + a new `task` variable: change stats and paths from the forge files API, a + deterministic change pattern, actor kind and role, labels, an attempt + count that routing derives from ADR 0098's handled-state evidence, and the + linked issue's number, state and labels. Titles, bodies, comments, command + and instruction fields, commit messages and branch names are never + visible, and a `when:` that references a field outside the allowlist fails + validation. Paths and stats are reported by the forge but chosen by the + author, so a downgrade threshold on them is a risk the reviewed policy + accepts, not a trusted signal. A downgrade rule may key on a PR or issue + label only from `routing.trusted_labels`, and only when ADR 0098's + provenance shows it was applied by a human (never a bot, App or fullsend + identity) other than the PR author whose current permission is at least + write; ADR 0098 reports permission at evaluation time, not when the label + was applied. An escalation rule may key on any label. `task.actor` is the + prompting event's actor and is null on poll, schedule and manual runs, + never the service identity the normalized event names there, so an + actor-keyed downgrade never matches them. 3. **Precedence.** A rule sits below the `--runtime`/`--model`/`--effort` flags and `FULLSEND_*` variables and above the agent's `agents:` entry, so an explicit per-run override still wins and a rule only refines the static choice. -4. **Guards, validated at config time and before the sandbox.** A rule is a - *downgrade* when any model or effort it resolves, for the agent or a - persona, sits below the static choice: effort by `low` < `medium` < `high` - < `xhigh` < `max`, model by the ordinal `tier` (economy < standard < - premium) that each catalog entry carries beside its `vendor`; any other - rule is an escalation, and every guard below applies to that computed - result. Every model a rule names is in `routing.allowed_models` ∩ the +4. **Guards, validated at config time and before the sandbox.** + Classification uses the fully resolved result for each agent and persona: + a rule is an *escalation* only when every resolved field is equal to or + above the static choice and at least one is above it, with effort ordered + `low` < `medium` < `high` < `xhigh` < `max` and models by the ordinal + model tier (economy < standard < premium) that each catalog entry carries + beside its `vendor`. Anything else, including a runtime change or a + same-tier model swap, is a *downgrade*, and every guard below applies to + that result. Every model a rule names is in `routing.allowed_models` ∩ the catalog, and persona models stay in ADR 0104's closed set. A persona file may declare `min_tier:`, a floor on *routed* persona models only: a rule cannot place the persona below it, while a static `subagents.` @@ -142,17 +156,21 @@ it never decides whether a run happens. frontmatter) and named-persona keys are rejected until ADR 0104's Claude half lands. The agents in `routing.never_downgrade` (default `triage`, `prioritize` and `review`; config can add to the set but never remove a - default) keep their static model or move to a higher one, so a downgrade - rule for `review` moves effort and `subagents`, never the orchestrator's - model. The resolved model and every persona model are checked against the - project's served list once per run; a routed model that is not served - falls back to the static choice, and a static model that is not served - fails the run before the sandbox exists, naming the model. Nothing is - retried inside the sandbox. -5. **Effort before model, model before runtime.** A downgrade lowers effort - on the same model first, then moves to a lower catalog tier on the same - vendor, then across vendors; a runtime move is never a downgrade rule's - job. + default) keep their static model or move to a higher one, and their + personas are floored at their static model's tier unless the persona file + declares a lower `min_tier`. A downgrade rule for `review` may therefore + lower its effort and the personas that opt in, never the orchestrator's + model or a persona that does not. The resolved model and every persona + model are checked against the project's served list once per run; a routed + model that is not served falls back to the static choice, and a static + model that is not served fails the run before the sandbox exists, naming + the model. An unservable id is never discovered and retried inside the + sandbox; Claude's existing `--fallback-model` chain is unchanged. +5. **Effort before model, model before runtime** (authoring guidance, not + validated). A downgrade should lower effort on the same model first, then + move to a lower model tier on the same vendor, then across vendors; a + runtime move is not a downgrade rule's job. A rule may still set several + fields at once. 6. **Every choice is echoed** with the rules that set each field: plan block, `metrics.json` (`routing.{mode,rules,applied,static_model,static_effort}`), root-span attributes `fullsend.routing.*`, status-comment footer. In @@ -185,41 +203,46 @@ it never decides whether a run happens. - A rule can raise the review orchestrator's model; lowering it needs a later ADR that amends #6527, on shadow `per_model_usage` evidence. Persona routing on the Claude Code runtime remains the second half of ADR 0104. +- "Tier" gains a fourth meaning here; when the catalog's model tier ships, + [tier-conventions.md](../contributing/tier-conventions.md) gains a "model + tier" entry. ### Deferred - **A routing advisor.** Rules cannot read a diff; a short, read-only run on - the fast tier can, and its schema-validated verdict (`scope`, `risk`, + the fast model tier can, and its schema-validated verdict (`scope`, `risk`, `domains`) can become a `task.assessment` fact beside the system-derived - ones, with an in-run counterpart that lets a worker consult a stronger - model without switching session model + ones, with an in-run counterpart that lets a worker consult a stronger model + without switching session model ([#6531](https://github.com/fullsend-ai/fullsend/issues/6531)). That is a follow-on decision. The constraint this record fixes for it: an assessment read from author-controlled content may fire an escalation rule alone but may satisfy a downgrade rule only together with system-derived facts that - would justify the downgrade on their own, and it never widens the allowed - set or crosses the never-downgrade floor. The advisor is an ordinary - sandboxed `fullsend run` on the repo's own inference path, never an - external classifier or decision API; an unsure, timed-out or failed - assessment leaves the static choice in place; and the advisor never - labels its own outcome. + would justify the downgrade on their own (with every `task.assessment` + predicate replaced by `true`, the rule's `when:` must still match on the + same task facts), and it never widens the allowed set or crosses the + never-downgrade floor. The advisor is an ordinary sandboxed `fullsend run` + on the repo's own inference path, never an external classifier or decision + API; an unsure, timed-out or failed assessment leaves the static choice in + place; and the advisor never labels its own outcome. - **A decision model as the advisor's classifier (open question).** Our internal chai bot classifies each request with a small general model that - reads plain-language tier descriptions and answers with a tier, a - confidence and a one-line reason; every decision is logged, and a - human-labelled case set scores the classifier before it changes. A - decision model such as [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) - or [Laya](https://www.layer3labs.io/guides/laya-explained) could take the + reads plain-language model-tier descriptions and answers with a model tier, + a confidence and a one-line reason; every decision is logged, and a + human-labelled case set scores the classifier before it changes. A decision + model such as + [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) or + [Laya](https://www.layer3labs.io/guides/laya-explained) could take the fast-tier LLM's place. These models generate no text: one pass returns a calibrated probability for each label of a closed set, in tens to hundreds of milliseconds by their vendors' figures, so the `scope`, `risk` and `domains` enums map onto them directly, a confidence floor reads a real - probability, and the ledger records the distribution in place of a - reason. With no tools and no free-text output, a steered input can only - pick a wrong label, which the asymmetric-trust rule already bounds. Open: - whether one matches a fast-tier LLM on a labelled set of fullsend tasks, - since these models are not built for multi-step reasoning over a diff; - whether a call this narrow still needs a sandboxed run or can be made from - the host; and serving. An open-weight, self-hosted model (Laya) fits the - repo's own inference path; a hosted decision API (Jev today) fails the - constraint above unless it becomes a provider on that path. + probability, and the ledger records the distribution in place of a reason. + With no tools and no free-text output, a steered input can only pick a wrong + label, which the asymmetric-trust rule already bounds. Open: whether one + matches a fast-tier LLM on a labelled set of fullsend tasks, since these + models are not built for multi-step reasoning over a diff; whether a call + this narrow still needs a sandboxed run or can be made from the host; and + serving. An open-weight, self-hosted model (Laya) fits the repo's own + inference path; a hosted decision API (Jev today) fails the constraint above + unless it becomes a provider on that path. diff --git a/docs/architecture.md b/docs/architecture.md index fda22c0f05..21cdb2430b 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -237,7 +237,7 @@ flowchart TB **Decided (implementation):** - The `fullsend run` runner delegates in-sandbox agent execution to a `runtime.Runtime` interface; production orgs default to Claude Code, with [pi](https://github.com/earendil-works/pi) available as an opt-in second runtime (`runtime: pi`, Claude-on-Vertex through the same WIF credential path) and [codex](https://github.com/openai/codex) as a third (`runtime: codex`, OpenAI-only through a custom model provider whose bearer token comes from a runner-seeded file, with the sandbox tool hooks behind a translating adapter — [ADR 0099](ADRs/0099-codex-agent-runtime.md) and [ADR 0100](ADRs/0100-codex-sandbox-hooks.md)). Runtime selection is configured per repo with `runtime:` in `.fullsend/config.yaml` (per-agent `runtime`/`model`/`effort`/`subagents` on the agent's `agents:` entry sit above it and below the `--runtime`/`--model`/`--effort` flags and `FULLSEND_*` variables, [ADR 0091](ADRs/0091-per-agent-runtime-model-effort.md)) and resolved via `runtime.ResolveForAgent()`. Test-only runtimes — **dummy** (scripted operations) and **dummy-playback** (playlist-based replay of canned results) — execute in the real OpenShell sandbox for behaviour tests without inference. Bootstrap uses a portable `BootstrapInput` interface with optional extensions such as `SandboxHooksBootstrap` for the runtime-neutral sandbox tool hooks ([ADR 0090](ADRs/0090-runtime-neutral-sandbox-hooks-contract.md)); runtimes declare further capabilities through small optional interfaces (`DebugLogNamer`, `ContextBridger`) rather than `Name()` checks in the runner. Transcript and debug artifact handling use a separate `TranscriptHandler` interface. See [runtimes.md](runtimes.md) for the per-runtime security feature matrix required when adding a new backend. -- Runtime, model, effort and persona models are routed **per task** by a `routing:` policy in `.fullsend/config.yaml`, resolved by `fullsend run` on the host before the sandbox exists, from system-derived task facts only (forge change stats and paths, actor kind, allowlisted labels, attempt count — never PR text); a rule sits below the per-run flags and variables and above the agent's `agents:` entry, is bounded by `allowed_models`, a never-downgrade set, persona `min_tier` floors on routed models and a served-model preflight, and is echoed in the plan block, `metrics.json`, the root span and the status comment; `shadow` mode records the decision without acting on it, and learning lands only as a reviewed policy change ([ADR 0112](ADRs/0112-task-grain-routing-policy-on-the-host.md)). +- Decided in [ADR 0112](ADRs/0112-task-grain-routing-policy-on-the-host.md), not yet implemented: runtime, model, effort and persona models will be routed **per task** by a `routing:` policy in `.fullsend/config.yaml`, resolved by `fullsend run` on the host before the sandbox exists, from an allowlist of system-reported task facts (forge change stats and paths, actor kind, trusted labels applied by a human other than the author, attempt count — never author-written text); a rule will sit below the per-run flags and variables and above the agent's `agents:` entry, bounded by `allowed_models`, a never-downgrade set, persona `min_tier` floors on routed models and a served-model preflight, and echoed in the plan block, `metrics.json`, the root span and the status comment; `shadow` mode will record the decision without acting on it, and learning lands only as a reviewed policy change. - Plugins are runtime-scoped harness resources: a harness declares `plugins:` as one list of directories in its own repository (same trust and fetch path as skills), and each entry's format decides which runtime loads it — a `plugin.json` bundle is Claude Code's, a directory pi's `-e` loader resolves is uploaded and loaded after a tree-hash preflight computed from the host copy. Each runtime names and skips the entries in the other format, so the list survives a runtime switch. Because `--no-extensions` plus explicit `-e` closes the set of code that can register tools, no per-tool declaration is needed ([ADR 0094](ADRs/0094-pi-extensions-are-harness-resources.md)). ### Behaviour testing diff --git a/docs/problems/adaptive-agent-selection.md b/docs/problems/adaptive-agent-selection.md index 717cbf9049..1fe3ee9ec0 100644 --- a/docs/problems/adaptive-agent-selection.md +++ b/docs/problems/adaptive-agent-selection.md @@ -206,6 +206,6 @@ The experiment should actively pressure-test three assumptions: - Should the fitness function include a cost term from the start, or should cost optimization be a separate experiment after quality optimization is validated? (For runtime and model selection, [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) judges cost per work item including re-review and fix rounds, and requires shadow-mode outcome evidence before any routed default changes; the composite fitness question remains open.) - What is the right exploration budget, and how should it decay? Too high wastes runs on poor configurations; too low starves new options. - Can fitness data transfer across repos with similar characteristics, and how do we measure "similar"? -- How should the adaptive layer interact with the deterministic safety model — is selection-only sufficient, or are there edge cases where the choice of configuration implicitly affects safety coverage? (Partially decided in [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) for the runtime/model surface: selection only over four config fields, with a never-downgrade set, persona floors on routed models and a closed model set as constraints, and no author-controlled input as a routing key.) +- How should the adaptive layer interact with the deterministic safety model — is selection-only sufficient, or are there edge cases where the choice of configuration implicitly affects safety coverage? (Partially decided in [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) for the runtime/model surface: selection only over four config fields, with a closed model set, a never-downgrade set that pins the deciding session's model and floors its personas unless they opt in (its effort may still drop), and no author-written text as a routing key; paths and change stats are author-chosen facts a policy may still key on.) - What prevents a well-scoring configuration from being well-scoring only because it is assigned to a biased subset of tasks (selection bias in the evaluation)? - Should there be a human-in-the-loop approval step before any configuration is retired, or is soft retirement with recovery probing sufficient? From cd903f67486ac2db9d3d0b80a244b2d19e3ef637 Mon Sep 17 00:00:00 2001 From: Tim Pouyer Date: Tue, 29 Sep 2026 13:16:40 -0400 Subject: [PATCH 6/6] docs(adr): address #7808 review and trim ADR 0112 to the decision Address the review on 3e2289efc by @waynesun09, @ifireball and the review agent, then cut ADR 0112 from about 313 to 86 content lines so it records one decision, per skills/writing-adrs. Implementation detail is left to follow-up implementation work: the trusted-label and trusted-actor tests and the list of protected paths, the CEL environment and its edge cases, merge and preflight mechanics, echo escaping, runtime notes, and presets. Review follow-up: drop per-runtime inventories (codex personas, "fallback chain on Claude only", CLAUDE_CODE_SUBAGENT_MODEL and _FORCE); state the catalog model tier as a field to add; cite #6527 only as the rule's origin; echo the rules a guard suppressed; and add the prompt-cache argument to Options. The overlays alternative is left to a separate rewrite, so the ADR no longer mentions ADR 0088. State at decision level what the trim must keep: - While any escalation matches, no field falls below static, and runtime or a swap within the same model tier keeps its static value. - An escalation keeps the runtime and changes a model only to a higher model tier; anything else is a downgrade. - never_downgrade agents keep their runtime and never lose model tier, while escalations may raise them and their personas. - Downgrades key only on evidence the change's author cannot supply and never apply to changes touching agent-instruction or policy files. - Rules override the agents: entry; flags and FULLSEND_* still win. - The served-list preflight runs only with routing on and fails a static model only when nothing in its fallback chain is served. - A downgrade rule reaches enforce only after replay evidence. Declare routing in repos.yaml for ADR 0122-managed repos, where any loosening is a relaxation under its safety gate. Align architecture.md and the problem docs with the trimmed text, shorten the decision-model open question, and add model tier to tier-conventions.md. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Tim Pouyer --- .../0091-per-agent-runtime-model-effort.md | 5 +- ...2-task-grain-routing-policy-on-the-host.md | 279 +++++------------- docs/architecture.md | 2 +- docs/contributing/tier-conventions.md | 1 + docs/problems/adaptive-agent-selection.md | 5 +- docs/problems/operational-observability.md | 2 +- 6 files changed, 85 insertions(+), 209 deletions(-) diff --git a/docs/ADRs/0091-per-agent-runtime-model-effort.md b/docs/ADRs/0091-per-agent-runtime-model-effort.md index 5a935ed3de..8b85f0282e 100644 --- a/docs/ADRs/0091-per-agent-runtime-model-effort.md +++ b/docs/ADRs/0091-per-agent-runtime-model-effort.md @@ -111,8 +111,9 @@ Config-layer addition, slotting in below per-run overrides: > default ``` -[ADR 0112](0112-task-grain-routing-policy-on-the-host.md) adds per-task -`routing.rules` between the `FULLSEND_*` variables and the `agents:` entry. +[ADR 0112](0112-task-grain-routing-policy-on-the-host.md) (decided, not yet +implemented) will add per-task `routing.rules` between the `FULLSEND_*` +variables and the `agents:` entry. The repo-wide `runtime:` key is kept as the default for agents that set none — deliberately not removed: existing configs, `fullsend github setup diff --git a/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md b/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md index 6cc5b5df25..e3af6c5961 100644 --- a/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md +++ b/docs/ADRs/0112-task-grain-routing-policy-on-the-host.md @@ -29,220 +29,93 @@ Accepted ## Context -A repo can say *which* runtime, model, effort and per-persona model an agent -uses ([ADR 0091](0091-per-agent-runtime-model-effort.md), -[ADR 0104](0104-per-persona-model-resolution.md)), but not *when*. Every -choice is static per agent, so a one-line docs change and a 2,000-line CI -refactor get the same opus-at-high review. CEL overlays cannot set `model` -or `effort` ([ADR 0088](0088-cel-guarded-overlays.md): both are operational, -not forge-specific), and the normalized event carries no diff size or paths. -Open issues ask for the next step from three directions: a cheaper model or -effort for trivially scoped changes -([#5777](https://github.com/fullsend-ai/fullsend/issues/5777), -[#6891](https://github.com/fullsend-ai/fullsend/issues/6891), -[#2842](https://github.com/fullsend-ai/fullsend/issues/2842), -[agents#497](https://github.com/fullsend-ai/agents/issues/497)), deeper -review when security signals are present -([agents#535](https://github.com/fullsend-ai/agents/issues/535)), and a way -to see the cost effect of a model change before merging it -([#6560](https://github.com/fullsend-ai/fullsend/issues/6560)). - -Two facts bound the design. The runtime-parity rule that *the deciding -session is never downgraded* ([#6527](https://github.com/fullsend-ai/fullsend/issues/6527)) -still holds. And catalog membership is not availability: four incidents -([#6964](https://github.com/fullsend-ai/fullsend/issues/6964), -[agents#1225](https://github.com/fullsend-ai/agents/issues/1225)) discovered -an unservable id at the first model call, after the sandbox existed, and -retried on opus at several times the cost. A closed draft -([#6361](https://github.com/fullsend-ai/fullsend/pull/6361)) prototyped -per-prompt routing with Claude Code hooks inside the sandbox and measured a -13-issue by 3-model grid on the code agent (opus a median 3.6× haiku; every -model stopped early on the no-change issues); it measured cost and -completion, not quality. -[adaptive-agent-selection.md](../problems/adaptive-agent-selection.md) asks -how selection should learn from outcomes and names the constraints any -learned policy must keep: selection only, shadow mode first, safety as a -constraint rather than an objective, no self-deployment. +A repo can say *which* runtime, model, effort and persona model an agent uses +([ADR 0091](0091-per-agent-runtime-model-effort.md), [ADR +0104](0104-per-persona-model-resolution.md)) but not *when*. +Issues ask for cheaper runs on trivial changes (#5777, #2842, agents#497), +deeper review on security signals (agents#535) and a cost preview (#6560). The +deciding session's model is never downgraded (#6527), a listed model may be +unservable (#6964, agents#1225), and a learned policy keeps the constraints in +[adaptive-agent-selection.md](../problems/adaptive-agent-selection.md). ## Options -**Per-prompt routing inside the sandbox** (the #6361 hooks). Rejected: the -sandbox sees only the prompt, which is author-controlled text; routing state -is per sandbox and lost; it is Claude-Code-only; and the decision comes after -the review has already read a diff it could have sized for free. -Prompt routing that only ever escalates, as it does in our internal chai -bot, is the safe case, since steering it costs only spend; fullsend's hard -case is the downgrade. - -**Routing in an LLM gateway.** Rejected as the place for the decision, kept -as an optional provider. On Vertex the model is addressed in the URL path, so -a gateway can route only if the client moves to the Anthropic Messages -endpoint and the gateway holds the credential the sandbox never sees today; a -silent rewrite also breaks the status-comment model echo, `per_model_usage` -and ADR 0104's closed set, so a gateway provider must report the model that -served and fullsend accounts against that model. Nothing a gateway sees -carries the outcome that arrives on a later forge event. - -**A heuristic in the GitHub Route job** (#6891's proposal). Rejected: GitHub -only, and a second place that decides model and effort next to the ADR 0091 -chain. +Rejected: **per-prompt routing in the sandbox** (#6361), which reads +author-controlled prompts and loses the prompt cache mid-loop, and a +**Route-job heuristic** (#6891), GitHub-only and a second decision point. An +**LLM gateway** stays only an optional provider that reports the model that +served. ## Decision `fullsend run` resolves runtime, model, effort and persona models **per task, on the host, before the sandbox exists**, from a `routing:` block in -`.fullsend/config.yaml`. Routing configures a run that dispatch has already -authorized and matched ([ADR 0098](0098-entity-first-harness-evaluation.md)); -it never decides whether a run happens. - -1. **Shape.** `routing.rules[]` each carry `agents:`, a CEL `when:` and a - `set:` that holds exactly the four fields an `agents:` entry holds - (`runtime`, `model`, `effort`, `subagents`); nothing else is routable. All - matching rules merge, later entries win per field (the ADR 0088 - semantics), except that when any matching rule for an agent is an - escalation, no field of the merged result falls below the static choice. - `subagents` merges per persona key with ADR 0104's rules, as one more - layer above the `agents:` entry, but a routed value may not tombstone - (`~`) a persona. When omitted, `routing.mode` is `off` (the others are - `shadow` and `enforce`) and `routing.allowed_models` and - `routing.trusted_labels` are empty, so no rule may name a model or key a - downgrade on a label. `fullsend run` validates `routing:` itself on every - run, as it does `agents:` (ADR 0091); a malformed block fails the run - before the sandbox exists rather than running without its escalations. -2. **Inputs are system-reported and allowlisted.** Rules evaluate in - routing's own CEL environment: ADR 0088's `runtime` and `config`, an - allowlisted view of ADR 0098's `entity` and nullable `event` (kind, id, - source system, state, and labels with their provenance; fields the - normalized schema gains later stay hidden until this list names them), and - a new `task` variable: change stats and paths from the forge files API, a - deterministic change pattern, actor kind and role, labels, an attempt - count that routing derives from ADR 0098's handled-state evidence, and the - linked issue's number, state and labels. Titles, bodies, comments, command - and instruction fields, commit messages and branch names are never - visible, and a `when:` that references a field outside the allowlist fails - validation. Paths and stats are reported by the forge but chosen by the - author, so a downgrade threshold on them is a risk the reviewed policy - accepts, not a trusted signal. A downgrade rule may key on a PR or issue - label only from `routing.trusted_labels`, and only when ADR 0098's - provenance shows it was applied by a human (never a bot, App or fullsend - identity) other than the PR author whose current permission is at least - write; ADR 0098 reports permission at evaluation time, not when the label - was applied. An escalation rule may key on any label. `task.actor` is the - prompting event's actor and is null on poll, schedule and manual runs, - never the service identity the normalized event names there, so an - actor-keyed downgrade never matches them. -3. **Precedence.** A rule sits below the `--runtime`/`--model`/`--effort` - flags and `FULLSEND_*` variables and above the agent's `agents:` entry, - so an explicit per-run override still wins and a rule only refines the - static choice. -4. **Guards, validated at config time and before the sandbox.** - Classification uses the fully resolved result for each agent and persona: - a rule is an *escalation* only when every resolved field is equal to or - above the static choice and at least one is above it, with effort ordered - `low` < `medium` < `high` < `xhigh` < `max` and models by the ordinal - model tier (economy < standard < premium) that each catalog entry carries - beside its `vendor`. Anything else, including a runtime change or a - same-tier model swap, is a *downgrade*, and every guard below applies to - that result. Every model a rule names is in `routing.allowed_models` ∩ the - catalog, and persona models stay in ADR 0104's closed set. A persona file - may declare `min_tier:`, a floor on *routed* persona models only: a rule - cannot place the persona below it, while a static `subagents.` - entry still resolves by ADR 0104's order. A runtime change must keep the - agent's needs (fallback chain on Claude only), and routed `subagents` must - be servable on the resolved runtime: on codex, which has no persona - roster, any `subagents` key is rejected; on Claude Code, - `subagents.default` is applied through `CLAUDE_CODE_SUBAGENT_MODEL` (never - `CLAUDE_CODE_SUBAGENT_MODEL_FORCE`, which would override persona - frontmatter) and named-persona keys are rejected until ADR 0104's Claude - half lands. The agents in `routing.never_downgrade` (default `triage`, - `prioritize` and `review`; config can add to the set but never remove a - default) keep their static model or move to a higher one, and their - personas are floored at their static model's tier unless the persona file - declares a lower `min_tier`. A downgrade rule for `review` may therefore - lower its effort and the personas that opt in, never the orchestrator's - model or a persona that does not. The resolved model and every persona - model are checked against the project's served list once per run; a routed - model that is not served falls back to the static choice, and a static - model that is not served fails the run before the sandbox exists, naming - the model. An unservable id is never discovered and retried inside the - sandbox; Claude's existing `--fallback-model` chain is unchanged. -5. **Effort before model, model before runtime** (authoring guidance, not - validated). A downgrade should lower effort on the same model first, then - move to a lower model tier on the same vendor, then across vendors; a - runtime move is not a downgrade rule's job. A rule may still set several - fields at once. -6. **Every choice is echoed** with the rules that set each field: plan block, - `metrics.json` (`routing.{mode,rules,applied,static_model,static_effort}`), - root-span attributes `fullsend.routing.*`, status-comment footer. In - `shadow` the rules are evaluated and recorded and the static choice runs. -7. **Learning is offline and lands as a pull request.** The root span carries - the routing ledger (choice, rules, task facts, cost, status, verdict) on - the OTLP path of [ADR 0050](0050-distributed-tracing-instrumentation.md); - the outcome (merged, rework rounds) comes from later forge events joined - on the entity's stable identity, never from the agent that ran; a replay - over that ledger scores a candidate policy, and the only path from a - learned change to production is a reviewed edit to `routing:`. - No in-run adaptation, no self-deployment. +`.fullsend/config.yaml`, declared in `repos.yaml` for repositories [ADR +0122](0122-declarative-repo-configuration.md) manages, where any change that +loosens routing is a relaxation under its safety gate. It configures a run that +dispatch has already authorized ([ADR +0098](0098-entity-first-harness-evaluation.md)) and never decides whether a run +happens. + +1. **Shape.** `routing.rules[]` carry `agents:`, a CEL `when:`, an optional + `mode:` and a `set:` of the four fields an `agents:` entry holds. Matching + rules merge later-wins per field. While any matching escalation applies, + no field falls below the static choice or below the highest value an + escalation set, and a field with no order (runtime, a model of the same + model tier) keeps its static value. `routing.mode` is `off` (default), + `shadow` (rules are recorded, the static choice runs) or `enforce`, and a + rule may act less than its block, never more. A malformed block fails the + run before the sandbox exists. Rules override the agent's `agents:` entry + and the repo default; flags and `FULLSEND_*` variables still beat any + rule. +2. **Inputs are system-reported.** Rules see an allowlisted environment: + change stats and paths, actor, labels, attempt count and the linked + issue's number, state and labels. Author-written text is never visible; + paths and stats are author-chosen, a risk the reviewed policy accepts, but + a downgrade never applies to a change that touches agent-instruction or + policy files. A downgrade may key on a label or actor only through a + reviewed trust list that fails closed, and only on evidence the change's + author cannot supply. An escalation may key on anything visible. +3. **Guards.** A rule is an escalation only if it keeps the static runtime + and every other field it resolves is unchanged or above the static choice + (effort `low` to `max`; a changed model only on a higher catalog model + tier); anything else, including a runtime change or a swap to another + model of the same model tier, is a downgrade. Models come from + `routing.allowed_models` (empty by default) and the catalog. Agents in + `routing.never_downgrade` (default `triage`, `prioritize`, `review`; it + can only grow) keep their static runtime and keep their static model or + move to a higher model tier, and their personas never go below their + static model tier unless a persona file sets a lower `min_tier`; + escalations may raise both. + `routing:` and `min_tier:` come from the base branch or pinned harness, + never the change being routed. When `routing.mode` is not `off`, every + model is checked against its provider's served list before the sandbox + exists: a routed miss falls back to static, and a static miss fails the + run only when no model in its existing fallback chain is served. +4. **Echo.** The plan block, `metrics.json`, root span and status comment + name the rules that set each field and those a guard suppressed. +5. **Learning is offline.** A routing ledger on the root span ([ADR + 0050](0050-distributed-tracing-instrumentation.md)), outcomes from later + forge events and a replay score candidate policies; a reviewed edit to + `routing:` is the only path to production, and a downgrade rule moves to + `enforce` only after replay shows it never downgraded a PR whose review + later requested changes. ## Consequences -- A repo can express "sonnet at low effort for docs-only changes" and "opus - at xhigh with opus security and challenger personas when `internal/scaffold/` - changes" as reviewed config, resolving the downgrade and escalation issues - above with the same mechanism. -- Shadow mode plus the ledger produce the quality evidence #6361 lacked - before any default changes; cost is judged per work item including - re-review and fix rounds, never per run. A downgrade rule moves from - `shadow` to `enforce` only after replay shows it never downgraded a PR - whose review later requested changes. -- The served-model preflight ends the retry-on-unavailable incident class for - routed and static runs alike. -- Presets may not ship `routing.rules` until the layered merge records which - layer a key came from (the provenance gap ADR 0104 deferred); a lower layer - may only tighten `never_downgrade` and `allowed_models`. -- A rule can raise the review orchestrator's model; lowering it needs a later - ADR that amends #6527, on shadow `per_model_usage` evidence. Persona - routing on the Claude Code runtime remains the second half of ADR 0104. -- "Tier" gains a fourth meaning here; when the catalog's model tier ships, - [tier-conventions.md](../contributing/tier-conventions.md) gains a "model - tier" entry. +- Docs-only downgrades and security escalations become reviewed config; a + downgrade of `review` reaches only its effort and opted-in personas, while + an escalation may also raise its model. +- For repos that turn routing on, the preflight ends the + retry-on-unavailable incident class on every provider that exposes a + served list; repos with routing `off` see no new failure mode. +- Implementing this adds a model tier to catalog entries and provenance fields + to ADR 0098's entity specification. ### Deferred -- **A routing advisor.** Rules cannot read a diff; a short, read-only run on - the fast model tier can, and its schema-validated verdict (`scope`, `risk`, - `domains`) can become a `task.assessment` fact beside the system-derived - ones, with an in-run counterpart that lets a worker consult a stronger model - without switching session model - ([#6531](https://github.com/fullsend-ai/fullsend/issues/6531)). That is a - follow-on decision. The constraint this record fixes for it: an assessment - read from author-controlled content may fire an escalation rule alone but - may satisfy a downgrade rule only together with system-derived facts that - would justify the downgrade on their own (with every `task.assessment` - predicate replaced by `true`, the rule's `when:` must still match on the - same task facts), and it never widens the allowed set or crosses the - never-downgrade floor. The advisor is an ordinary sandboxed `fullsend run` - on the repo's own inference path, never an external classifier or decision - API; an unsure, timed-out or failed assessment leaves the static choice in - place; and the advisor never labels its own outcome. -- **A decision model as the advisor's classifier (open question).** Our - internal chai bot classifies each request with a small general model that - reads plain-language model-tier descriptions and answers with a model tier, - a confidence and a one-line reason; every decision is logged, and a - human-labelled case set scores the classifier before it changes. A decision - model such as - [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) or - [Laya](https://www.layer3labs.io/guides/laya-explained) could take the - fast-tier LLM's place. These models generate no text: one pass returns a - calibrated probability for each label of a closed set, in tens to hundreds - of milliseconds by their vendors' figures, so the `scope`, `risk` and - `domains` enums map onto them directly, a confidence floor reads a real - probability, and the ledger records the distribution in place of a reason. - With no tools and no free-text output, a steered input can only pick a wrong - label, which the asymmetric-trust rule already bounds. Open: whether one - matches a fast-tier LLM on a labelled set of fullsend tasks, since these - models are not built for multi-step reasoning over a diff; whether a call - this narrow still needs a sandboxed run or can be made from the host; and - serving. An open-weight, self-hosted model (Laya) fits the repo's own - inference path; a hosted decision API (Jev today) fails the constraint above - unless it becomes a provider on that path. +- **A routing advisor** that reads the diff (#6531) may fire an escalation + alone, but a downgrade rule may use its assessment only as one condition and + must still match with that condition removed; its classifier is an open + question in + [adaptive-agent-selection.md](../problems/adaptive-agent-selection.md). diff --git a/docs/architecture.md b/docs/architecture.md index 21cdb2430b..abaa6ae806 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -237,7 +237,7 @@ flowchart TB **Decided (implementation):** - The `fullsend run` runner delegates in-sandbox agent execution to a `runtime.Runtime` interface; production orgs default to Claude Code, with [pi](https://github.com/earendil-works/pi) available as an opt-in second runtime (`runtime: pi`, Claude-on-Vertex through the same WIF credential path) and [codex](https://github.com/openai/codex) as a third (`runtime: codex`, OpenAI-only through a custom model provider whose bearer token comes from a runner-seeded file, with the sandbox tool hooks behind a translating adapter — [ADR 0099](ADRs/0099-codex-agent-runtime.md) and [ADR 0100](ADRs/0100-codex-sandbox-hooks.md)). Runtime selection is configured per repo with `runtime:` in `.fullsend/config.yaml` (per-agent `runtime`/`model`/`effort`/`subagents` on the agent's `agents:` entry sit above it and below the `--runtime`/`--model`/`--effort` flags and `FULLSEND_*` variables, [ADR 0091](ADRs/0091-per-agent-runtime-model-effort.md)) and resolved via `runtime.ResolveForAgent()`. Test-only runtimes — **dummy** (scripted operations) and **dummy-playback** (playlist-based replay of canned results) — execute in the real OpenShell sandbox for behaviour tests without inference. Bootstrap uses a portable `BootstrapInput` interface with optional extensions such as `SandboxHooksBootstrap` for the runtime-neutral sandbox tool hooks ([ADR 0090](ADRs/0090-runtime-neutral-sandbox-hooks-contract.md)); runtimes declare further capabilities through small optional interfaces (`DebugLogNamer`, `ContextBridger`) rather than `Name()` checks in the runner. Transcript and debug artifact handling use a separate `TranscriptHandler` interface. See [runtimes.md](runtimes.md) for the per-runtime security feature matrix required when adding a new backend. -- Decided in [ADR 0112](ADRs/0112-task-grain-routing-policy-on-the-host.md), not yet implemented: runtime, model, effort and persona models will be routed **per task** by a `routing:` policy in `.fullsend/config.yaml`, resolved by `fullsend run` on the host before the sandbox exists, from an allowlist of system-reported task facts (forge change stats and paths, actor kind, trusted labels applied by a human other than the author, attempt count — never author-written text); a rule will sit below the per-run flags and variables and above the agent's `agents:` entry, bounded by `allowed_models`, a never-downgrade set, persona `min_tier` floors on routed models and a served-model preflight, and echoed in the plan block, `metrics.json`, the root span and the status comment; `shadow` mode will record the decision without acting on it, and learning lands only as a reviewed policy change. +- Runtime, model, effort and persona models will be routed **per task** by a `routing:` policy in `.fullsend/config.yaml`, resolved by `fullsend run` on the host before the sandbox exists from allowlisted, system-reported task facts; a rule sits below the per-run flags and variables and above the agent's `agents:` entry, a downgrade rule moves to `enforce` only after `shadow` and replay evidence, and every rule is bounded by guards the ADR lists (decided in [ADR 0112](ADRs/0112-task-grain-routing-policy-on-the-host.md), not yet implemented). - Plugins are runtime-scoped harness resources: a harness declares `plugins:` as one list of directories in its own repository (same trust and fetch path as skills), and each entry's format decides which runtime loads it — a `plugin.json` bundle is Claude Code's, a directory pi's `-e` loader resolves is uploaded and loaded after a tree-hash preflight computed from the host copy. Each runtime names and skips the entries in the other format, so the list survives a runtime switch. Because `--no-extensions` plus explicit `-e` closes the set of code that can register tools, no per-tool declaration is needed ([ADR 0094](ADRs/0094-pi-extensions-are-harness-resources.md)). ### Behaviour testing diff --git a/docs/contributing/tier-conventions.md b/docs/contributing/tier-conventions.md index 2adb0159aa..47e5f63fea 100644 --- a/docs/contributing/tier-conventions.md +++ b/docs/contributing/tier-conventions.md @@ -7,5 +7,6 @@ The term "tier" is used in multiple distinct contexts across this codebase. Alwa | **credential delivery tier** | The four-tier model for how agents receive credentials: (1) prefetch + post-process, (2) providers + L7, (3) host-side REST server, (4) host files | [ADR 0025](../ADRs/0025-provider-credential-delivery-for-sandboxed-agents.md) | | **intent authorization tier** | The four-tier model for change authorization: (0) standing rules, (1) tactical/issue, (2) strategic, (3) organizational | [intent-representation.md](../problems/intent-representation.md) | | **configuration tier** | The three-tier inheritance model for agent configuration: upstream defaults -> org config -> per-repo overrides. The `customized/` overlay mechanism (ADR-0035) has been removed; use config-driven agent registration per [ADR 0064](../ADRs/0064-deprecate-customized-directory-overlay.md) | [ADR 0035](../ADRs/0035-layered-content-resolution.md) | +| **model tier** | The ordinal on a model catalog entry that per-task routing uses to tell an escalation from a downgrade and to floor persona models (decided, not yet implemented) | [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) | **Do not** use bare "Tier N" or "tier" without a prefix — the same number means different things in different contexts (e.g., "Tier 2" could be provider-based credential delivery or strategic intent authorization). External tier references (e.g., "GitLab Free tier", "GitHub plan tiers") are exempt from this convention. diff --git a/docs/problems/adaptive-agent-selection.md b/docs/problems/adaptive-agent-selection.md index 1fe3ee9ec0..6d32647a3a 100644 --- a/docs/problems/adaptive-agent-selection.md +++ b/docs/problems/adaptive-agent-selection.md @@ -203,9 +203,10 @@ The experiment should actively pressure-test three assumptions: - GA vs. Thompson Sampling — or both at different layers? TS for team/config selection, GA for workflow evolution is the leading hypothesis, but it needs validation. - How fine-grained should context tuples be? A hierarchical split-on-variance approach avoids committing to a fixed schema, but adds implementation complexity. - How do we handle model version changes — reset fitness data, apply a discount, or version-tag and keep history? -- Should the fitness function include a cost term from the start, or should cost optimization be a separate experiment after quality optimization is validated? (For runtime and model selection, [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) judges cost per work item including re-review and fix rounds, and requires shadow-mode outcome evidence before any routed default changes; the composite fitness question remains open.) +- Should the fitness function include a cost term from the start, or should cost optimization be a separate experiment after quality optimization is validated? (For runtime and model selection, [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) scores candidate routing policies offline by replaying a ledger of routing choices against later forge outcomes, and a downgrade rule reaches `enforce` only after replay shows it never downgraded a PR whose review later requested changes; the composite fitness and cost-term questions remain open.) - What is the right exploration budget, and how should it decay? Too high wastes runs on poor configurations; too low starves new options. - Can fitness data transfer across repos with similar characteristics, and how do we measure "similar"? -- How should the adaptive layer interact with the deterministic safety model — is selection-only sufficient, or are there edge cases where the choice of configuration implicitly affects safety coverage? (Partially decided in [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) for the runtime/model surface: selection only over four config fields, with a closed model set, a never-downgrade set that pins the deciding session's model and floors its personas unless they opt in (its effort may still drop), and no author-written text as a routing key; paths and change stats are author-chosen facts a policy may still key on.) +- How should the adaptive layer interact with the deterministic safety model — is selection-only sufficient, or are there edge cases where the choice of configuration implicitly affects safety coverage? (Partially decided in [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) for the runtime/model surface: selection only over four config fields, with a closed model set, a never-downgrade set that never lowers the deciding session's model and floors its personas unless they opt in (its effort may still drop), and no author-written text as a routing key; paths and change stats are author-chosen facts a policy may still key on.) - What prevents a well-scoring configuration from being well-scoring only because it is assigned to a biased subset of tasks (selection bias in the evaluation)? - Should there be a human-in-the-loop approval step before any configuration is retired, or is soft retirement with recovery probing sufficient? +- Can a decision model classify tasks for routing? [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md) defers a routing advisor that reads the diff and leaves its classifier open. A purpose-built decision model such as [Jev](https://typesafe.ai/blog/introducing-system-one-models-and-jev) or [Laya](https://www.layer3labs.io/guides/laya-explained) returns a probability for each label of a closed set rather than text, so a steered input can only pick a wrong label and fullsend could set its own abstention threshold from that distribution. Open: whether such a model matches a small fast LLM on labelled fullsend tasks, and whether it can sit on the repo's own inference path (an open-weight, self-hosted model can; a hosted decision API cannot unless it becomes a provider there). diff --git a/docs/problems/operational-observability.md b/docs/problems/operational-observability.md index 61f4e4bae6..10e9f9c288 100644 --- a/docs/problems/operational-observability.md +++ b/docs/problems/operational-observability.md @@ -191,7 +191,7 @@ This works for early experimentation when the volume is low and the operators ar - ~~How do we keep the triggering event and the agent run linked in the GitHub Actions UI for debugging?~~ Decided in [ADR 0041](../ADRs/0041-synchronous-workflow-call-event-dispatch.md) (synchronous `workflow_call` dispatch for the event path). - How should trace access be controlled? (JSONL trace exposure decided in [ADR 0021](../ADRs/0021-jsonl-reasoning-trace-exposure.md): owner-scoped storage with credential scanning as defense-in-depth. Broader question of balancing security and transparency for non-JSONL observability data remains open.) - What retention policy applies to traces? Indefinite retention supports audit requirements but increases storage cost and data sensitivity exposure. Time-bounded retention (e.g., 90 days) limits exposure but may lose traces needed for incident investigation. -- How do we measure "is the system getting better"? What metrics constitute a meaningful quality signal for an autonomous software factory? Merge revert rate? Human override rate? Time-to-review? Cost per decision? Some composite score? The choice of metric shapes what gets optimized. First-ship trend scores (trace fitness on wild runs, local `eval-measurements.jsonl`) are [ADR 0087](../ADRs/0087-eval-measurements-online-trace-scoring.md); richer quality signals remain open. Routing decisions and the task facts behind them are recorded on the root span (`fullsend.routing.*`) so cost can be compared per work item across model choices ([ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md)). +- How do we measure "is the system getting better"? What metrics constitute a meaningful quality signal for an autonomous software factory? Merge revert rate? Human override rate? Time-to-review? Cost per decision? Some composite score? The choice of metric shapes what gets optimized. First-ship trend scores (trace fitness on wild runs, local `eval-measurements.jsonl`) are [ADR 0087](../ADRs/0087-eval-measurements-online-trace-scoring.md); richer quality signals remain open. Routing decisions and the task facts behind them will be recorded as a routing ledger on the root span so outcomes can be compared across model choices (decided in [ADR 0112](../ADRs/0112-task-grain-routing-policy-on-the-host.md), not yet implemented). - Should trace scoring cover run *health*, not just trace *health*? Trace *fitness* ([ADR 0087](../ADRs/0087-eval-measurements-online-trace-scoring.md)'s `trace_fitness`) checks that a run's telemetry is well-formed — span tree, identity, model, usage, cost, and exit present and coherent — but not whether the run *behaved* correctly. A separate class of failure is structurally decidable straight from the trace, with no model in the loop: a tool that returned an error the run then ignored, an errored result reused by a later side-effecting call, no-progress loops, or a job that reports success despite an in-trace failure (e.g. [#6621](https://github.com/fullsend-ai/fullsend/issues/6621)). Two questions follow. First, does the eval-measure layer grow a second scorer for these run-*health* defects — the deterministic complement to the statistical evals in [testing-agents.md](testing-agents.md), catching what is provable from a single trace rather than what needs repeated runs — or does behavioral correctness belong with the review and retro agents instead? Second, there is a prerequisite either way: the structured-trace ideal described above records each tool call's result, but tool *results* are only partly on the trace: `execute_tool` spans carry per-call error status (`error.type=tool_error` when a result is flagged `is_error`, [ADR 0108](../ADRs/0108-tool-call-span-topology.md)) only for id-bearing calls — Claude Code today; pi and codex emit no call ids ([#7414](https://github.com/fullsend-ai/fullsend/issues/7414)) — and result content is recorded only at opt-in Level 3 ([ADR 0050](../ADRs/0050-distributed-tracing-instrumentation.md)), again on Claude runs only. The highest-value rules therefore still depend on extending capture across runtimes and levels — itself a telemetry-contract decision. Prior discussion in [#7246](https://github.com/fullsend-ai/fullsend/issues/7246). - At what scale does a dedicated LLM observability platform justify its operational overhead (Postgres, ClickHouse, Redis, S3 for something like Langfuse)? Is there a threshold of agent activity below which structured logging suffices? Score files are local JSONL ([ADR 0087](../ADRs/0087-eval-measurements-online-trace-scoring.md)); remote scores reuse `OTEL_EXPORTER_OTLP_*`. Platform choice remains open. - ~~How do we handle the bootstrapping problem — the factory needs observability to improve, but building the observability infrastructure is itself work that competes with building the factory?~~ Decided in [ADR 0050](../ADRs/0050-distributed-tracing-instrumentation.md): zero-configuration baseline (local JSONL + summary files) eliminates infrastructure requirements for initial observability; OTLP export adds backends when the org is ready.