Add groupByTeamHierarchy: tree-shaped multi-level team-prefix grouping - #184
Add groupByTeamHierarchy: tree-shaped multi-level team-prefix grouping#184shouze wants to merge 2 commits into
Conversation
|
Coverage after merging feat/team-hierarchy-model into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
Introduces a new pure hierarchical team-prefix grouping algorithm (groupByTeamHierarchy) that produces a tree-shaped TeamSection model, providing the data-model foundation for EPIC #125’s multi-level team-prefix grouping work.
Changes:
- Extended
TeamSectionto support hierarchy (level?,children?) alongside the existing flat grouping shape. - Extracted the existing single-level grouping logic into
bucketSingleLevel()and reused it for both flat (groupByTeamPrefix) and hierarchical grouping. - Added
groupByTeamHierarchy()plus new unit tests covering multi-level chains, per-level"other", multiple chains, and overlap nesting.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/types.ts | Adds hierarchy fields (level, children) to TeamSection and updates its documentation. |
| src/group.ts | Refactors single-level bucketing into a helper and adds the new hierarchical grouping implementation with overlap nesting. |
| src/group.test.ts | Adds new unit tests covering the hierarchical grouping behavior. |
Suppressed comments (1)
src/types.ts:78
- The
childrenfield comment says it is present (non-empty) when subdivided, but the current implementation often setschildren: []on leaf nodes (including "other" and combined-label sections). Either the docs should allow empty arrays or the implementation should omitchildrenwhen there are no children to traverse.
/** Present (non-empty) when this section was subdivided further, either by
* the next prefix in the chain or by an auto-detected overlapping
* team-name relationship. Only set by `groupByTeamHierarchy`. */
children?: TeamSection[];
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Coverage after merging feat/team-hierarchy-model into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/group.ts:187
nestOverlappingLabelscomputes overlap parents with a nested loop over all labels (O(n²) comparisons per level). For orgs with many matching teams at a level, this can become a noticeable bottleneck in interactive mode. Consider switching to a sort+stack (prefix-chain) approach or a trie to find the longest-prefix parent in O(n log n) / O(total label length).
for (const s of nestable) {
let bestParent: string | undefined;
for (const other of nestable) {
if (other.label === s.label) continue;
if (
…ldren Addresses Copilot review on PR #184: - applyChainDepth no longer skips splitting a node's own groups by the next chain-level prefix just because it also has overlap-nested children (both can now coexist and each gets subdivided correctly). - TeamSection docs updated: a node can have non-empty groups AND children at the same time (was previously documented as either/or). - children is now omitted (not an empty array) on sections that were never subdivided, matching the documented invariant.
9e2dd78 to
847ac29
Compare
|
Coverage after merging feat/team-hierarchy-model into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
…ldren Addresses Copilot review on PR #184: - applyChainDepth no longer skips splitting a node's own groups by the next chain-level prefix just because it also has overlap-nested children (both can now coexist and each gets subdivided correctly). - TeamSection docs updated: a node can have non-empty groups AND children at the same time (was previously documented as either/or). - children is now omitted (not an empty array) on sections that were never subdivided, matching the documented invariant.
847ac29 to
47377b1
Compare
|
Coverage after merging feat/team-hierarchy-model into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Summary
Adds a pure, tree-shaped hierarchical grouping algorithm for team-prefix
grouping, laying the data-model foundation for the rest of the "Hierarchical
team-prefix grouping" EPIC (#125).
level?andchildren?toTeamSection(src/types.ts) so asection can either own repos directly (
groups, a leaf) or be subdividedfurther (
children).out of
groupByTeamPrefixinto a sharedbucketSingleLevelhelper, withno behavior change to
groupByTeamPrefix(all 36 pre-existing testspass unchanged).
groupByTeamHierarchy(groups, chains): given one or more prefixchains (e.g.
["gamme-", "squad-"]for a 2-level chain), recursivelysub-groups repos at each depth, with a per-level
"other"bucket forrepos that don't match the next prefix.
gamme-lead-clientbecomes the parent ofgamme-lead-client-p1) insteadof listing them as unrelated siblings, cascading across chains of overlaps.
CLI parsing of the
/-chain syntax, output rendering (markdown/JSON), TUIrendering, and
--pick-teamsupport are intentionally out of scope hereand covered by the following sub-issues (#178-#182).
Closes #177
How to test
bun test src/group.test.ts11 new tests cover: single-level parity with
groupByTeamPrefix, 2-level and3-level chains, per-level
"other"buckets, multiple independent chains, andoverlapping team-name nesting (including a 3-way cascade).
Validation
bun test(882 pass)bun run lintbun run format:checkbun run knipbun run build.ts