Repository navigation
Tree places new Bots up front: reuse before create, project teams as lead plus children, create under own descendants - #454
Merged
Conversation
…parent?, create_team lead plus children, orphan reattach) (ThinkFlowLab#447)
6 tasks
Collaborator
Author
|
Self-review: PASS
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #447
Summary
Forward allocation for the Bot tree, built on #446's self-organization (#448 / #453). New Bots go in a sensible place up front. The auto-prune/merge path stays the safety net.
Reuse before create. New read-only tool
find_bots(query?), visible to every tree Bot. It lists the Bots in the caller's branch (for Chief, the whole tree) withname,role,parent,depth,path,children,leadandvia(the caller's child on the path). With a query, it returns matches only, best first.create_child_botchecks the whole branch first. If a Bot with the same role exists at any depth, it returns{ reused, note }and creates nothing. Tested with the match at depth 3.Lead plus children. New tool
create_team(team, members, parent?). It creates"<team> Lead"with the members under it, soChief → FlyBot Lead → {Dev, Test, Maintenance, Repo}takes one slot under Chief. It usesroles.jskeys and labels,canLead, and organize'screateLead/markLead. If a lead for that group already exists, it is reused. Members that already exist with the same role are reused too. A reused member that sits flat next to the lead moves under it, which frees its slot. There is never a least-loaded fallback. With noparent,create_child_botputs a later Bot of the group under that group's marked lead ("FlyBot Docs" → under FlyBot Lead).create_child_bot(name, role_description, parent?).parentcan be an id or a unique name. It must be the caller or one of its descendants; anything else gets "parent must be you or one of your descendants". Limits, depth and the sibling-name check run at the target, under that parent's existing lock. Tested: refusal of a sibling, an ancestor, an outsider and an unknown parent, plus limits checked at the target.Shared primitives.
organize.jsnow exposesorganizer.shared(profile, subtree, homes,fits,createLead,markLead,move, journal, the reorganization queue). The newsrc/allocate.jsuses only these, so there is no second implementation. A team that moves or marks existing Bots is a journaled run (triggerteam), and the tree view's existing Undo reverses it.Prompts and docs. Coordinator / Chief prompts now state the placement rules:
find_botsfirst and reuse what fitscreate_team)maxChildren - 2children or more, group related children instead of adding another flat oneOrphans (a member whose parent is no longer in the tree) are now reattached on each repair pass: by role to their group's lead, else the root, with their subtree, as a journaled move. One that fits nowhere yet is retried on the next pass.
docs/subsystems/tree.mdhas a new "Placement rules" section linked to Tree: close create_bot maxChildren bypass; auto-prune/merge when over capacity or orphans exist #446. README and changelog fragment updated.Plan card: deferred. The codebase has no chat card for a model-proposed plan with Approve / Edit / Cancel. The only approval cards are social's message holds, and the tree only has the sidebar reorg notice. Building one would mean a new chat slot, host endpoints and resuming the model's turn, which is not small. Forward allocation goes ahead and its result names the tree paths. The deferral is recorded on Tree: smarter sub-Bot allocation (lead+children, reuse, deeper placement) maintained by auto-prune/merge #447. Automatic reorganization never asks first.
Minor decisions (made by me)
sameRole: same name once generic words are dropped and no conflicting description, or near-identical descriptions. A same-name Bot with a different description is created, not reused.find_botsmatching is fuzzier: query in name or role, shared role-word stems ("test" finds "Tester"), project, domain.parent) only goes under a Bot already marked as a group lead (leadfield), only down a path of groups the new Bot belongs to, never under a namesake, and never under a lead of a group the new Bot could lead itself. Unmarked lead-like Bots are left to Tree: close create_bot maxChildren bypass; auto-prune/merge when over capacity or orphans exist #446 grouping. Otherwise the parent is the caller, as before.create_teammembers are"Name: role"strings. The host keeps onlytype/description/enum/items, and DSH refuses object items without declared keys.{ name, role_description }objects are also accepted. A team has 2 tomaxChildrenmembers. Team name is at most 35 characters, so that " Lead" fits the 40-character name limit.parentnames another place, so no second lead is made.create_child_botandcreate_teamkeep thelimit reachedrefusal (the Tree: close create_bot maxChildren bypass; auto-prune/merge when over capacity or orphans exist #446 contract). The message points toparentor the automatic regroup. A team still fits at a full level when it reuses a flat member, because the lead takes that member's slot.parentset to an id that is not a tree member. Bots withparent: nullkeep today's handling.Tests
plugins/tree/test/tree.test.js: 6 new#447tests:find_bots(scope, fields, ranking, branch-only)parentrefusal and limits at the target, including the lock under parallel createsparent, a new Bot goes only down leads of groups it belongs tofix 4adjusted, becauseparentis now a known argument.plugins/tree/test/host.test.js: new real-host test. The schemas compile under DSH, andfind_bots,create_teamandcreate_child_bot(parent)work end to end.ARCH_DOCS_BASE=origin/main TZ=UTC npm run verifypasses.node scripts/lint-plugins.mjs tree|social|timeline,node .github/scripts/check-pack.mjsandnode .github/scripts/changelog.mjs checkalso pass. Plugin tests ran withDSH_HARNESSand none were skipped.Risk tier: T3