fix(graph): report a self-dependency as the cycle it is (GitHub #43)
CI / dco (pull_request) Successful in 5s
CI / runtimes (bun) (pull_request) Successful in 20s
CI / build (pull_request) Successful in 29s
CI / runtimes (edge) (pull_request) Successful in 18s
CI / runtimes (deno) (pull_request) Successful in 32s

A node that needs the token it provides is a cycle of one, so say so in
the same words as every other cycle (`cycle detected: a -> a`), and name
the token and the fix:

  cycle detected: auth -> auth (it needs 'user', which only it provides).
  Remove 'user' from its needs, or move the work that produces 'user'
  into a step it needs.

"missing dependency … it provides it itself" pointed the reader at a
missing producer, when the producer is there and the problem is the
loop.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-10-24 16:11:36 -05:00
1 parent 53b04f7a32
commit 9420f3feeb
4 files changed
+14 -9

No files matched your search

+1 -1
View File
@@ -57,7 +57,7 @@ describe('one producer per token', () => {
describe('self-dependency', () => {
it('counts as missing when the token is not seeded', () => {
expect(() => topoSort([node('auth', ['user'], ['user'])], [])).toThrow(
/missing dependency: user needed by auth — it provides 'user' itself/,
/cycle detected: auth -> auth \(it needs 'user', which only it provides\)/,
);
});