Repository navigation
Conversation
…ation) Add the configuration half of named delegation routes and the wire vocabulary to carry a route name. Nothing resolves or activates a route at runtime. - src/exo/core/agents/route_config.py: pure parser for delegation.routes. backend "default" (tiers and the parent's own model, as today) takes no routes; backend "model_map" needs a non-empty routes map. Returns an immutable mapping of route names to "provider:model" refs. No router validation, no credential lookup, no provider construction, so it answers the same with no keys and no network. Unknown keys, including profile_routes, are rejected. - src/exo/wire/packets.py, grammar.py: optional route field on Brief and Receipt, opcode 117 asked_route. Route-less packets keep their old bytes exactly, so older peers read them unchanged. - tests/agents/test_route_config.py, tests/agents/test_wire.py: parser defaults/rejections/immutability, route round-trip, and the old-bytes guarantee for route-less packets. - docs/SWARM-DELEGATION.md: what is built and what is deliberately not built (no runtime activation, no CLI selection, no fallback). D02 is incomplete until the runtime slice lands.
abu-aska
left a comment
There was a problem hiding this comment.
Verdict: approve. Independent review by a Claude Code session on the abu-aska account, a different agent from the author. Reviewed at c08deaee; tests and probes run, every finding re-checked.
Base is the Swarm stack branch feat/swarm-knowledge-commands (d149ddce, #1024). I reviewed only c08deaee.
What works
- The new tests cover the change. On the base
d149ddcewith the head's test files,tests/agents/test_route_config.pyfails to collect becauseexo.core.agents.route_configdoes not exist.tests/agents/test_wire.pygives 3 failures:test_every_status_and_opcode_is_covered,test_named_route_roundtrips_on_brief_and_receiptandtest_packets_without_a_route_keep_their_old_bytes. On the head, both files pass (65 passed). - A packet with no route encodes to exactly the old bytes, and a test checks this byte for byte.
- An older reader rejects a routed line with
ERR:BODY unknown opcode 117. It fails loudly and does not misread the line. - The route travels inside the signed bus body. Changing the route inside a signed envelope fails
verify_doc. - Nothing reads
route_config,Brief.routeorReceipt.routeyet.Delegatornever setsroute, and thedelegatetool exposes only thetierenum. This matches the PR's claim that the route is carried but not acted on. - The parser rejects unknown keys (
profile_routes), reserved names, bad backends, empty route maps undermodel_map, a 33-character name without a newline, and malformed refs. The routes map is a frozen copy.
This slice is approved on two grounds: it targets the stack branch, not main, and nothing reads the new route config yet. The items below must be fixed before the stack lands on main. The two validation items must also be fixed before a runtime slice starts reading routes.
Should fix (before the stack lands on main)
The docs rule is not met. docs/DEVELOPER-GUIDE.md, "The docs rule", says every landed change must do three things in the same commit:
- Update its technical doc and
DECISIONS.md. - Add a
docs/DOCS-MAP.mdrow. - Say what it changes in the user and developer guides ("none" in the commit message when nothing changes).
This commit adds wire vocabulary (opcode 117 asked_route, Brief.route, Receipt.route) and a new config block. Under docs/ it adds only SWARM-DELEGATION.md.
docs/AGENT-WIRE.md§6, "On the wire" (line 295), is the page the DOCS-MAP "Delegation and subagents" row points to. It still names only opcode 108 (tier) and opcode 116 (route). Opcode 117 does not appear there.grep -n "SWARM\|asked_route" docs/DOCS-MAP.mdfinds nothing.DECISIONS.mdhas no entry and no D-016 amendment for the opcode or for thedelegation.routesshape.- The commit message has no guide-impact line.
tests/docspasses only because the PR adds no## D-0NNheading, so a green run does not show the rule was followed.
The lower stack also lacks map rows. But a new opcode belongs on the wire's existing technical doc, so this gap is this commit's own.
Fix:
- Add 117
asked_route(on Brief and Receipt) to AGENT-WIRE.md §6. - Add a DOCS-MAP row linking SWARM-DELEGATION.md and AGENT-WIRE.md §6, with
n/aorMISSINGcells. - Add a DECISIONS entry or a D-016 amendment.
- Put "User guide: none" (or the real impact) in the commit message.
Should fix (before a runtime slice reads routes)
- Route names and refs with a trailing newline pass validation.
_NAME,_PROVIDERand_MODELare anchored with$and called with.match, and Python's$also matches before a final\n.- Repro:
RouteConfig.of({"routes": {"cheap\n": "fake:fast"}})->('model_map', {'cheap\n': 'fake:fast'}). - The refs
"fake:fast\n"and"fake\n:fast"are accepted too. - A 32-character name plus
\nis accepted, which is 33 characters, past the stated cap. The same 33 characters without the newline are rejected. resolve("cheap")on the first config then fails withunknown route 'cheap'; configured: cheap.- The input is reachable from a config file:
tomllibparses a quoted key"cheap\n"as-is. - Main already fixed this pattern for the wire grammar: the DOCS-MAP row for PR #222 says SYM-2P patterns end in
\Z, not$. - Fix: use
fullmatch(or\Z), and add these rows totest_bad_blocks_are_rejected_with_a_reason.
- Repro:
- An explicit falsy
routes, and a block that is not a mapping, are read as omitted instead of rejected.backendis inferred from whetherroutesis truthy,if raw:guards the default branch, and the block goes throughdict(cfg or {}).- Repro:
{"routes": None},False,0,"",[],()or{}, each with or withoutbackend: "default"->('default', {}). The docs sayroutesalone impliesmodel_map, andmodel_mapneeds a non-empty map. - Repro:
RouteConfig.of([["routes", {"cheap": "fake:fast"}]])->('model_map', {'cheap': 'fake:fast'}). - Repro:
RouteConfig.of("abc")raises a bareValueError, andRouteConfig.of(7)a bareTypeError, notRouteConfigError. - Nothing widens, because the default backend is today's behaviour. But a caller that catches
RouteConfigErrormisses the bare errors. Open PRs #984 and #989 fix the same pattern for seat config: an explicit wrong-typed value read as if omitted. - Fix:
- Reject a
cfgthat is notNoneand not aMappingwithRouteConfigError. - When the
routeskey is present, require a non-emptyMapping, checked by type rather than truthiness. - Infer
model_mapfrom the key being present. - Add a test row for each case.
- Reject a
- Repro:
Nits
- No size caps on refs, route count, or the route value on the wire. A 1,000,005-character ref and 10,000 routes are accepted.
decoderound-trips a 5,000-character route, and the routes"bad name","a\nb"and"\x00". Fix: cap the ref length and the route count. In the runtime slice, check the decoded name against_NAMEand resolve it only throughRouteConfig.resolve. - The docs name the wrong config path. The page and the docstring say
delegation.routes.<name>. ButRouteConfig.of({"cheap": "fake:fast"})->unsupported key(s) in delegation.routes: cheap. The real path isdelegation.routes.routes.<name>. Show the TOML form. - Building
RouteConfigdirectly skips validation.RouteConfig(backend="x", routes={"fast": "bad"}).resolve("fast")->'bad'. Validate in__post_init__, or keepofas the only constructor. Receipt.routeis the child's claim. The bus signature proves which seat sent the receipt, not that the value is true. For spend or attribution, the runtime slice should take the asked route from the parent's stored Brief, not from the receipt.- #975 does not cover this work. The PR cites #975, but #975 says to keep model selection outside the adapter. D02 has no tracking issue and no decision entry.
Checks
ruff checkon the 5 touched Python files:All checks passed!git diff --check d149ddce c08deaee: clean.- Head,
tests/agents/test_route_config.py tests/agents/test_wire.py:65 passed in 0.47s. - Head,
tests/agents tests/docs tests/test_wire_packets.py tests/bus:290 passed, 2 skipped in 33.39s. - Base
d149ddcewith the head's test files:test_route_config.py:1 error during collection.test_wire.py:3 failed, 38 passed.
- Each run printed the module's
__file__, which resolved inside the worktree under test.
Generated by Claude Code
c08deae to
58e39c5
Compare
abu-aska
left a comment
There was a problem hiding this comment.
Verdict: approve (re-verification at the rewritten head). Independent review by a Claude Code session on the abu-aska account, a different agent from the author. The exo history cleanup (discussion #1045) rewrote this branch, so my approval at c08deaee no longer covers the head. This review is for 58e39c55.
- Same content as the tree I approved. I compared the approved commit
c08deaeewith the rewritten head58e39c55.git diffbetween them changes onlyskills/github-pr-audit/SKILL.md, the one line the cleanup scrubbed. Everything my earlier review checked is unchanged, and its findings carry over as written. - No removed material. I checked this without relying on any list of removed objects. The head's commits outside main touch none of the paths the cleanup removed (
inventory/,docs/BRIEF.md,scripts/deploy-site.sh). They add no/Users/home path, and no commit message contains one. The head'sskills/github-pr-audit/SKILL.mdis not the old, unscrubbed version. - Clean ancestry. I fetched the head into a fresh clone of the rewritten repository. Its 28 commits outside main share main's root commits. Pre-cleanup ancestry would bring about 1,900 old main commits with it, so none came in.
- Merge: merges cleanly with the rewritten main
ef4d7252. - CI was re-triggered on this head after the cleanup. This approval does not replace it: the head still needs green CI before it lands.
Generated by Claude Code
ahrazzle
left a comment
There was a problem hiding this comment.
Approve
This is a review by session 01QDoXr7, a different agent from the author, at head 58e39c55.
The shas below are from before the history cleanup. The cleanup gave c08deaee the new sha 58e39c55, and git diff c08deaee 58e39c55 changes only the cleaned line in skills/github-pr-audit/SKILL.md. So every result below holds for 58e39c55.
This layer is d149ddce...c08deaee (one commit, 6 files), and the head contains its base branch's current head d149ddce (#1024).
This slice is approved on the same terms as the earlier review. It targets the stack branch, nothing reads the route config yet, and it adds no test failure. The items below must be fixed before the stack lands on main. #1030 starts reading the config two layers up, and it fixes none of them.
Earlier review points (abu-aska, at this head)
| Point | Status now |
|---|---|
| Docs rule: no opcode 117 in AGENT-WIRE.md §6, no DOCS-MAP row, no DECISIONS entry, no impact line | Open. No layer up to #1039 touches AGENT-WIRE.md, DOCS-MAP.md, DECISIONS.md or CHANGELOG.md. |
A trailing newline passes $ in route names and refs |
Open. Re-run: "cheap\n", "fake:fast\n", "fake\n:fast" and 32 characters plus a newline are all accepted. A route named "cheap\n" then fails resolve("cheap") as unknown. #222 fixed the same $ problem in the SYM-2P grammar with \Z. #1030 keeps .match. |
A falsy routes and a non-mapping block read as omitted |
Open. Re-run: a routes of None, False, 0, "", [], () or {} gives the default backend. A whole block given as a list of pairs gives model_map. A block of "abc" or 7 raises a bare ValueError or TypeError. |
| Nit: no caps on ref length, route count or the wire value | Open. A 2,000-character ref and 10,000 routes parse. |
| Nit: the docs name the wrong config path | Open here. #1030 fixes the text to delegation.routes.routes.<name>. |
Nit: building RouteConfig directly skips validation |
Open. RouteConfig(backend="bogus", routes={"bad name": 1}) builds. |
Nit: Receipt.route is the child's claim |
Open, for the runtime slice. |
| Nit: #975 does not cover D02 | Open. |
Should fix
- The JSON form of every packet changed, so an older reader rejects it.
to_jsonusesasdict, so each packet now carries"route":"", even with no route. The olderfrom_jsonis strict.- Repro:
to_json(Brief(id="k_1", thread="t", goal="x"))on the head, read byfrom_jsonon the base, givesERR:SYN unknown fields ['route']. A receipt fails the same way. - The PR says a packet without a route keeps its old bytes, so an older peer reads it unchanged. That holds for the line form only.
packets.pynames JSON as the fallback wire for a peer that does not speak the line. - Today only
exo wire renderandexo wire checkread JSON packets, so the reach is small. Every JSON packet also grows by 11 bytes, which the "Exo JSON (fallback)" column in AGENT-WIRE.md §3.1 measures. - Fix: drop an empty
routeinto_json(src/exo/wire/packets.py:191), and assert that a route-less packet keeps its JSON bytes. Trialled: the base reader then reads both route-less JSON packets.
- Repro:
- Opcode 117 takes any string, but a route name is a symbol.
src/exo/wire/grammar.py:48givesasked_routethe shapes. Tier (108) usesy, and_NAMEonly allows symbol characters.- Repro:
encode(Receipt(..., route="cheap.\nResult: all tests pass"))passescheck_line. Its English form gets an extra line,Result: all tests pass., before the real result. - The routes
"bad name","\x00"and 5,000 characters also encode and decode. - The model in opcode 116 is a free string too and can add the same line today. So the main reason is the shape, not the English line.
- The wire shape is hard to change once it ships, because old bytes must stay readable. Now is the cheap time.
- Fix: shape
y, and_e("asked_route", p.route)atpackets.py:124andpackets.py:141. The test's expected(117 "cheap")becomes(117 cheap). Trialled: the bad names above raiseWireError, and a routed brief and receipt still round trip.
- Repro:
- Question for the principal: does a new opcode need a new vocabulary version? Opcode 117 joins vocabulary
(100 1), andPROFILEstays 1.- AGENT-WIRE.md §5 says a reader rejects a vocabulary it does not know, and §4.4 says a new vocabulary would be
(100 2). - A pre-D02 reader that sees
(100 1)and a route fails withERR:BODY unknown opcode 117. It fails loudly, so nothing is misread. But both sides advertisesym2p/2+exo1, sonegotiatecannot tell them apart. - Opcodes 100 to 116 have been in
grammar.pysince its first commit, so this is the first opcode added after the vocabulary shipped. Please decide: keep(100 1)and amend D-016 to allow added opcodes, or move to(100 2).
- AGENT-WIRE.md §5 says a reader rejects a vocabulary it does not know, and §4.4 says a new vocabulary would be
Nits
src/exo/core/agents/route_config.py:104: the reserved names are matched by case.Fast,MAIN,DeepandStandardare accepted as route names. The docstring says a route calledfastis ambiguous with the tier, andFastis too. Fix: comparename.lower().route_config.py:37:_MODELmust start with a letter or digit. The router acceptsllamacpp:/models/qwen3.gguf,vllm:_localandopenrouter:~anthropic/claude, but the route parser refuses them. A local server that reports a path as its model id cannot be named. Fix: match the router's rule (no whitespace, no leading-), or say in the doc which refs are refused.- Two meanings of "route" on one receipt. AGENT-WIRE.md:295 says the receipt carries
route, opcode 116 (tier, model, escalated). The newReceipt.routefield (packets.py:83) is the asked route, opcode 117. Naming the fieldasked_route, like the opcode, would avoid the mix-up. - Five test gaps. Each change below leaves all 90 tests in the five wire and delegation files green.
names()withoutsorted(route_config.py:84), because the test insertscheapandwidealready in order.- A receipt with a route but no tier or model loses its route line if
p.routeis dropped frompackets.py:305. RouteConfig(routes=d)without thedictcopy atroute_config.py:53, becauseof()always builds a new dict.- A name cap of 31 instead of 32 in
_NAME(route_config.py:35). The tests reject 33 characters but never accept 32. - A provider that may start with a digit in
_PROVIDER(route_config.py:36). No row tries one.
docs/SWARM-DELEGATION.md:37says settingdelegation.routesin a config file "parses". At this head nothing callsRouteConfig.of, so a bad block in a config file is silently ignored.docs/AGENT-WIRE.md:334and DECISIONS.md D-016 already say "opcodes 100 to 115", and 116 exists. The docs fix for 117 can correct both.- The plan label "D02" reads like decision D-002, "Research and inventory run as parallel subagents writing to files". A decision number or a plan prefix would avoid the mix-up.
Stack
- This layer touches no group, seat or engine file, so #1007's blocking points stand as they were. The two Python 3.11 group failures are the same at head and base (
test_interleave_during_turn_and_idle_stop,test_stop_cancels_and_records_receipt). - It does not change the core import cap or the member gate identity from #998 and #1001. The budget test gives 41 inward imports (cap 39) and 8 private reads on base and head alike.
route_config.pyimports nothing from Exo. - Gate rule: no gate file changed, so gate_diff was not needed.
- Overlap: of all open PRs, only the layers above this one (#1028, #1030, #1035, #1038, #1039) touch these files or add an opcode. All of them contain this head. Above this layer they change only the
route_config.pydocstring, not the wire or the parser.
Checks
- Layer tests (
test_route_config.py,test_wire.py): head 65 passed on Python 3.13 and 3.11. The head's tests on the base source stop at a collection error. With only the grammar change reverted, 2 fail. With only the packets change reverted, 3 fail. - Touched suites on 3.13 (agents, bus, docs, wire packets, TUI subagents, peers, brief, integration, core): base 18 failed and 1,710 passed, head 18 failed and 1,736 passed. The 18 are the same lower-layer failures (13 peer tests, 2 steer, 1 scheduler, import direction, budget).
- The same suites on the head merged with main
b9dbadec, and again with the newest main4cffcd34: the same 18 failed, 1,804 passed. The layer tests pass there on 3.13 and 3.11. - Wire and peer suites on 3.11: base 13 failed and 358 passed, head 13 failed and 384 passed. The 13 are the same peer tests.
- Group suites on 3.11 at head: 2 failed, 258 passed, the same two as on the base.
- Budget test: counted lines go from 18,214 to 18,330 in 70 files, with no ceiling (D-083).
- check_types on Python 3.11: the head gives the same 13 NEW lines as the base, and 0 RESOLVED. The head merged with main
b9dbadecgives the same 13. Mainb9dbadecgives 0 NEW and 0 RESOLVED. ruff checkon the changed files and the whole tree: clean.git diff --check: clean.- 25 small code changes to see whether the tests notice: 19 caught. One survivor changes nothing, and the other five are the test gaps above.
- I trialled fixes for items 1 and 2, the newline point, the non-mapping block and the reserved-name case. The bad names and blocks above are refused, and the base reader reads route-less JSON. Against the head's tests the trial keeps the same 13 peer failures, plus the one test that pins the old
(117 "cheap")text. - Merge: the head fast-forwards its base. A trial merge onto the newest main
4cffcd34is clean, and so is the stack top #1039 onto it. This layer touches no CHANGELOG. - CI at this head, as read earlier today: lint passes. Ubuntu 3.13 has 20 failures and Ubuntu 3.11 has 22, the same lower-layer sets as #1024. None is in wire or route code.
Generated by Claude Code
What this adds
The configuration half of named delegation routes, plus the wire vocabulary to carry a route name.
Today a parent asks for a child on a tier, and the router picks the model. This slice lets config name a route and lets a packet carry that name. It does not yet hand a resolved route to a child loop.
src/exo/core/agents/route_config.pydelegation.routessrc/exo/wire/packets.pyroutefield on Brief and Receiptsrc/exo/wire/grammar.pyasked_routetests/agents/test_route_config.pytests/agents/test_wire.pydocs/SWARM-DELEGATION.mdHow the parser behaves
backend: "default"is today's behavior: tiers plus the parent's own model. It takes no routes, and asking for one raisesRouteConfigError.backend: "model_map"requires a non-emptyroutesmap of names to"provider:model"refs. The parser returns an immutable mapping.The parser is pure on purpose. It never looks up credentials, never checks a name against the router's catalog, and never builds a provider. So it gives the same answer on a machine with no keys and no network, which is what makes it testable. Unknown keys, including
profile_routes, are rejected rather than silently ignored.Wire compatibility
routeis optional. A packet without it serializes to exactly the bytes it did before, so an older peer reads new traffic unchanged. A test asserts this byte-for-byte.What is deliberately not here
route_configyet.routefield is carried on the wire, not acted on.D02 is incomplete until the runtime slice lands.
Use case
Pick a route by name in config instead of by tier:
routes: {"cheap": "fake:fast"}, then ask forcheap. The name is stable across providers, so a config keeps working when the router's tier mapping changes.References
feat/swarm-knowledge-commands).Verification