Skip to content

feat(evals): add a delegation-accuracy trajectory case - #230

Merged
pgermishuys merged 4 commits into
mainfrom
feat/trajectory-delegation-case
Sep 23, 2026
Merged

pgermishuys merged 4 commits into
mainfrom
feat/trajectory-delegation-case

Conversation

@pgermishuys

Copy link
Copy Markdown
Contributor

Refs #183 (Spec 37, task 20.1: delegation accuracy, the first of three runtime behaviour cases)

What

  • New case loom-delegates-backend-fix-to-category-trajectory (loom-routing, harness_trajectory, opencode-local, starts on Loom). It uses the new fixture evals/fixtures/orders-api, a small Bun project with backend and frontend categories. The user reports, in plain words, that GET /orders/:id returns 200 with a null body. Loom must delegate to the shuttle-backend category shuttle and to nothing else, and shuttle-backend must then edit the code.
  • Session-audit metrics it stands for: Delegations, Configuration delegation failures, Built-in agent delegations (explore/general) and Category-shuttle success. The rubric notes and the new "Runtime behaviour cases" table in docs/agent-evals.md both name them.
  • Schema extension: one optional field, allowed_delegates (documented in Spec 35 under "Runtime behaviour checks (Spec 37, task 20.1)"). It was needed because expected_spawns checks an exact ordered sequence, and under the Spec 33 pass rule a matching sequence passes the case even when the spawned agent then failed. With a verifier, the case would also pass when Loom did the work itself. allowed_delegates is one execution check. It requires at least one spawn, every spawned sub-agent in the list, and a code edit made by one of them. The edit comes from the observer's per-agent records and proves the delegated agent's model resolved. Like expected_commands, it gates the pass. The adapter and the publishable surface are unchanged. Tests: schema (types.test.ts), scoring (trajectory-scoring.test.ts: happy path, a built-in delegation next to a good one, Loom doing the work itself, a delegate that never edits, a bookkeeping-only edit), and the full pipeline through workflow-sync.test.ts, which loads every real case.
  • Two runner.test.ts tests run the real loom-routing corpus live with stubs. They now pass track: "text". The new case allows claude-sonnet-4.5, so without it they started real Podman containers (with a fake key) and timed out.
  • Workflow allowlists (ALLOWED_CASES, ALLOWED_TRAJECTORY_CASES), evals/README.md and the tasks file are updated. 20.1 stays unticked until all three cases land.

Live run

One run, deepseek/deepseek-v4-flash-0731, --raw-artifacts (raw files not committed): PASS, weighted total 1.00. Loom grepped and read the code, then delegated once to shuttle-backend. shuttle-backend edited src/api/orders.ts (and the test file) and ran bun test (exit 0). No explore/general or other sub-agent was spawned. Cost < $0.01 (OpenRouter usage 110.9131 → 110.9170).

This is the baseline for the delegation-accuracy case. On main, with the category-model fix (b4f8efac), the category shuttle resolves and Loom routes to it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01T15PT3299yvdvr6gkzyDmk

Copilot AI lite review requested due to automatic review settings September 23, 2026 20:55
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 1cbbb6fc-de66-4604-927b-9292306c7380

📥 Commits

Reviewing files that changed from the base of the PR and between 8df47c2 and d250bb0.

⛔ Files ignored due to path filters (7)
  • .codesight/CODESIGHT.md is excluded by !.codesight/**
  • .codesight/config.md is excluded by !.codesight/**
  • .codesight/coverage.md is excluded by !.codesight/**
  • .codesight/libs.md is excluded by !.codesight/**
  • .codesight/middleware.md is excluded by !.codesight/**
  • docs/specs/35-spec-verification-trajectory-evals/35-spec-verification-trajectory-evals.md is excluded by !docs/specs/**
  • docs/specs/37-spec-repository-foundation/37-tasks-repository-foundation.md is excluded by !docs/specs/**
📒 Files selected for processing (16)
  • .github/workflows/agent-evals.yml
  • docs/agent-evals.md
  • evals/README.md
  • evals/cases/loom-routing/loom-delegates-backend-fix-to-category-trajectory.json
  • evals/fixtures/orders-api/.weave/config.weave
  • evals/fixtures/orders-api/package.json
  • evals/fixtures/orders-api/src/api/orders.ts
  • evals/fixtures/orders-api/src/db/orders.ts
  • evals/fixtures/orders-api/src/ui/order-badge.ts
  • evals/fixtures/orders-api/test/orders.test.ts
  • evals/rubrics/loom-routing/loom-delegates-backend-fix-to-category-trajectory.json
  • packages/cli/src/evals/__tests__/runner.test.ts
  • packages/cli/src/evals/__tests__/trajectory-scoring.test.ts
  • packages/cli/src/evals/__tests__/types.test.ts
  • packages/cli/src/evals/trajectory-scoring.ts
  • packages/cli/src/evals/types.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

pgermishuys added a commit that referenced this pull request Sep 23, 2026
pgermishuys and others added 3 commits September 23, 2026 20:57
Adds loom-delegates-backend-fix-to-category-trajectory (Spec 37, 20.1),
the first of three runtime behaviour cases from the September session
audit. It stands in for the Delegations, Configuration delegation failures,
Built-in agent delegations and Category-shuttle success metrics.

The orders-api fixture declares backend and frontend categories. The user
reports that `GET /orders/:id` returns 200 with a null body. Loom must
delegate to the shuttle-backend category shuttle and nothing else, and
shuttle-backend must then edit the code.

The existing schema could not express that promise. `expected_spawns`
checks an exact ordered sequence, and under the Spec 33 pass rule a
matching sequence passes even when the spawned agent then failed. So the
smallest extension is one optional field, `allowed_delegates`. It is one
execution check, and like expected_commands it gates the pass. The check
requires at least one spawn, every spawned sub-agent in the list, and a
code edit by one of them. The edit is taken from the observer's per-agent
records, and it proves that the delegated agent's model resolved.

Two runner tests that run the real loom-routing corpus live now pass
`track: "text"`. The new case allows claude-sonnet-4.5, so without it they
would start a Podman sandbox.

Live run (DeepSeek V4 Flash, 1 run): pass. Loom read the code and
delegated once to shuttle-backend, which edited src/api/orders.ts and ran
bun test. No other sub-agent was spawned. Cost < $0.01.

Refs #183

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T15PT3299yvdvr6gkzyDmk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T15PT3299yvdvr6gkzyDmk
@pgermishuys
pgermishuys force-pushed the feat/trajectory-delegation-case branch from 15dfb32 to 0a47324 Compare September 23, 2026 21:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Delegation validation and successful, spawned-agent edit attribution are not yet fully enforced.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds a delegation-accuracy trajectory evaluation, including the allowed_delegates schema, scoring logic, tests, fixture, documentation, and workflow updates.

Changes:

  • Adds the orders-api evaluation fixture and delegation case.
  • Extends schema validation and trajectory scoring.
  • Adds tests, rubric metadata, documentation, and allowlist updates.
  • Delegation attribution and edit verification require changes before approval.
File Reviewed changes
packages/​cli/​src/​evals/​types.ts Adds allowed_delegates schema support.
packages/​cli/​src/​evals/​trajectory-scoring.ts Scores delegation restrictions and delegate edits; changes required for validation and edit attribution.
packages/​cli/​src/​evals/​__tests__/​types.test.ts Tests schema validation.
packages/​cli/​src/​evals/​__tests__/​trajectory-scoring.test.ts Tests delegation scoring scenarios.
packages/​cli/​src/​evals/​__tests__/​runner.test.ts Updates runner tests to use the text track.
evals/​rubrics/​loom-routing/​loom-delegates-backend-fix-to-category-trajectory.json Adds rubric metadata.
evals/​README.md Documents the new case and fixture.
evals/​fixtures/​orders-api/​test/​orders.test.ts Adds fixture tests.
evals/​fixtures/​orders-api/​src/​ui/​order-badge.ts Adds fixture UI code.
evals/​fixtures/​orders-api/​src/​db/​orders.ts Adds fixture database code.
evals/​fixtures/​orders-api/​src/​api/​orders.ts Adds fixture API code.
evals/​fixtures/​orders-api/​package.json Defines fixture package configuration.
evals/​fixtures/​orders-api/​.weave/​config.weave Adds fixture Weave configuration.
evals/​cases/​loom-routing/​loom-delegates-backend-fix-to-category-trajectory.json Defines the delegation trajectory case.
docs/​specs/​37-spec-repository-foundation/​37-tasks-repository-foundation.md Updates task tracking.
docs/​specs/​35-spec-verification-trajectory-evals/​35-spec-verification-trajectory-evals.md Documents the runtime verification check.
docs/​agent-evals.md Documents runtime behavior coverage.
.github/​workflows/​agent-evals.yml Updates evaluation allowlists.
.codesight/​CODESIGHT.md Updates generated metadata.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 23, 2026 21:01
An edit attributed to an allowed agent that was never spawned no longer
satisfies the check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T15PT3299yvdvr6gkzyDmk

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Unresolved moderate scoring issues could allow invalid delegation results to pass.

Review effort: Lite
Findings: 1 Medium severity

Open (1)

Copilot AI review requested due to automatic review settings September 23, 2026 21:05
@pgermishuys
pgermishuys merged commit 010009c into main Sep 23, 2026
7 checks passed
@pgermishuys
pgermishuys deleted the feat/trajectory-delegation-case branch September 23, 2026 21:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Fix the two critical validation and edit-detection issues before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity

Open (2)
Resolved since last review (1)

Comment on lines +264 to +266
const editedByDelegate = codeEdits(events).some((event) =>
spawnedDelegates.has(event.agentName),
);
* of them made a code edit, so the delegation reached a working agent.
* Like `expected_commands`, it gates the pass.
*/
allowed_delegates: z.array(IdentifierSchema).min(1).optional(),
pgermishuys added a commit that referenced this pull request Sep 25, 2026
…ry rules

Spec 38 item 3 (root causes c and e), written as the behaviour wanted:

- loom.md and tapestry.md: "Delegate only to the agents listed above."
  The example names (shuttle-backend, shuttle-frontend, shuttle-core) and
  the shuttle-{category} placeholder are gone; specialists are referred to
  by role or through the rendered delegation list, so a disabled agent
  such as warp is no longer named.
- loom.md: the size rule. Loom does small, self-contained work itself and
  delegates work that spans several files, needs exploration, needs a
  plan, or is a review. It replaces "Small or self-contained work",
  "Delegate aggressively" and "Never delegate work you can complete
  correctly in one step".
- loom.md and tapestry.md: the recovery rule. Resend once after a
  transient error; after a configuration error send the task to shuttle
  and tell the user which agent is broken. Tapestry's retry is folded in.
- Copilot: drop the placeholder rewrite; the appended section points to
  "the matching category shuttle listed above". Bundle regenerated.
- Delegation contract: the item-3 it.failing assertions are plain it,
  except where item 2 is still needed. Guard tests assert the new
  sentences.
- #230 trajectory case now spans the handler and the data layer, since a
  one-file fix is work the size rule lets Loom do itself.

Refs #253

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T15PT3299yvdvr6gkzyDmk
pgermishuys added a commit that referenced this pull request Sep 25, 2026
Tick group 3 in the Spec 38 tasks file with the wording decisions, the
agents" rule in prompt-composition.md, and bring the Copilot adapter doc,
the L2 notes in testing-strategy.md and the #230 row in agent-evals.md in
line with the new prompts.

Refs #253

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T15PT3299yvdvr6gkzyDmk
pgermishuys added a commit that referenced this pull request Sep 25, 2026
…(Spec 38 item 3) (#257)

* feat(prompts): give Loom and Tapestry the delegation, size and recovery rules

Spec 38 item 3 (root causes c and e), written as the behaviour wanted:

- loom.md and tapestry.md: "Delegate only to the agents listed above."
  The example names (shuttle-backend, shuttle-frontend, shuttle-core) and
  the shuttle-{category} placeholder are gone; specialists are referred to
  by role or through the rendered delegation list, so a disabled agent
  such as warp is no longer named.
- loom.md: the size rule. Loom does small, self-contained work itself and
  delegates work that spans several files, needs exploration, needs a
  plan, or is a review. It replaces "Small or self-contained work",
  "Delegate aggressively" and "Never delegate work you can complete
  correctly in one step".
- loom.md and tapestry.md: the recovery rule. Resend once after a
  transient error; after a configuration error send the task to shuttle
  and tell the user which agent is broken. Tapestry's retry is folded in.
- Copilot: drop the placeholder rewrite; the appended section points to
  "the matching category shuttle listed above". Bundle regenerated.
- Delegation contract: the item-3 it.failing assertions are plain it,
  except where item 2 is still needed. Guard tests assert the new
  sentences.
- #230 trajectory case now spans the handler and the data layer, since a
  one-file fix is work the size rule lets Loom do itself.

Refs #253

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T15PT3299yvdvr6gkzyDmk

* docs(spec-38): record the group 3 prompt rules and their measurement

Tick group 3 in the Spec 38 tasks file with the wording decisions, the
agents" rule in prompt-composition.md, and bring the Copilot adapter doc,
the L2 notes in testing-strategy.md and the #230 row in agent-evals.md in
line with the new prompts.

Refs #253

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T15PT3299yvdvr6gkzyDmk

* fix(prompts): keep Loom's category-shuttle sentence free of agent names

"its entry in the list above describes that area" contained the substring
"scribe", which the OpenCode 2 name-collision scenario from item 2 reads as
Loom still naming another plugin's `scribe` agent. Reword it to "says which
area it covers" and regenerate the Copilot bundle.

Refs #253

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T15PT3299yvdvr6gkzyDmk

* docs(spec-38): record the tapestry-category-routing re-measurement

After #259 composed each case's categories into Tapestry's list, the
group 3 prompts show no change beyond the noise on the suite (DeepSeek
30/30 -> 29/30, GPT 6 Luna 30/30 -> 30/30, --models dev --repeat 3).

Refs #253

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T15PT3299yvdvr6gkzyDmk

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants