Skip to content

Commit 12bc86e

Browse files
author
jovanSAPFIONEER
committed
feat: Phase 3 - Priority & Preemption (v3.2.0)
- Add ConflictResolutionStrategy type: 'first-commit-wins' | 'priority-wins' - Add AgentPriority type (0-3) with validation/clamping - Update propose() with optional priority parameter - Update validate() to preempt lower-priority changes in priority-wins mode - Update commit() with under-lock priority check - Add findConflictingPendingChanges() and preempt() helpers - Add BLACKBOARD_PREEMPT audit events - Backward-compatible constructor overloads - 64 new tests (13 test groups), 315 total passing - Export new types from main index
1 parent 918e48b commit 12bc86e

File tree

6 files changed

+852
-32
lines changed

6 files changed

+852
-32
lines changed

CHANGELOG.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,26 @@ All notable changes to Network-AI will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased] -- Phase 3: Priority & Preemption
8+
## [3.2.0] - 2026-02-17
9+
10+
### Added -- Phase 3: Priority & Preemption
11+
- **Priority-Based Conflict Resolution** -- `'priority-wins'` strategy for `LockedBlackboard` commit step; higher-priority agents preempt lower-priority pending/committed writes on same-key conflicts (0=low, 3=critical)
12+
- **`ConflictResolutionStrategy` type** -- Choose between `'first-commit-wins'` (default, current behavior) and `'priority-wins'` (new)
13+
- **`AgentPriority` type** -- `0 | 1 | 2 | 3` typed priority levels
14+
- **`LockedBlackboardOptions` interface** -- Configuration object for LockedBlackboard constructor
15+
- **Priority-aware `propose()`** -- Optional 5th parameter for agent priority
16+
- **Priority-aware `validate()`** -- In `priority-wins` mode, higher-priority changes preempt lower-priority pending changes and override committed values from lower-priority agents
17+
- **Priority-aware `commit()`** -- Under-lock double-check respects priority in `priority-wins` mode
18+
- **`findConflictingPendingChanges()`** -- Public helper to list pending/validated changes targeting the same key
19+
- **`getConflictResolution()`** -- Query the active conflict resolution strategy
20+
- **Preemption audit events** -- `BLACKBOARD_PREEMPT` events logged when changes are preempted
21+
- **Priority validation** -- Invalid priority values clamped to 0-3 range; non-integers default to 0
22+
- **Backward-compatible constructor** -- Supports both `new LockedBlackboard(path, auditLogger, options)` and `new LockedBlackboard(path, options)`
23+
- **64 new priority tests** -- 13 test groups covering default behavior regression, preemption, same-priority fallback, metadata, constructor overloads, TTL interaction, backward compatibility
924

10-
### Planned
11-
- **Priority-Based Conflict Resolution** -- `'priority-wins'` strategy for `LockedBlackboard` commit step; higher-priority agents preempt lower-priority pending writes on same-key conflicts (0=low, 3=critical)
12-
- **`ConflictResolutionStrategy` option** -- Choose between `'first-commit-wins'` (default, current behavior) and `'priority-wins'` (new)
13-
- **Priority-aware `validate()` / `commit()`** -- Wire `HandoffMessage.metadata.priority` into the atomic commit pipeline
25+
### Stats
26+
- 315 tests passing (79 + 33 + 139 + 64)
27+
- 0 compile errors
1428

1529
## [Future] -- Phase 4: Distributed Blackboard
1630

README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
**The plug-and-play AI agent orchestrator for TypeScript/Node.js -- connect 12 agent frameworks with zero glue code**
44

5-
[![Release](https://img.shields.io/badge/release-v3.1.3-blue.svg)](https://github.com/jovanSAPFIONEER/Network-AI/releases)
5+
[![Release](https://img.shields.io/badge/release-v3.2.0-blue.svg)](https://github.com/jovanSAPFIONEER/Network-AI/releases)
66
[![ClawHub](https://img.shields.io/badge/ClawHub-network--ai-orange.svg)](https://clawhub.ai/skills/network-ai)
77
[![Node.js](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org)
88
[![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178C6.svg)](https://typescriptlang.org)
99
[![Python](https://img.shields.io/badge/python-3.9+-green.svg)](https://python.org)
1010
[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE)
1111
[![AgentSkills](https://img.shields.io/badge/AgentSkills-compatible-orange.svg)](https://agentskills.io)
12-
[![Tests](https://img.shields.io/badge/tests-251%20passing-brightgreen.svg)](#testing)
12+
[![Tests](https://img.shields.io/badge/tests-315%20passing-brightgreen.svg)](#testing)
1313
[![Adapters](https://img.shields.io/badge/frameworks-12%20supported-blueviolet.svg)](#adapter-system)
1414
[![RSS Feed](https://img.shields.io/badge/RSS-releases-orange?logo=rss)](https://github.com/jovanSAPFIONEER/Network-AI/releases.atom)
1515

@@ -134,6 +134,7 @@ Network-AI wraps your agent swarm with **file-system mutexes**, **atomic commits
134134
### Operational Safety
135135
- **Swarm Guard** -- Prevents "Handoff Tax" (wasted tokens) and detects silent agent failures
136136
- **Atomic Commits** -- File-system mutexes prevent split-brain in concurrent writes
137+
- **Priority-Based Preemption** -- Higher-priority agents preempt lower-priority writes on same-key conflicts (`priority-wins` strategy)
137138
- **Cost Awareness** -- Token budget tracking with automatic SafetyShutdown
138139
- **Budget-Aware Handoffs** -- `intercept-handoff` command wraps `sessions_send` with budget checks
139140

@@ -358,7 +359,32 @@ python scripts/blackboard.py commit "chg_001"
358359
python scripts/blackboard.py list
359360
```
360361

361-
#### 5. Check Budget Status
362+
#### 5. Priority-Based Conflict Resolution (Phase 3)
363+
364+
```typescript
365+
import { LockedBlackboard } from 'network-ai';
366+
367+
// Enable priority-wins strategy
368+
const board = new LockedBlackboard('.', { conflictResolution: 'priority-wins' });
369+
370+
// Low-priority worker proposes a change
371+
const lowId = board.propose('shared:config', { mode: 'draft' }, 'worker', undefined, 1);
372+
373+
// High-priority supervisor proposes to same key
374+
const highId = board.propose('shared:config', { mode: 'final' }, 'supervisor', undefined, 3);
375+
376+
// Worker commits first
377+
board.validate(lowId, 'orchestrator');
378+
board.commit(lowId);
379+
380+
// Supervisor validates -- higher priority wins despite stale hash
381+
board.validate(highId, 'orchestrator'); // true (preempts worker's value)
382+
board.commit(highId); // success
383+
384+
board.read('shared:config'); // { mode: 'final' } -- supervisor wins
385+
```
386+
387+
#### 6. Check Budget Status
362388

363389
```bash
364390
python scripts/swarm_guard.py budget-check --task-id "task_001"

index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { randomUUID, createHmac } from 'crypto';
1515
import { AdapterRegistry } from './adapters/adapter-registry';
1616
import { InputSanitizer, SecureSwarmGateway, RateLimiter, SecureAuditLogger, DataEncryptor, SecurityError } from './security';
1717
import { LockedBlackboard } from './lib/locked-blackboard';
18+
import type { ConflictResolutionStrategy, AgentPriority, LockedBlackboardOptions } from './lib/locked-blackboard';
1819
import { BlackboardValidator, QualityGateAgent } from './lib/blackboard-validator';
1920
import { Logger } from './lib/logger';
2021
import {
@@ -2153,6 +2154,9 @@ export type {
21532154
// Backward-compatible OpenClaw types
21542155
export type { OpenClawSkill, SkillContext, SkillResult };
21552156

2157+
// Phase 3: Priority & Preemption types
2158+
export type { ConflictResolutionStrategy, AgentPriority, LockedBlackboardOptions };
2159+
21562160
// Logger
21572161
export { Logger, LogLevel } from './lib/logger';
21582162
export type { LogEntry, LogTransport, LoggerConfig } from './lib/logger';

0 commit comments

Comments
 (0)