Skip to content

Commit 2fd19cd

Browse files
Claude/resume repos migration 9 o2 u1 (#34)
<!-- SPDX-License-Identifier: PMPL-1.0-or-later --> ## Summary <!-- Briefly describe what this PR does and why. Link to related issues with "Closes #N". --> ## Changes <!-- List the key changes introduced by this PR. --> - ## RSR Quality Checklist <!-- Check all that apply. PRs that fail required checks will not be merged. --> ### Required - [ ] Tests pass (`just test` or equivalent) - [ ] Code is formatted (`just fmt` or equivalent) - [ ] Linter is clean (no new warnings or errors) - [ ] No banned language patterns (no TypeScript, no npm/bun, no Go/Python) - [ ] No `unsafe` blocks without `// SAFETY:` comments - [ ] No banned functions (`believe_me`, `unsafeCoerce`, `Obj.magic`, `Admitted`, `sorry`) - [ ] SPDX license headers present on all new/modified source files - [ ] No secrets, credentials, or `.env` files included ### As Applicable - [ ] `.machine_readable/STATE.a2ml` updated (if project state changed) - [ ] `.machine_readable/ECOSYSTEM.a2ml` updated (if integrations changed) - [ ] `.machine_readable/META.a2ml` updated (if architectural decisions changed) - [ ] Documentation updated for user-facing changes - [ ] `TOPOLOGY.md` updated (if architecture changed) - [ ] `CHANGELOG` or release notes updated - [ ] New dependencies reviewed for license compatibility (PMPL-1.0-or-later / MPL-2.0) - [ ] ABI/FFI changes validated (`src/abi/` and `ffi/zig/` consistent) ## Testing <!-- Describe how you tested these changes. --> ## Screenshots <!-- If applicable, add screenshots or terminal output demonstrating the change. --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9394045 commit 2fd19cd

3 files changed

Lines changed: 335 additions & 8 deletions

File tree

cartridges/local-coord-mcp/adapter/local_coord_adapter.zig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,31 @@ fn dispatch(tool: []const u8, body: []const u8, resp: []u8, allocator: std.mem.A
927927
w.writeAll("\"") catch return .{ .status = 500, .body = errJson(resp, "buffer overflow") };
928928
}
929929
}
930+
w.writeAll("],\"by_peer\":[") catch return .{ .status = 500, .body = errJson(resp, "buffer overflow") };
931+
932+
// Per-peer reject counts + cooldown flags (Item A — rejection rate-limit hardening).
933+
// Skip inactive slots; peer_id rebuilt canonically via renderPeerId.
934+
var wrote_bp: bool = false;
935+
var pi: c_int = 0;
936+
while (pi < 16) : (pi += 1) {
937+
const pk = ffi.coord_read_peer_kind(pi);
938+
if (pk < 0) continue;
939+
var psuf: [4]u8 = undefined;
940+
if (ffi.coord_read_peer_suffix(pi, &psuf) != 4) continue;
941+
var pctx_buf: [32]u8 = undefined;
942+
const pctx_len = ffi.coord_read_peer_context(pi, &pctx_buf, @intCast(pctx_buf.len));
943+
const pctx_slice: []const u8 = if (pctx_len > 0) pctx_buf[0..@intCast(pctx_len)] else "";
944+
var pid_buf: [96]u8 = undefined;
945+
const pid = renderPeerId(&pid_buf, kindName(pk), &psuf, pctx_slice) catch continue;
946+
const prc = ffi.coord_count_rejects_recent_peer(&token, 16, pi);
947+
if (prc < 0) continue;
948+
const pcd = ffi.coord_peer_in_cooldown(&token, 16, pi);
949+
if (wrote_bp) w.writeAll(",") catch return .{ .status = 500, .body = errJson(resp, "buffer overflow") };
950+
wrote_bp = true;
951+
std.fmt.format(w, "{{\"peer_id\":\"{s}\",\"count\":{d},\"in_cooldown\":{s}}}", .{
952+
pid, prc, if (pcd == 1) "true" else "false",
953+
}) catch return .{ .status = 500, .body = errJson(resp, "buffer overflow") };
954+
}
930955
w.writeAll("]}}") catch return .{ .status = 500, .body = errJson(resp, "buffer overflow") };
931956
return .{ .status = 200, .body = resp[0..stream.pos] };
932957
}

0 commit comments

Comments
 (0)