Skip to content

lib: one cascade graph for every store - #68

Merged
msimerson merged 3 commits into
NicTool:mainfrom
aberoham:references
Oct 16, 2026
Merged

msimerson merged 3 commits into
NicTool:mainfrom
aberoham:references

Conversation

@aberoham

@aberoham aberoham commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Destroy a group, user or zone on json or toml and its nameservers, sessions or records stay behind. mysql removes them through its FOREIGN KEY constraints.

references.js declares the three edges once. On the file stores, destroy() calls cascade() first. It removes all of the parent's children in one write, matched on the parent key, and mysql keeps its constraints.

references.test.js is the repro. Each case seeds a second parent whose children must survive, so taking too much fails as loudly as taking too little.

Which children a hard delete takes with it was decided separately in
each backend. mysql gets each of them from a FOREIGN KEY. The file
stores have no constraints and never implemented them, so destroying a
group left its nameservers behind, a user its sessions, and a zone its
records.

references.js names those three edges once. The file stores call
cascade() from destroy() before removing the row, mysql goes on getting
it from the constraints, and references.test.js holds whichever store is
configured to the same graph. Each case seeds a second parent whose child
must survive, so a store that takes too much fails as loudly as one that
takes too little.
@aberoham
aberoham marked this pull request as ready for review October 16, 2026 05:50

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

Cascades can delete children concurrently moved to surviving parents and repeatedly rewrite entire child files.

1 open finding
What changed in this PR

Aligns JSON and TOML hard-delete cascades with existing MySQL behavior through a shared relationship graph.

Changes:

  • Cascades group, user, and zone destruction to their children.
  • Adds cross-store tests for deletion, unrelated-child preservation, and retry behavior.
  • Documents the behavior change.
File Description
lib/​zone/​store/​file.js Cascades before removing zones.
lib/​user/​store/​file.js Cascades before removing users.
lib/​references.test.js Tests cascade behavior across stores.
lib/​references.js Declares relationships and implements cascades.
lib/​group/​store/​file.js Cascades before removing groups.
CHANGELOG.md Documents file-store cascade support.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lib/references.js Outdated
@msimerson

Copy link
Copy Markdown
Contributor

also, the previous PR broke test-win for some reason.

@aberoham

Copy link
Copy Markdown
Contributor Author

test-win failed before any test ran. choco got a 503 and then a 504 from community.chocolatey.org for mysql 9.7.2, so mysqld never started. #68 hit the same outage in the same minute. The feed answers again now, and a re-run should pass.

@msimerson
msimerson merged commit 7d4a529 into NicTool:main Oct 16, 2026
10 checks passed
@aberoham
aberoham deleted the references branch October 16, 2026 22:16
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