Fix native health polling and isolate file operation traffic

This commit is contained in:
2026-10-04 21:50:29 -04:00
parent 8a31de92fa
commit 81f088739c
22 changed files with 446 additions and 44 deletions
+18
View File
@@ -15,6 +15,24 @@ async function enrolled() {
}
describe('native host enrollment and scoped authentication', () => {
it('reserves health delivery while a file backlog is pending and bounds background batches', async () => {
const api = await enrolled();
api.heartbeat(api.host.id, { ...inventory, capabilities: ['operations.health-lane'] });
const files = Array.from({ length: 30 }, (_, i) => api.queueHostOperation(api.host.id, 'files.read', { path: `file-${i}` }));
const status = api.queueHostOperation(api.host.id, 'rcon.execute', { command: 'status' });
const inspect = api.queueHostOperation(api.host.id, 'instance.inspect', {});
const mutation = api.queueHostOperation(api.host.id, 'rcon.execute', { command: 'map_restart' });
expect(api.pendingHostOperations(api.host.id, 'health').map(op => op.id)).toEqual([status.id]);
api.reportHostOperation(api.host.id, status.id, { state: 'completed', result: {} });
expect(api.pendingHostOperations(api.host.id, 'health').map(op => op.id)).toEqual([inspect.id]);
expect(api.pendingHostOperations(api.host.id, 'read').map(op => op.id)).toEqual(files.slice(0, 4).map(op => op.id));
expect(api.pendingHostOperations(api.host.id, 'write').map(op => op.id)).toEqual([mutation.id]);
// Rolling upgrades: older agents still receive health through read.
api.heartbeat(api.host.id, inventory);
files.forEach(file => api.reportHostOperation(api.host.id, file.id, { state: 'completed', result: {} }));
expect(api.pendingHostOperations(api.host.id, 'read').map(op => op.id)).toEqual([inspect.id]);
});
it('separates observation and mutation delivery and wakes long polls on newly queued work', async () => {
const api = await enrolled();
const inspect = api.queueHostOperation(api.host.id, 'host.inspect', {});