Skip to content

Commit 1609f70

Browse files
committed
chore(gates): R81 rejects a declared layer that owns no files
An empty layer array kept a phantom position in the daemon layer order after its last file moved; reject it, and isolate the orphaned-file test from the empty-layer check.
1 parent f680d70 commit 1609f70

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

‎scripts/layering/daemon-layers.test.ts‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,9 @@ test('a dynamic cross-layer edge is reported, not rejected', () => {
119119
});
120120

121121
test('a production daemon file missing from the manifest fails', () => {
122-
const manifest = {
123-
...FIXTURE_MANIFEST,
124-
'daemon-server': [],
125-
};
126-
const violations = driftFor(manifest);
122+
const violations = driftFor(FIXTURE_MANIFEST, [...FIXTURE_FILES, 'src/daemon/server2.ts']);
127123
assert.equal(violations.length, 1);
128-
assert.equal(violations[0]!.file, 'src/daemon/server.ts');
124+
assert.equal(violations[0]!.file, 'src/daemon/server2.ts');
129125
assert.match(violations[0]!.message, /production daemon file is in no layer/);
130126
});
131127

@@ -187,3 +183,12 @@ test('a layer key missing from the manifest fails even when no file is orphaned'
187183
assert.equal(violations.length, 1);
188184
assert.match(violations[0]!.message, /layer "daemon-resources" is missing from the manifest/);
189185
});
186+
187+
test('a declared layer whose array is empty fails, so it cannot linger after its last file moves', () => {
188+
const violations = driftFor(
189+
{ ...FIXTURE_MANIFEST, 'daemon-resources': [] },
190+
FIXTURE_FILES.filter((file) => file !== 'src/daemon/resources.ts'),
191+
);
192+
assert.equal(violations.length, 1);
193+
assert.match(violations[0]!.message, /layer "daemon-resources" owns no files/);
194+
});

‎scripts/layering/daemon-layers.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,19 @@ export function daemonLayerManifestDrift(
9999
}
100100
}
101101
for (const layer of DAEMON_LAYER_ORDER) {
102-
if (manifest[layer] === undefined) {
102+
const owned = manifest[layer];
103+
if (owned === undefined) {
103104
violations.push(
104105
manifestFileViolation(
105106
`layer "${layer}" is missing from the manifest. Every declared layer must own files or leave the order.`,
106107
),
107108
);
109+
} else if (owned.length === 0) {
110+
violations.push(
111+
manifestFileViolation(
112+
`layer "${layer}" owns no files. A layer that lost its last file leaves the order; an empty entry keeps a phantom position in it.`,
113+
),
114+
);
108115
}
109116
}
110117

0 commit comments

Comments
 (0)