Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"email": "hi@okis.dev"
},
"description": "Multi-model orchestration marketplace for Claude Code.",
"version": "0.0.36",
"version": "0.0.37",
"plugins": [
{
"name": "grok",
"source": "./plugins/grok",
"displayName": "Grok Companion",
"description": "Local Grok CLI delegation: task, review, resumable history, best-of-n tournaments, background jobs, stats, and setup health checks.",
"version": "0.0.36",
"version": "0.0.37",
"author": {
"name": "Harry Yep"
},
Expand All @@ -34,7 +34,7 @@
"source": "./plugins/codex",
"displayName": "Codex Companion",
"description": "First party local Codex CLI delegation for tasks, reviews, resumable threads, and durable background jobs.",
"version": "0.0.36",
"version": "0.0.37",
"author": {
"name": "Harry Yep"
},
Expand All @@ -55,7 +55,7 @@
"source": "./plugins/fusion",
"displayName": "Fusion Orchestrator",
"description": "Multi-model orchestration: tier agents, routing rules, blind panel, ultra fleet, model config, and drift doctor.",
"version": "0.0.36",
"version": "0.0.37",
"author": {
"name": "Harry Yep"
},
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# changelog

## 0.0.37

- settlement and telemetry become more discriminating: batched settlement validates every pair before writing, reports per pair rejection reasons, and `/fusion:stats` adds lane drift, per SKU trends, narrow wave watch, and an acceptance epoch cutoff; the worker lifecycle adds a parent context advisory, package type and brief byte capture, recalibrated trivial worker budgets, and token observations, while the inline guard gains tail allowance and softens zero dispatches
- repeated advisory noise is reduced across the lanes: in flight stop notices dedupe, the Grok token observer gains monitor silence, and the Codex monitor stays silent when no announcement is needed; verification also surfaces manifest lint advisories and codifies wave settlement and dispatch norms
- Codex now warns when Sol runs in the foreground, surfaces timeout resume state, and records `repositoryTopLevel`; Grok reports permission denial detail and the same repository identity, with peer wrapper completion contract canaries covering the delivery gate
- the bench suite completes all eight tasks, closing the release's orchestration, observability, transport, verification, and lifecycle coverage

## 0.0.36

- peer transport wrappers get their own completion contract: 0.0.35's SubagentStop matcher expansion routed `codex:codex-rescue`, `grok:grok-rescue`, and `grok:grok-review-runner` through the claude worker deliverable gate, whose `verification` contract demands a final message ending in `delivery: complete` plus `verification: passed`; a verbatim companion relay ends with the engine envelope (`job:`, `state:`) instead, so every foreground peer delivery burned its single truncation recovery retry arguing with the gate, took a false `failureKind: delivery`, and terminalized as `incomplete`, which the notification reconcile guard skips, breaking notification driven auto collection and forcing a stop collection block on every peer package (observed two of two in the first 0.0.35 session against twenty nine of twenty nine clean on 0.0.34 the same day); dispatches now record a `transport` contract, `completedReport` accepts a relay whose footer parses through `peerJobIdFromCollectedResult` (the same parser settlement identity backfill uses, with `grok:grok-review-runner` always deliverable because its terminal output may be raw json validated by the review consumer), a matching transport retry message covers genuinely truncated relays, and the guards also match the agent type so records created before the fix settle correctly after a hot deploy
Expand Down
1 change: 1 addition & 0 deletions bench/tasks/T02-negative-control/brief.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This task is the benchmark suite's negative control, a small single file fix where delegation is expected to provide no advantage over making the change directly, and its purpose is to check that the harness does not manufacture an advantage where none exists. The small library in this folder is a numeric range helper exported from range.js. The clamp function takes a value, a minimum, and a maximum, and it should return the minimum when the value falls below it and the maximum when the value falls above it, leaving a value already between them unchanged. With a minimum of 0 and a maximum of 10, clamp(-5, 0, 10) should return 0 and clamp(15, 0, 10) should return 10. In the current code the two boundaries are swapped, so clamp(-5, 0, 10) returns 10 and clamp(15, 0, 10) returns 0, pushing a value below the range to the top of the range and a value above the range to the bottom. The normalize function calls clamp internally and maps the result onto the 0 to 1 interval, so the same swapped boundaries make normalize(-5, 0, 10) return 1 instead of 0 and normalize(15, 0, 10) return 0 instead of 1. Please fix clamp so each out of range value returns the boundary on its own side, while keeping normalize, lerp, and the existing guard against a minimum greater than a maximum unchanged.
3 changes: 3 additions & 0 deletions bench/tasks/T02-negative-control/fixtures/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
23 changes: 23 additions & 0 deletions bench/tasks/T02-negative-control/fixtures/range.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export function clamp(value, min, max) {
if (min > max) {
throw new RangeError("min must not exceed max");
}
if (value < min) {
return max;
}
if (value > max) {
return min;
}
return value;
}

export function normalize(value, min, max) {
if (max === min) {
throw new RangeError("max must be greater than min");
}
return (clamp(value, min, max) - min) / (max - min);
}

export function lerp(t, min, max) {
return min + t * (max - min);
}
3 changes: 3 additions & 0 deletions bench/tasks/T02-negative-control/mutant/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
23 changes: 23 additions & 0 deletions bench/tasks/T02-negative-control/mutant/range.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export function clamp(value, min, max) {
if (min > max) {
throw new RangeError("min must not exceed max");
}
if (value < min) {
return max;
}
if (value > max) {
return min;
}
return value;
}

export function normalize(value, min, max) {
if (max === min) {
throw new RangeError("max must be greater than min");
}
return (clamp(value, min, max) - min) / (max - min);
}

export function lerp(t, min, max) {
return min + t * (max - min);
}
32 changes: 32 additions & 0 deletions bench/tasks/T02-negative-control/range.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { clamp, normalize, lerp } from "./range.js";

test("clamp pins a low value to min and a high value to max", () => {
assert.equal(clamp(-5, 0, 10), 0);
assert.equal(clamp(15, 0, 10), 10);
assert.equal(clamp(4, 0, 10), 4);
});

test("clamp leaves boundary values unchanged", () => {
assert.equal(clamp(0, 0, 10), 0);
assert.equal(clamp(10, 0, 10), 10);
});

test("clamp rejects a range where min exceeds max", () => {
assert.throws(() => clamp(5, 10, 0), RangeError);
});

test("normalize maps a bounded value onto zero through one", () => {
assert.equal(normalize(0, 0, 10), 0);
assert.equal(normalize(10, 0, 10), 1);
assert.equal(normalize(5, 0, 10), 0.5);
assert.equal(normalize(-5, 0, 10), 0);
assert.equal(normalize(15, 0, 10), 1);
});

test("lerp is unaffected by the clamp fix", () => {
assert.equal(lerp(0, 0, 10), 0);
assert.equal(lerp(1, 0, 10), 10);
assert.equal(lerp(0.5, 0, 10), 5);
});
26 changes: 26 additions & 0 deletions bench/tasks/T02-negative-control/selftest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -euo pipefail

TASK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VERIFY="${TASK_DIR}/verify.sh"

fail() {
echo "FAIL: $1" >&2
exit 1
}

TMP_MUTANT="$(mktemp -d)"
trap 'rm -rf "$TMP_MUTANT" "$TMP_SOLUTION"' EXIT
TMP_SOLUTION="$(mktemp -d)"

cp -R "${TASK_DIR}/mutant"/. "$TMP_MUTANT"/
if bash "$VERIFY" "$TMP_MUTANT"; then
fail "mutant leg: verify.sh should reject the known bad solution"
fi

cp -R "${TASK_DIR}/solution"/. "$TMP_SOLUTION"/
if ! bash "$VERIFY" "$TMP_SOLUTION"; then
fail "solution leg: verify.sh should accept the reference fix"
fi

echo "PASS"
3 changes: 3 additions & 0 deletions bench/tasks/T02-negative-control/solution/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
23 changes: 23 additions & 0 deletions bench/tasks/T02-negative-control/solution/range.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export function clamp(value, min, max) {
if (min > max) {
throw new RangeError("min must not exceed max");
}
if (value < min) {
return min;
}
if (value > max) {
return max;
}
return value;
}

export function normalize(value, min, max) {
if (max === min) {
throw new RangeError("max must be greater than min");
}
return (clamp(value, min, max) - min) / (max - min);
}

export function lerp(t, min, max) {
return min + t * (max - min);
}
30 changes: 30 additions & 0 deletions bench/tasks/T02-negative-control/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -euo pipefail

if [[ $# -ne 1 ]]; then
echo "usage: bash verify.sh <workdir>" >&2
exit 2
fi

WORKDIR="$1"
TASK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HIDDEN_TEST="${TASK_DIR}/range.test.mjs"

if [[ ! -d "$WORKDIR" ]]; then
echo "workdir is not a directory: $WORKDIR" >&2
exit 2
fi

if [[ ! -f "$HIDDEN_TEST" ]]; then
echo "hidden test missing: $HIDDEN_TEST" >&2
exit 2
fi

TMP="$(mktemp -d)"
trap 'rm -rf "$TMP"' EXIT

cp -R "$WORKDIR"/. "$TMP"/
cp "$HIDDEN_TEST" "$TMP"/

cd "$TMP"
exec node --test
12 changes: 12 additions & 0 deletions bench/tasks/T03-spec-implementation/brief.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Event bus implementation

Implement the event bus described here in the fixture project. The package has no dependencies and uses native Node ESM.

The package entry point, `index.js`, must export the named exports `EventBus` and `matchesPattern`. Keep the implementation split between `match-pattern.js`, `subscriptions.js`, and `event-bus.js`; `index.js` only exposes the public API.

1. A topic is a nonempty string of dot separated segments. Each segment must be nonempty and must not contain `.` or `*`. A pattern follows the same rule except its final segment may be `*`. A pattern of `*` is valid. Reject every invalid topic or pattern with `TypeError`.
2. `matchesPattern(pattern, topic)` validates both arguments. It returns `true` for an exact match. A final `*` matches exactly one topic segment, so `orders.*` matches `orders.created` but not `orders.created.audit`, and `*` matches `ready` but not `system.ready`.
3. `new EventBus()` creates an empty bus. `subscribe(pattern, listener)` validates its pattern and requires a function listener, otherwise it throws `TypeError`. It returns an unsubscribe function. Calling that function removes only its registration and returns `true`; later calls return `false`. Separate registrations of the same listener are separate subscriptions.
4. `once(pattern, listener)` has the same validation and return contract as `subscribe`. Its listener is removed before it is called, so a listener that publishes the same topic recursively still runs only once.
5. `publish(topic, payload)` validates its topic, then synchronously calls every listener whose pattern matches. Listeners receive `(payload, topic)` and run in registration order across exact and wildcard patterns. It returns the number of listeners selected for the delivery.
6. A publish uses a snapshot of the matching registrations taken before the first listener runs. A listener that subscribes or unsubscribes during delivery does not change that delivery, but does affect later publishes. If a listener throws, `publish` propagates that error immediately and does not call later listeners.
123 changes: 123 additions & 0 deletions bench/tasks/T03-spec-implementation/event-bus.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { EventBus, matchesPattern } from "./index.js";

test("the package exports the public event bus API", () => {
assert.equal(typeof EventBus, "function");
assert.equal(typeof matchesPattern, "function");
});

test("patterns match exact topics and one wildcard segment", () => {
assert.equal(matchesPattern("orders.created", "orders.created"), true);
assert.equal(matchesPattern("orders.*", "orders.created"), true);
assert.equal(matchesPattern("*", "ready"), true);
assert.equal(matchesPattern("orders.*", "orders.created.audit"), false);
assert.equal(matchesPattern("*", "system.ready"), false);
assert.equal(matchesPattern("orders.*", "payments.created"), false);
});

test("topics and patterns reject invalid names", () => {
const invalidTopics = ["", ".ready", "ready.", "system..ready", "system.*", 3];
const invalidPatterns = ["", ".ready", "ready.", "system..*", "*.ready", "ready*", 3];

for (const topic of invalidTopics) {
assert.throws(() => matchesPattern("*", topic), TypeError);
}
for (const pattern of invalidPatterns) {
assert.throws(() => matchesPattern(pattern, "ready"), TypeError);
}
});

test("publish delivers matching listeners in registration order and preserves payload identity", () => {
const bus = new EventBus();
const payload = { id: 42 };
const received = [];

bus.subscribe("orders.*", (value, topic) => received.push(["wildcard", value, topic]));
bus.subscribe("orders.created", (value, topic) => received.push(["exact", value, topic]));
bus.subscribe("orders.*", (value, topic) => received.push(["second wildcard", value, topic]));

assert.equal(bus.publish("orders.created", payload), 3);
assert.deepEqual(received, [
["wildcard", payload, "orders.created"],
["exact", payload, "orders.created"],
["second wildcard", payload, "orders.created"],
]);
});

test("separate subscriptions and unsubscription have independent idempotent results", () => {
const bus = new EventBus();
let calls = 0;
const listener = () => {
calls += 1;
};
const removeFirst = bus.subscribe("ready", listener);
const removeSecond = bus.subscribe("ready", listener);

assert.equal(removeFirst(), true);
assert.equal(removeFirst(), false);
assert.equal(bus.publish("ready"), 1);
assert.equal(calls, 1);
assert.equal(removeSecond(), true);
assert.equal(bus.publish("ready"), 0);
});

test("once removes its listener before a recursive publish", () => {
const bus = new EventBus();
let calls = 0;
const removeUncalled = bus.once("later", () => {
calls += 1;
});
const remove = bus.once("tick", () => {
calls += 1;
assert.equal(bus.publish("tick"), 0);
});

assert.equal(removeUncalled(), true);
assert.equal(removeUncalled(), false);
assert.equal(bus.publish("later"), 0);
assert.equal(bus.publish("tick"), 1);
assert.equal(calls, 1);
assert.equal(remove(), false);
assert.equal(bus.publish("tick"), 0);
});

test("subscriptions changed during publish affect only later publishes", () => {
const bus = new EventBus();
const received = [];
let removeThird;

bus.subscribe("sync", () => {
received.push("first");
removeThird();
bus.subscribe("sync", () => received.push("later"));
});
bus.subscribe("sync", () => received.push("second"));
removeThird = bus.subscribe("sync", () => received.push("third"));

assert.equal(bus.publish("sync"), 3);
assert.deepEqual(received, ["first", "second", "third"]);
received.length = 0;
assert.equal(bus.publish("sync"), 3);
assert.deepEqual(received, ["first", "second", "later"]);
});

test("validation failures and listener errors stop publishing", () => {
const bus = new EventBus();
assert.throws(() => bus.subscribe("ready", null), TypeError);
assert.throws(() => bus.once("ready", null), TypeError);
assert.throws(() => bus.subscribe("*.ready", () => {}), TypeError);
assert.throws(() => bus.publish("ready.*"), TypeError);

const failure = new Error("listener failure");
let afterFailure = false;
bus.subscribe("fail", () => {
throw failure;
});
bus.subscribe("fail", () => {
afterFailure = true;
});

assert.throws(() => bus.publish("fail"), failure);
assert.equal(afterFailure, false);
});
13 changes: 13 additions & 0 deletions bench/tasks/T03-spec-implementation/fixtures/event-bus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export class EventBus {
subscribe() {
throw new Error("not implemented");
}

once() {
throw new Error("not implemented");
}

publish() {
throw new Error("not implemented");
}
}
2 changes: 2 additions & 0 deletions bench/tasks/T03-spec-implementation/fixtures/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { EventBus } from "./event-bus.js";
export { matchesPattern } from "./match-pattern.js";
17 changes: 17 additions & 0 deletions bench/tasks/T03-spec-implementation/fixtures/match-pattern.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export function assertTopic(topic) {
if (typeof topic !== "string") {
throw new TypeError("topic must be a string");
}
}

export function assertPattern(pattern) {
if (typeof pattern !== "string") {
throw new TypeError("pattern must be a string");
}
}

export function matchesPattern(pattern, topic) {
assertPattern(pattern);
assertTopic(topic);
return pattern === topic;
}
Loading
Loading