Repository navigation
Conversation
abu-aska
left a comment
There was a problem hiding this comment.
Review of PR #1035 (comment, not an approval) — 2026-10-30 15:21 CDT
Verified at head 11baf1f, reading the full diff (6 files) and the new
test file. I did not run the test suite locally (no local checkout).
What checks out against the body:
- Byte-identical default:
PROMPT_PREFIXequals the previous literal
prompt prefix, and both adapters only append a snapshot when a reader
is present, so withknowledge=Falseprompts stay unchanged. - Host validation order:
startrejects a non-boolknowledgeflag
(type(...) is boolrejects 0, 1 and truthy strings) and validates
bounds before the factory is invoked or any claim exists. The test
covers factory never invoked and no claim for the bad flag and bad
bound cases. - Snapshot authorization:
_readerruns before any row is read, so a
wrong owner, a non-member, or a foreign group raises. The test covers
all three plus the foreign-group read. - Oversize handling for one item: an item that does not fit
max_chars
is omitted whole and flaggedtruncated, andrender_prompt_context
raises instead of emitting a half-written envelope. The test covers
the single-item case and the huge-envelope case. - Snapshot failure path: in the conversation adapter a snapshot failure
records an error outcome and raises beforerun_turn, the same
failure shape as a provider failure in_turn.
Points to resolve before merge:
- CI on 11baf1f is red while main e52bc2f is green on its completed
checks:test (ubuntu-latest, py3.11),test (ubuntu-latest, py3.13)andtypesfailed,lintpassed, macOS runs queued. The
body claims 112 focused tests pass locally. Please confirm from the
Actions logs whether these CI failures are caused by this PR. Do not
merge on this review alone while those checks are red. - Snapshot stops at the first oversize item:
snapshot()breaks out of
its loop when an item does not fitmax_chars, so a smaller later
item in key order is never returned even if it would fit. The docs
say oversize items are omitted whole and flagged, and the test covers
only the single-item case. Is the intended rule key-order prefix
only, or should scanning continue past an oversize item to later
items that fit? If prefix-only is intended, one line in
docs/SWARM-KNOWLEDGE.md would settle it. - Host validates bounds even when
knowledge=False:startcalls
GroupKnowledge.boundsunconditionally, soknowledge=Falsewith
max_items=99raisesHostErroreven though no reader is built. Is
that intended, or should bounds be validated only when
knowledge=True? The bad-bounds test only coversknowledge=True
cases. - Minor: the new test file header says "(M02-M04)" while the PR title
and body say M02 only. Confirm the scope label.
abu-aska
left a comment
There was a problem hiding this comment.
Verdict: request changes. Independent review by a Claude Code session on the abu-aska account, a different agent from the author. Reviewed at 11baf1f6; tests and probes run, every finding re-checked.
Scope: commit 11baf1f only (git diff b9cf95e8..11baf1f6, 6 files). The PR targets the stack branch feat/swarm-delegation-route-execution, not main.
What works
- The new tests test the change.
tests/test_group_knowledge_context.pycopied onto base b9cf95e fails at collection (ImportErroron the new constants). With the constants shimmed, 6 of 8 tests fail on behaviour (start() got an unexpected keyword argument 'knowledge','GroupKnowledge' object has no attribute 'snapshot'). The 2 byte-identical guards pass on the base, as regression guards should. - The default prompt is byte-identical.
PROMPT_PREFIXequals the old literal, and withknowledge=Falseneither adapter builds a reader. - Authorization holds. The snapshot runs
_readerfirst and reads onlyswarm_knowledgerows for thatgroup_id. Wrong owner, non-member and foreign-group reads all raise, and a second group'sFOREIGN-SECRETnever appeared in group 1's snapshot. - Framing holds. Knowledge text containing
"}]}, newlines, a copy ofKNOWLEDGE_PREFIXand a fake envelope still gave exactly one prefix and no raw newline in the block, and it round-tripped intact. - A snapshot failure leaves input pending. On the conversation path the failed member had
pending ['hello'], 0 engine turns, and the receipt settled. - D-083 is unchanged by this commit.
test_core_line_budgetfails identically on base and head, so it is inherited from the stack.
Blocking
max_charsat the documented minimum (256) cannot hold the empty envelope for most member names, so those members fail on every turn. The empty snapshot JSON is 244 characters plus the member name (group ids are a fixed 18 characters).snapshot()never checks the envelope when no item fits or none exist, sorender_prompt_contextraises inside the turn.start()accepts the bound because it checks only the numeric range, which contradicts its "validated before any factory, claim or turn" contract.- Repro, no knowledge published,
knowledge=True, sendhelloto the member:- Conversation path (
ConversationOptions(max_turns=1)),max_chars=256, memberanalyst1(envelope 257): memberfailed, 0 engine turns,hellostill pending. The same run withmax_chars=300completes with 1 turn. - Conversation path,
max_chars=260, memberresearcher-long-name(envelope 269): memberfailed, 0 engine turns. - One-shot path, the same two cases:
analyst1andresearcher-long-namebothfailed, 0 engine turns.leadcompletes in both.
- Conversation path (
test_conversation_knowledge_tightest_bound_fails_closedpasses only because its member istwo(envelope 252, 4 characters of headroom). Profile names (ID_RE) have no length cap.- Fix: in
start, render an empty snapshot for every member and raiseHostErrorif it does not fit. RaiseMIN_SNAPSHOT_CHARSso it really leaves room for the envelope plus one short item, as its comment says. Test the minimum bound with a member name longer than 7 characters on both paths.
- Repro, no knowledge published,
- This commit adds two new mypy
[index]errors, so thetypesratchet fails on this commit's own lines.self.boundsandself.kboundsare typedtuple[int, int] | Noneand are indexed without narrowing.- Repro: mypy 2.4.0 with
--python-version 3.11 --platform linuxon the four touched modules. The base has the two existinggroup_host.pyerrors. The head addsgroup_engine_adapter.py:86: Value of type "tuple[int, int] | None" is not indexable [index]and the same error atgroup_conversation.py:243. Neither file has an entry in.github/mypy-baseline.json, so both count as NEW. The CItypescheck on 11baf1f is red. The stack's other NEW entries are inherited, but these two are not. - Fix: store non-optional bounds (
startalready validates them, soself.bounds = GroupKnowledge.bounds(max_items, max_chars)can run unconditionally), or narrow into a local before indexing.
- Repro: mypy 2.4.0 with
Should fix
- One long knowledge item hides every later key, and the
…[truncated]text cut cannot be reached throughGroupHost. The host never passesmax_text_chars, so it stays atMAX_TEXT_LEN(100,000), whilemax_charsis capped at 16,000. An item too large for the budget is never cut. It is dropped whole, and thebreakthen drops every later key too, for every member on every turn.- Repro (one-shot host, default bounds): publish
a-big(20,000 chars),b-smallandc-small. The member prompt hasreturned 0, truncated True, keys []and no marker. A single 15,900-character item givesreturned 0and no marker. Withmax_chars=4000, a 5,000-charactera-bigahead of two 1-character items givesreturned 0, keys []. - The run is flagged
truncated: trueand fails closed, so this is not blocking. Still, the PR body's "text cut with an explicit…[truncated]marker" does not hold for the real caller, and the docs' "a single item ... is omitted whole" does not say that later items go with it. - Fix: cut an oversize item's text to the remaining budget with the marker, or
continuepast it instead ofbreak. State the rule indocs/SWARM-KNOWLEDGE.mdand add a test with an oversize item ahead of small ones.
- Repro (one-shot host, default bounds): publish
- The docs rule is not met for the new
GroupHost.startoptions.knowledge,max_itemsandmax_charsare documented only indocs/SWARM-KNOWLEDGE.md. The commit has noDECISIONS.mdordocs/DOCS-MAP.mdrow, no CHANGELOG line, and no user/developer-guide impact line in the commit message ("none" is required when nothing changed;docs/DEVELOPER-GUIDE.md, "The docs rule"). No SWARM-* doc and no earlier stack commit has these either, so the gap is mostly inherited, andtests/docspasses on both trees. This must be fixed before the stack lands on main.
Nits
- Knowledge JSON uses
ensure_ascii=False, so U+2028 and U+202E reach the prompt raw, while participant messages are ASCII-escaped. Escape control, separator and bidi characters, or match the messages.max_charscounts code points, not bytes; the docs say characters. start(knowledge=False, max_items=99)raisesHostErroralthough no reader is built. Document that or validate only whenknowledge=True.- The test file header says "(M02-M04)"; the PR says M02.
Checks
ruff checkon the 5 touched Python files:All checks passed!- Knowledge context, knowledge, knowledge commands, host, host conversation, conversation, engine adapter, runtime and
tests/docson head:138 passed in 32.41s - New test file on base b9cf95e:
1 error in 0.14s(collectionImportError) tests/integration/test_wave1_acceptance.pyon head:1 failed, 19 passed(test_core_line_budget, inherited)- mypy 2.4.0 (py3.11) on the touched modules: head adds 2
[index]errors atgroup_engine_adapter.py:86andgroup_conversation.py:243 - CI on 11baf1f:
typesfailure (partly this commit),lintsuccess, ubuntu/macOS py3.11 test jobs failure (collection error inherited from #1030), macOS py3.13 queued
Generated by Claude Code
ahrazzle
left a comment
There was a problem hiding this comment.
Request changes
This is a review by session 01QDoXr7, a different agent from the author, at head 11baf1f6. It covers this layer only: the diff from the base branch head b9cf95e8 (#1030) to 11baf1f6. The head contains b9cf95e8, with one commit on top that touches 6 files.
The gap is real at the base. There, GroupHost.start has no knowledge option and GroupKnowledge has no snapshot. In my probe with real engines on the fake model, a published item never reached any member prompt, and start(knowledge=True) raised TypeError.
Earlier review points
Point (abu-aska, at 11baf1f6) |
Status now |
|---|---|
| CI is red on this head | Partly this layer. The types job lists 2 NEW errors from this commit (item 2). The 4 test jobs stop at collection on #1030's test import. |
max_chars=256 cannot hold the empty envelope for longer member names |
Open. Reproduced on both start paths (item 1) |
Two new mypy [index] errors |
Open. Reproduced with scripts/check_types.py (item 2) |
One long item hides every later key, and the text cut cannot be reached through GroupHost |
Open. Reproduced (item 4) |
| Docs rule | Open (item 7) |
ensure_ascii=False lets raw control and bidi characters through |
Open. It also causes item 3 |
knowledge=False still validates the bounds |
Open. Reproduced (item 8) |
| The test file header says M02-M04 | Open |
The stack questions
- Core import cap: this layer adds no inward import and no private read. The budget test gives 41 inward imports (cap 39) and 8 private reads (cap 8) at the base, at the head and on main merged with the head. The 41 still comes from
group_composition.py(#998). - Member gates bound to the host's identity (#1001): unchanged. This layer does not touch
group_composition.pyor the engine. Knowledge only goes into the text of the turn the member's own engine runs. - #1007's blocking points: unchanged.
group_conversation.py:281still sends a reply with nowake.set(), and:112still waits withasyncio.wait_for. On Python 3.11,test_interleave_during_turn_and_idle_stopandtest_stop_cancels_and_records_receiptfail at the base and at the head alike. - A snapshot failure is one more way for a member to fail. In a conversation run the other members then wait for input until the host stops them, as with any member failure.
Must fix
-
src/exo/core/group_knowledge.py:40andsrc/exo/core/group_host.py:206:startacceptsmax_chars=256, but the empty snapshot alone is longer than that for any member name over 7 characters. That member then fails on every turn.- Repro: members
leadandanalyst1, no knowledge published,start(..., knowledge=True, max_chars=256), sendhellotoanalyst1. On both start pathsanalyst1endsfailedwith 0 model calls. Its empty envelope is 257 characters. The test membertwopasses only because its envelope is 252. - Fix: check the empty envelope for every member in
startand raiseHostError, or raise the minimum. Test it with a long member name on both paths.
- Repro: members
-
src/exo/core/group_engine_adapter.py:86andsrc/exo/core/group_conversation.py:243: this commit adds 2 NEW type errors, so thetypescheck fails on this layer's own lines.- Repro:
scripts/check_types.pyon Python 3.11. The base lists 13 NEW lines from lower layers. The head lists the same 13 plusValue of type "tuple[int, int] | None" is not indexable [index]in both files. - Fix: store the bounds as a plain tuple (
starthas already checked them), or narrow into a local before indexing.
- Repro:
Should fix
-
src/exo/core/group_knowledge.py:280: one source with a lone surrogate makes every member turn fail once knowledge is on. Publish accepts such a source (a #1024 nit), and the snapshot now renders it raw.- Repro: publish
sources=["doc:\ud800"], thenstart(..., knowledge=True)with real engines. Both members endfailedwith 0 model calls.run_turnraisesUnicodeEncodeError: surrogates not allowedwhen the engine stores the message. Withknowledge=Falsethe same group completes. - Fix: render with
ensure_ascii=True, as the participant messages are, or reject such sources at publish. This also settles abu-aska's nit on control and bidi characters.
- Repro: publish
-
src/exo/core/group_knowledge.py:405: thebreakdrops every key after the first item that does not fit. The…[truncated]cut never runs throughGroupHost, becausemax_text_charsstays at 100,000 and stored text cannot be longer.- Repro: one-shot run with default bounds, items
a-big(20,000 characters),b-smallandc-small. The prompt showsreturned 0,truncated true, no keys and no marker. - Fix: cut an oversize item to the space left, or
continuepast it. State the rule indocs/SWARM-KNOWLEDGE.mdand test an oversize item ahead of small ones.
- Repro: one-shot run with default bounds, items
-
src/exo/core/group_conversation.py:239-245anddocs/SWARM-KNOWLEDGE.md:54: the cap holds per turn, but every turn stores a new full copy in the member's session. Each later model call sends all the copies again.- Repro: real engines, members
aandbthat answer each other,max_turns=4, one 5,000-character item. The 7th model call carried 4 copies of the snapshot, 22,966 characters of user text. With the defaults (8 turns, 16,000 characters) the last call can carry 128,000 characters of repeated knowledge. - Fix: send the snapshot once per run, or only when it changed. Otherwise state the real bound (turns x
max_charsper member) in the docs.
- Repro: real engines, members
-
tests/test_group_knowledge_context.py: no test makes a snapshot fail, and several rules have no test. Each of these changes leaves the 112 tests of the 7 group files green.- A snapshot failure that falls back to the plain prompt, in either adapter. So "fails closed" has no test.
- The one-shot path ignoring the caller's
max_itemsandmax_chars. truncatednever set when more thanmax_itemskeys exist.- The
continueandensure_ascii=Truefixes from items 3 and 4. - Fix: add a test where the snapshot raises on each path, one with
max_items=1and 2 keys on the one-shot path, and one per rule in items 3 and 4.
-
The docs rule is not met, and this is a design question for the principal. The commit changes only
docs/SWARM-KNOWLEDGE.md. There is no DECISIONS entry, no DOCS-MAP row, no CHANGELOG line, and the commit message has no body, so no guide impact line.docs/SWARM-COMMANDS.md:92-95still says members learn of knowledge only through their own explicit reads.
Nits
src/exo/core/group_host.py:206:start(..., knowledge=False, max_items=99)raisesHostErroralthough no reader is built. Check the bounds only whenknowledge=True, or say so in the docs.src/exo/core/group_engine_adapter.py:34repeats20and16_000instead of the module constants, and:47testsif knowledgewhere the conversation adapter testsis not None.tests/test_group_knowledge_context.py:1says M02-M04. The PR body says "112 focused tests" while the new file has 8, and "Static independent review PASS" names no review.
Checks
- New test file: 8 passed on Python 3.13 and 3.11, and 20 of 20 repeat runs passed on each.
- Head tests against the base code: collection error, since the new names do not exist. With only the new constants added to the base: 6 failed, 106 passed. The 2 byte-identical guards pass there, as they should.
- 10 mutants: 3 fail a test (no member check, knowledge before the messages, no group filter). 7 pass all 112 (item 6).
- Group, profile, router,
tests/core,tests/integrationandtests/docson Python 3.13: base 5 failed, 1755 passed. Head 5 failed, 1763 passed. The same 5 fail on both (steer x2, scheduler, import direction, budget). - The same set on Python 3.11: base 7 failed, 1753 passed. Head 7 failed, 1761 passed. The 2 extra are #1007's tests.
ruff checkon the whole tree at the base, the head and main merged with the head: clean.git diff --check: clean.- Core budget and import direction: main passes. Base, head and main merged with the head fail the same way (41/39 imports, 8/8 private reads).
scripts/check_types.py, Python 3.11: main matches its baseline (222). Base shows 13 NEW lines, head shows those plus the 2 in item 2. RESOLVED is empty on all trees.- Probes with real engines on the fake model: the base gap, the 256 bound with 3 member names on both paths, a lone surrogate source, an oversize item ahead of small ones, the history copies, and bounds with
knowledge=False. - gate_diff: not run, the gate is not touched.
- Merge: the head lands on its base as a fast forward.
git merge-tree --write-tree origin/main 11baf1f6is clean. #1038 builds on this layer and touches the same 3 core files, but not the knowledge lines.
Generated by Claude Code
11baf1f to
932d5b0
Compare
M02: bounded group-knowledge context for member prompts
Implements the M02 consumption slice from docs/SWARM-KNOWLEDGE.md: an independent, explicit
knowledge=Trueopt-in onGroupHost.startthat gives each member turn one bounded snapshot of the group's owner-published knowledge as labelled, quoted, untrusted reference data.API behavior
knowledge=False, every prompt stays byte-identical to the knowledge-free prompt.max_items1–20 andmax_chars256–16,000.knowledgemust be an explicit bool.…[truncated]marker. Nothing is silently dropped, and the envelope is never sliced into invalid JSON.Verification
Refs #975