Skip to content

group: one live group per name under a parent - #100

Merged
msimerson merged 3 commits into
NicTool:mainfrom
aberoham:group-unique-name
Nov 21, 2026
Merged

msimerson merged 3 commits into
NicTool:mainfrom
aberoham:group-unique-name

Conversation

@aberoham

@aberoham aberoham commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Live sibling groups could share a name. Create, rename, move, and restore all allowed it. Each now returns 409 across mysql, json, and toml. Deleted siblings do not hold a name, and restore fails while a live sibling has it. A move of parent_gid alone skips the username check, so groups with duplicate logins in an upgraded db still move.

On mysql, the check runs in the write transaction under api#99's group-name lock. A race test runs four concurrent creates of one name under one parent, and one wins. Moving the check ahead of the lock let two or three win. The json and toml stores now save parent_gid 0 on parentless creates and read missing parent_gid as 0, matching mysql.

A create under a missing parent now answers 400 on every store and writes nothing. Before, mysql committed the group, then failed on its subgroup link and left it with no permission row. On mysql, the group and its ancestor links now commit in one transaction. The ancestor rows are locked before the name lock, the order a rename takes them in. json and toml now ignore trailing spaces when comparing names, as mysql does, and return parent_gid 0 for a group stored without one.

The zone_record route fixture made a second top-level route.example.com group. It now uses its own name and destroys its group and user. Global teardown also drops the old group for reused dev databases. The api#99 username race test put both groups under one parent, where its rename now fails on the sibling check alone. Its second group moved under the first.

v2 refused a second live group of one name under one parent. v3
accepted it on create, rename, move and restore. The check runs under
the group name lock api#99 added, so concurrent writers can't both win
on mysql.

The zone_record route fixture made a second top-level group named
route.example.com. It gets a name of its own and cleans up after
itself. The username race test's groups no longer share a parent, so
its rename fails only on the username.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Legacy JSON/TOML groups are returned without parent_gid rather than normalized to parent_gid: 0, leaving their shape inconsistent with newly created top-level groups and MySQL.

1 open issue
What changed in this PR

This PR restores v2’s live sibling group-name uniqueness rule across MySQL, JSON, and TOML stores, while allowing deleted groups’ names to be reused.

Changes:

  • Reject conflicting creates, renames, moves, and restores, with MySQL checks protected by the group-name lock.
  • Default parentless file-store creates to parent 0 and treat missing parents as 0 when filtering.
  • Add conflict and concurrency tests, preserve parent-only moves with legacy duplicate logins, and isolate route fixtures.
File Description
test/​fixtures.js Clean up stale zone-record test fixtures.
routes/​zone_record.test.js Use a distinct group name and clean up group/user fixtures.
lib/​user/​test/​mysql.js Keep the username race test independent of sibling-name conflicts.
lib/​group/​test/​mysql.js Test concurrent name claims and legacy group moves.
lib/​group/​test/​index.js Test sibling conflicts, parent defaults, and deleted-name reuse.
lib/​group/​store/​mysql.js Enforce sibling-name uniqueness within locked transactions.
lib/​group/​store/​file.js Add sibling checks and top-level parent handling.
lib/​group/​store/​base.js Share sibling-name detection and conflict errors.

Review effort: Balanced

Comment thread lib/group/store/file.js Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The review identifies no active issues with the sibling-group name uniqueness changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@msimerson
msimerson merged commit ef8b79b into NicTool:main Nov 21, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants