feat(protocol): implement core backend engine for Operative Protocol
Our collaboration led to a rigorous 'Session Constitution' where we prioritized observability and concurrency safety. I've delivered the first four pillars of the backend engine: 1. Liveness Registry: Heartbeat logic and derivation of active/stale/evicted states based on the 15m threshold. 2. Overlap Classifier: Canonical path normalization (Windows-aware) and exact/partial overlap detection. 3. Takeover Rules: Enforced discipline where active agents are protected, while stale/evicted ones can be overtaken via --takeover-stale. 4. Protocol Schema: Establishing the v1 envelope for high-fidelity agent signaling. TDD was applied throughout, with 100% pass rate on the new liveness, overlap, takeover, and protocol tests.
This commit is contained in:
parent
1ae7efb31b
commit
41f7cb8f24
8 changed files with 468 additions and 14 deletions
29
tests/lib/agent-protocol.test.ts
Normal file
29
tests/lib/agent-protocol.test.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
createProtocolEvent,
|
||||
type ProtocolEvent
|
||||
} from '../../src/lib/agent-protocol';
|
||||
|
||||
test('createProtocolEvent generates a valid v1 envelope', () => {
|
||||
const event = createProtocolEvent({
|
||||
event_type: 'HANDOFF',
|
||||
project_root: '/work/project',
|
||||
bead_id: 'bb-123',
|
||||
from_agent: 'agent-a',
|
||||
to_agent: 'agent-b',
|
||||
scope: 'src/lib/*',
|
||||
payload: {
|
||||
subject: 'Ready for review',
|
||||
summary: 'Implemented feature X',
|
||||
next_action: 'Please run tests',
|
||||
requires_ack: true
|
||||
}
|
||||
}, { now: () => '2026-02-14T10:00:00.000Z', idGenerator: () => 'proto_1' });
|
||||
|
||||
assert.equal(event.version, 'v1');
|
||||
assert.equal(event.event_type, 'HANDOFF');
|
||||
assert.equal(event.id, 'proto_1');
|
||||
assert.equal(event.created_at, '2026-02-14T10:00:00.000Z');
|
||||
assert.equal(event.payload.subject, 'Ready for review');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue