Repository navigation
Conversation
Explicit GroupKnowledge store: owner-only publishes with revision compare-and-swap inside one transaction, immutable per-key revision history, and fail-closed reads limited to the group's own members. Nothing reads sessions, memories or messages, so no private content is ingested automatically.
…oups Expose GroupKnowledge via the "group" command name: knowledge_publish / knowledge_read / knowledge_list / knowledge_history. Publishing is owner-only (eng.agent) with explicit expected_revision compare-and-swap; reads are member-scoped and fail-closed. Imported verbatim from PR #974 (commit provenance retained).
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 d149ddce; tests and probes run, every finding re-checked.
Scope: this PR's own 2 commits, 9b37f0e6..d149ddce (base feat/swarm-profile-update, #1022). The store slice src/exo/core/group_knowledge.py, its tests and docs/SWARM-KNOWLEDGE.md came over from #974. Findings from the #974 review that still apply are marked as carried.
What works
- Authority holds on the real path. All four ops were run through the Dispatcher:
principal:tuiandprincipalsucceed.local,unknown,seat:helper,channel,principalxand""all getforbiddenand write noswarm_knowledgerow.
- The publisher is always
eng.agent. Extra fieldspublisher,owner,by,seat,authorandcallereach givebad_request "unknown field(s): <name>"and write nothing. - Member scoping fails closed.
- A non-member and a member of another group get
unknown member. - Another seat's group and an unknown id get
no group. - Through a second group of the same seat, the item is
nullandknowledge_listandknowledge_historyboth return[](re-probed at head).
- A non-member and a member of another group get
- CAS holds.
- Stale or missing
expected_revisiongives a revision-conflictbad_requestand writes nothing. - Non-integer and negative values give
expected_revision must be a nonnegative integer. - 16 racing publishers: 1 ok and 15 conflicts, with gapless history.
- Stale or missing
- The new tests fail on the base and pass on the head.
- On base
9b37f0e6both new files fail at collection (ModuleNotFoundError: exo.core.group_knowledge). - On the head they give
44 passed. - With the four knowledge ops removed from
_OPSon the head, the roundtrip, cross-group and stale-CAS tests fail (3 failed, 41 passed). The suite does test the change, but see the first item under "Should fix".
- On base
- D-083 adds nothing. The scorecard hit lists on base and head are identical (41 inward imports, 8 private reads).
This slice is approved because it targets the stack branch, not main, and leaves the required types job as red as it found it. The two items in the next section must be fixed before the stack lands on main.
Should fix (before the stack lands on main)
-
_knowledge()stores the cache aseng._group_knowledge, which adds a mypyattr-defineddiagnostic to thetypesbaseline check.- Repro: mypy 2.4.0
--python-version 3.11 --platform linuxoversrc/exo clients/tui/exo_tui, compared with.github/mypy-baseline.jsonthroughcheck_types.parse_output/differences. - Base gives 239 errors and 17 NEW; head gives 240 and 18 NEW.
- The only addition is
NEW 1x src/exo/core/group_commands.py: "CoreRuntime" has no attribute "_group_knowledge" [attr-defined]. - Not blocking for this slice: the required job is already red on the base with the same pattern (
_group_store,_group_messages, inherited from #978) plus the composition, host, runner and launch errors. This PR does not change the job's state, and there is no runtime effect. - Since the baseline never grows, the stack cannot land on main until all three are fixed.
Fix:
return GroupKnowledge(_groups(eng))(the tables useCREATE TABLE IF NOT EXISTS), or one public lazy property on the engine that also fixes the two inherited errors. Trialled: mypy goes to 239 with no_group_knowledgeline, andtest_group_knowledge*.pyplustest_group_commands.pygive67 passed. - Repro: mypy 2.4.0
-
The docs rule is not met.
- DOCS-MAP.md "The rule" requires a map row, a DECISIONS.md entry and a user-guide/developer-guide impact note in the same commit. DEVELOPER-GUIDE step 3 puts the impact line in the commit message.
- DOCS-MAP.md and DECISIONS.md have no Swarm rows at all;
grep -rln SWARM-KNOWLEDGE docshits onlySWARM-COMMANDS.md. - Neither commit message has the impact line, and there is no CHANGELOG line.
- COMMANDS.md has no
grouprow (inherited from #978). tests/docspasses (22 passed), so this is a written-rule gap. Under the stacked-PR policy it is should-fix, not blocking.
Fix: add a DOCS-MAP row for SWARM-KNOWLEDGE.md and §Shared knowledge, a DECISIONS entry or an amendment, a CHANGELOG line and a
grouprow listing the knowledge ops, and end the commit message with the impact line.
Should fix
-
Several regressions would not be caught by the tests. Each of these mutants leaves all 44 new tests green (re-run at head):
- dropping the
group_idfilter fromGroupKnowledge.keys(), so a list would show another group's key names; - dropping it from
history(), so a history would show another group's revision text; - raising
MAX_TEXT_LENtenfold (carried from #974); keys[:limit]->keysinknowledge_list.
The current code is correct: the second-group probe above returns
[]. The fixture's only other group belongs to another seat, so it fails withno groupbefore any query runs. Fix:- publish to group A, then assert
knowledge_listandknowledge_historyfor a member of a second group of the same seat return[]; - add a 100,000 / 100,001-character text pair;
- publish 3 keys and assert that
limit=2returns 2 keys withtotal3.
- dropping the
-
32 malformed-input cases pass without the feature.
test_malformed_publish,test_malformed_readandtest_malformed_list_and_historyassert onlycode == "bad_request", and an unknown op returns the same code. With the knowledge ops removed from_OPS, all 32 still pass. Fix: addmatch=on each specific message (unknown field(s): publisher,sources must be,expected_revision must be,limit must be, and so on). -
knowledge_historyloads every revision body before slicing. It runs synchronously on the event loop under the store lock. Measured throughgroup_commands.command:- 1,000 revisions of 100,000 characters,
limit=1: 96 ms, tracemalloc peak 100.7 MB; - 3,000 revisions of 100 characters: 73 ms, 2.3 MB.
Cost grows linearly, and history is never pruned. Only the principal can trigger this, and the data is the owner's own, so it is a resource issue, not a security one. Fix:
ORDER BY revision DESC LIMIT ?, then reverse, plus aSELECT COUNT(*)fortotal. - 1,000 revisions of 100,000 characters,
Nits
- A lone surrogate is accepted in
sources(carried from #974)."sources": ["doc:\ud800"]-> ok, stored and read back, while the same character intext->bad_request. Nothing crashes today. Fix: reject any source for whichs.encode("utf-8")raises in_validate_sources.
Stack (inherited)
- D-083 budget: 41/39 inward imports and 8/8 private reads.
test_core_line_budgetfails on base and head alike. - mypy: 17 NEW diagnostics already on the base (
_group_store,_group_messages,group_composition,group_host,group_runner,group_launch). - The usage text suggests
'<json>', but a quoted argument gets the usage error. The op split also accepts only a single space.
Checks
ruff checkon the 4 changed Python files:All checks passed!- New tests: base
9b37f0e6gives 2 collection errors (ModuleNotFoundError); head gives44 passed; head with the knowledge ops removed gives3 failed, 41 passed. tests/test_group_*.py tests/test_saved_groups.py tests/docs tests/core/test_rename.py tests/test_store.py tests/test_session_owner_boundary.py: base269 passed, head313 passed.- mypy 2.4.0 (py3.11, linux) against the baseline: base
239errors with 17 NEW, head240with 18 NEW. The one added line isgroup_commands.py _group_knowledge [attr-defined]. With the per-call fix it is239. - Mutants:
keys_no_group,history_no_group,text_cap_x10andlist_no_sliceeach give44 passed;history_no_slicegives1 failed. - Module path printed from the tree under test:
.../wt/src/exo/core/group_knowledge.py.
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 d149ddce. It covers this layer only: the diff from the base branch head 9b37f0e6 (#1022) to d149ddce. The head contains 9b37f0e6, with two commits on top. They add src/exo/core/group_knowledge.py, four knowledge_* subcommands in src/exo/core/group_commands.py, two docs and two test files.
The gap is real at the base. There, /group knowledge_publish and /group knowledge_list both get the usage error, and exo.core.group_knowledge does not exist. The new test files fail to collect on the base source.
At this head the commands work through the real Dispatcher. As principal and principal:tui all four subcommands work. As local, channel, seat:helper, unknown, principalx or an empty caller all four get forbidden, and the knowledge tables are not even created.
The publisher is always this seat. A second group of the same seat with the same members sees nothing of the first group's knowledge. Another seat's group, or an unknown id, gets no group.
A publish with no expected_revision on an existing key gets a conflict, so it never overwrites by accident. 16 threads on two connections raced for revision 1 of one key: 1 won, 15 got a conflict, and history kept one row. Python 3.11 and 3.13 agree on every probe, and so does the head merged with the newest main.
Earlier review points
| Point | Status now |
|---|---|
abu-aska (approve at d149ddce): _knowledge() caches on eng._group_knowledge, one new mypy line |
Open. Confirmed (item 2) |
| abu-aska: docs rule not met | Open. Asked as a question for the principal (item 1) |
abu-aska: group filter mutants in keys() and history(), text cap and list slice survive |
Open. Confirmed (item 4) |
| abu-aska: 32 malformed input cases pass without the feature | Open. Confirmed (item 4) |
abu-aska: knowledge_history loads every revision before slicing |
Open. Confirmed (item 5) |
abu-aska: a lone surrogate is accepted in sources |
Open. Confirmed (item 7) |
| abu-aska: budget 41/39 and the mypy errors of lower layers | Lower layers. Unchanged here |
abu-aska: the usage text shows '<json>', but a quoted argument gets the usage error |
Inherited. This layer adds four names to the same usage line and keeps the quotes |
| abu-aska on #974 (same store files): the cross-owner publish test passes on the revision conflict, not the owner check | The command test now catches a missing owner check. The store test alone still passes without it |
| abu-aska on #974: the source count cap is untested | Open (item 4) |
| abu-aska on #974: the owner has no read path of its own | Open (item 6) |
| abu-aska on #974: the doc should say knowledge reaches a member only as quoted data | Open here, where nothing puts knowledge in a prompt yet. #1035 adds that rule with the first prompt path |
The head has not moved since that review. There are no review threads and no PR comments.
The stack questions
This layer changes no group conversation, host, runner, composition, profile or gate file. So it changes none of the stack's blocking points.
- #1007, member replies never wake the addressee: unchanged.
- #1007, two tests fail on Python 3.11, and a stop is lost on 3.11: unchanged. The group suites on 3.11 give the same 2 failures in
test_group_conversation.pyat the base and at the head. On 3.13 they all pass. - #998, the core import cap broken by
group_composition.py: unchanged. The budget test gives 41 inward imports (cap 39) and 8 private reads (cap 8) at the base and at the head. The import direction test fails with the same text on both. The new core module adds 384 counted lines, which D-083 allows. - #1001, member gates bound to the host's identity: unchanged.
Must fix
None in this layer.
Should fix
-
A question for the principal, on the docs rule. This layer adds four user-facing subcommands of
/groupand a new store with two tables in the sessions database. It keeps every revision forever, and nothing can remove a key or a revision, even one published by mistake.It has no CHANGELOG line, no DECISIONS entry, no DOCS-MAP row, no
grouprow indocs/COMMANDS.mdand no guide impact line in either commit message. No commit from main to this head touches those files, and none of the six layers above it does either. The docs name plan steps "M02" to "M04" that no file defines. Which layer adds the Swarm decision, and is a store with no removal path the intended design? -
One new type error.
src/exo/core/group_commands.py:56setseng._group_knowledge, andscripts/check_types.pyreports it as a newattr-definedline. On Python 3.11 the head has 13 NEW lines (18 errors) and the base 12 lines (17 errors). This is the only added one, none are RESOLVED, and the CI types job shows the same line.Fix: build
GroupKnowledge(_groups(eng))per call, since its tables useCREATE TABLE IF NOT EXISTS, or give the engine one typed attribute. I tried the per-call form: the 67 tests of item 4 pass, and the check is back to the base's 12 lines. -
Two open PRs carry the same change. #974 is still open, and its
group_knowledge.py,tests/test_group_knowledge.pyanddocs/SWARM-KNOWLEDGE.mdare byte-identical to this layer's. Discussion #746 asks for one canonical PR per change. Fix: close #974 as superseded by this layer, or drop the store commit here and stack on #974. -
The tests do not pin several guarantees. I ran 34 mutants of this layer's code against the 67 tests in the two new files and
tests/test_group_commands.py. 20 were caught. These survivors are real gaps:- A publish with no
expected_revisionthat falls back to the current revision, so it overwrites blindly, passes (src/exo/core/group_commands.py:351). No test publishes twice to one key withoutexpected_revision. knowledge_historythat checks the seat instead of the named member passes. The fixture's seatoneis also a member, and no history test names a non-member.- Dropping the group filter from
keys()orhistory()passes. - Raising the text cap tenfold, or the source count cap to 100, passes. The 51 sources case (
tests/test_group_knowledge_commands.py:175) is 51 copies of"s". With the cap raised, the duplicate check still rejects it, and the test checks only the error code. knowledge_listwithout its[:limit]slice passes. So does atotalcounted after the slice, inknowledge_listorknowledge_history.- Dropping the command's own list check on
sourcespasses. A JSON object then gets through, and its keys become the sources. - Running the publish outside the store's transaction passes. No test races two publishes.
- The 32 malformed cases check only the
bad_requestcode, and an unknown op gets that code too. Withgroup_commands.pyreverted to the base, they all still pass, and so do the denial test and the protocol test: 34 of the 38 command tests.
Fix: add a test for each, and a
match=on each malformed case's message. Two survivors are harmless: the member padding check (the store then saysunknown member) and the store's own negative revision check (the command rejects it first). - A publish with no
Nits
-
knowledge_historyreads every revision before it keeps the newestlimit(src/exo/core/group_commands.py:427). With 300 revisions of 100,000 characters andlimit1, one call took about 15 ms and peaked at 30 MB of memory. The cost grows with every revision, and history is never pruned. The PR body names this caveat. Fix:ORDER BY revision DESC LIMIT ?and aCOUNT(*)fortotal. -
Docs:
docs/SWARM-COMMANDS.md:92-95says members learn of knowledge "only through their own explicit reads outside this slice". No member read exists at this head. #1035 adds a prompt snapshot later but does not edit this sentence. The PR body also says verified members "can read it".- The owner can read its own knowledge only by naming a member.
knowledge_readwith the seat's own name givesunknown memberunless the seat is also a member. Say so, or let the owner read without a member.
-
A lone surrogate is stored in
sourcesand read back ("sources": ["doc:\ud800"]). The same character intextgivesbad_requestwith the raw codec message "'utf-8' codec can't encode character". Responses use ASCII JSON, so nothing crashes today. Fix: reject it in_validate_sourcesand give both one plain message.
Checks
- New tests: 44 passed on Python 3.13, 44 on 3.11, and 44 twice in random order. On the base source both files fail to collect (
ModuleNotFoundError). Withgroup_commands.pyreverted to the base and the store kept: 4 failed, 40 passed. - Group suites with the new tests: on 3.11 the head gives 2 failed and 258 passed, the base 2 failed and 214 passed. The same 2 fail on both (#1007). On 3.13 the head gives 260 passed.
- Group, profile, seat, core, integration and docs suites with the new tests: head 5 failed, 1753 passed, 2 skipped. Base 5 failed, 1709 passed, 2 skipped. The same 5 fail on both (steer x2, scheduler, import direction, budget). The 44 extra passes are the new tests.
- Core budget: 41/39 inward imports and 8/8 private reads at the base and at the head. Counted lines go from 17,830 to 18,214.
ruff checkon the changed files and on the whole tree: clean.ruff format --checkflags onlygroup_commands.py, as it does at the base.scripts/check_types.pyon Python 3.11: 13 NEW lines (18 errors) at the head, 12 lines (17 errors) at the base. The one added line is item 2. None RESOLVED.- Mutants: 34 of this layer's code, 20 caught (item 4).
- Probes through the real
Dispatcheron 3.11 and 3.13, with identical results: callers, cross group reads, the owner read path, the publish race, caps, surrogates and history cost. - The head merged with main
b9dbadec(clean): 44 new tests pass on 3.13 and on 3.11. The group, store, session and docs suites give 316 passed, and the probes give the same results. - CI at this head: lint passes. The types job shows the one new line. The four test jobs fail only on lower-layer tests: 20 on Ubuntu 3.13 and macOS 3.13, 22 on Ubuntu 3.11 and macOS 3.11. None is a knowledge test.
gate_diff: not needed, no gate file changed.- Merge: the head is a fast forward of its base.
git merge-treeonto mainb9dbadecis clean for this head and for the top of the stack (#1039). The upper layers #1025, #1028, #1030, #1035, #1038 and #1039 contain this head. From #1035 up they changegroup_knowledge.pyandSWARM-KNOWLEDGE.mdto add the prompt snapshot. - Overlap: outside the stack only #974 touches these files. The other 17 open PRs touch none of them. The stack does not touch
CHANGELOG.md.
Generated by Claude Code
d149ddc to
7a00b7c
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 d149ddce no longer covers the head. This review is for 7a00b7c8.
- Same content as the tree I approved. I compared the approved commit
d149ddcewith the rewritten head7a00b7c8.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 27 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
Purpose
Adds the human control surface for the owner-published shared knowledge store (
GroupKnowledge, seedocs/SWARM-KNOWLEDGE.md) on the existinggroupcommand name, so a group owner can publish knowledge and its verified members can read it — with no autonomous retrieval.Functions
Four principal-only subcommands, each behind
principal.require_principal:/group knowledge_publish {"id": …, "key": …, "text": …, "sources": […], "expected_revision": N}— owner-only publish with explicit revision compare-and-swap; the publisher is always this seat (eng.agent), never caller-supplied./group knowledge_read {"id": …, "member": …, "key": …}— member-scoped read, validated against the group's verified members./group knowledge_list {"id": …, "member": …, "limit": N}— keys visible to that member./group knowledge_history {"id": …, "member": …, "key": …, "limit": N}— revision history for a key visible to that member.Use case
Principal-only ops (publish/read/list/history); explicit revision CAS; owner is always
eng.agent;human_owner_view; verified members only; no autonomous retrieval remains — gap M02–M04 implementation is partial. Caveat:list/historycurrently materialize all rows before slicing.Provenance and refs