Skip to content

Claude/resume repos migration 9 o2 u1#32

Closed
hyperpolymath wants to merge 4 commits intomainfrom
claude/resume-repos-migration-9O2U1
Closed

Claude/resume repos migration 9 o2 u1#32
hyperpolymath wants to merge 4 commits intomainfrom
claude/resume-repos-migration-9O2U1

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

Summary

Changes

RSR Quality Checklist

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

Screenshots

claude added 4 commits April 19, 2026 22:37
…bilities (Tasks #33 + #34)

Closes P0 backlog items #33 and #34 in docs/handover/COORD-MCP-TODO.md.
Version bumped to 0.7.0 (cartridge.json + cartridge.ncl + boj_cartridge_version).

Task #33 — client_kind extension + free-form variant label
- ClientKind enum: added openai (4) + mistral (5) in Zig FFI and Idris
  ABI (SafeLocalCoord.idr); KIND_COUNT bumped 4 → 6 for reject-ring.
- Peer struct gains `variant: [32]u8 + variant_len` (alphanumeric +
  `.`/`-`/`_` only). New FFI:
    coord_set_variant(token, variant)
    coord_read_peer_variant(peer_idx, out, cap)
- Adapter `coord_register` accepts optional `variant` and `capabilities`
  blocks — invalid values roll back the register so the caller sees a
  clean 400. `coord_list_peers` output now includes a `variant` field.
- Durable log: peer_variant_set = 15 (new event type), with
  logPeerVariantSet + decodePeerVariantSet and replay-dispatch wiring
  so slot reuse after crash reconstructs variant correctly.

Task #34 — capability advertisement for cold-start routing
- Per-peer storage: class_csv (≤128B), tier (0=unset, 1..5), and
  prover_strengths CSV (≤256B). CSV alphabets restricted to
  [A-Za-z0-9._-+/,] so later JSON rendering stays injection-safe.
- New FFI:
    coord_set_capabilities(token, class, tier, provers)
    coord_read_peer_class / _tier / _provers
- Adapter tools (cartridge.ncl + cartridge.json):
    coord_set_variant        — post-register update
    coord_set_capabilities   — post-register update
    coord_get_peer_capabilities
      — returns {peer_id, kind, variant, tier, class[], prover_strengths[]}
        using the server-rebuilt canonical peer_id rather than echoing
        client input.
- Durable log: peer_capabilities_set = 16 with matching encode + decode
  + replay-dispatch.

Tests
- Extended `default role derives from client_kind` to cover openai /
  mistral → apprentice.
- New `set and read peer variant (Task #33)` — round-trip, rejection of
  invalid chars, slot-reuse clears variant.
- New `set and read peer capabilities (Task #34)` — round-trip, tier
  out-of-range rejection retains prior value, bad CSV char (`"`)
  rejected.

Notes
- Build + e2e verification deferred: Zig is not on PATH in this
  environment. Pattern for every new code path mirrors established
  idioms in the same file (@memcpy slices, std.io.fixedBufferStream,
  std.mem.splitScalar, std.mem.writeInt with `buf[p_off..][0..2]`).
- cartridge.json was hand-synchronised; note the pre-existing drift
  from cartridge.ncl (extra tools from Tasks #13..#15, #32, #35 live
  in .json only). Regenerating from Nickel would currently delete
  them; kept surgical until Nickel toolchain is available.
- D3 in TODO says `just cartridge-install` in 007-lang is gated on
  these tasks shipping — that unblock now applies.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

https://claude.ai/code/session_01DobLJY3jgoso4M3z7xcZi8
From P1 in docs/handover/COORD-MCP-TODO.md. Single read-only tool that
returns a coord-wide snapshot so operators can monitor health without
walking every existing export individually.

Version → 0.8.0 (cartridge.json + cartridge.ncl + boj_cartridge_version).

FFI additions (all require a valid session token, -1 on bad token):
  coord_count_quarantine         — active quarantine entries
  coord_count_claims             — active task claims
  coord_count_track              — track-record ring fill
  coord_count_rejects_recent(k)  — rejects in the 10-min window for kind k
  coord_kind_in_cooldown(k)      — 1 if kind k is in reject-cooldown

Adapter:
  coord_health {token} → {
    peers:      { active, max, by_kind, by_role },
    quarantine: { pending, max },
    claims:     { active, max },
    track:      { entries, max },
    rejects:    { window_ms, cooldown_ms, recent_by_kind, in_cooldown: [...] }
  }
  Validates caller token via coord_count_rejects_recent(kind=0); first -1
  short-circuits to 401. Per-peer breakdown walks the 16 slots directly
  using the existing coord_read_peer_kind / _role exports.

Tests:
  `coord_health counts basics` — bad token → -1, valid token with one
  active claim reflects count, unseen kind has zero rejects, out-of-range
  kind returns -2.

Non-goals for this pass:
  - No historical / time-series data (spill to VeriSimDB is a separate
    P1 item).
  - No rate-limiting on the poll — loopback only, all callers are trusted
    session peers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

https://claude.ai/code/session_01DobLJY3jgoso4M3z7xcZi8
Closes the last self-assessment layer. From P1 in
docs/handover/COORD-MCP-TODO.md, unblocks DD-9 in COORD-MCP-STATE.md.

Drift detector
--------------
The TODO criterion (`avg_confidence > 0.8 AND effective_affinity < 0.3`)
mechanically matches the existing overclaim heuristic, but the *intent*
is different: overclaim is a routing FYI, drift is a self-assessment
monitoring flag. They warrant distinct envelopes so the master sees
both signals without one drowning out the other.

`coord_scan_suggestions` now emits, on the same condition:
  - existing `kind:"overclaim"` — op_kind=fyi,  risk_tier=1 (routing)
  - new      `kind:"drift"`     — op_kind=warn, risk_tier=2 (monitoring)

The drift envelope additionally carries `drift_pct = avg_conf − pct`
so the master sees the magnitude of the gap at a glance.

kind_str fix
------------
Latent bug from Task #33: the engine-side `switch (agg.client_kind)` in
coord_scan_suggestions still mapped only kinds 0..2, falling through to
"custom" for openai/mistral peers. Extracted into a shared `kindStr`
helper that mirrors the adapter's `kindName` and now includes the new
kinds (4=openai, 5=mistral). All four suggestion emit branches use it.

Tests
-----
- Updated `scan flags overclaim` to also assert that a `kind:"drift"`
  envelope is emitted from the same condition, with `op_kind:"warn"`,
  risk_tier=2, and a `drift_pct` field.
- New `drift uses Task #33 kind names (openai)` — drift envelope from
  an openai peer now reports `client_kind:"openai"` rather than the
  fallback "custom".

Docs
----
- COORD-MCP-TODO.md: drift detector + coord_health crossed off in P1.
- COORD-MCP-STATE.md: DD-9 layer D moved from "pending P1" to "done"
  with implementation summary.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

https://claude.ai/code/session_01DobLJY3jgoso4M3z7xcZi8
From P1 in docs/handover/COORD-MCP-TODO.md — closes the DD-20 watchdog
item. Bump cartridge version to 0.9.0.

Mechanism
---------
Each claim now carries `claimed_at_ms`, stamped at grant and refreshed
on heartbeat. `sweepExpiredClaims(now_ms)` walks active claims and
auto-releases any where `(now − claimed_at_ms) > TTL(holder.role)`.

TTLs (DD-20):
  apprentice  → 30 s
  journeyman  → 5 min
  master      → no watchdog (approver, not executor)

Sweep runs:
  - implicitly at the top of every coord_claim_task (contention is the
    natural moment abandoned work matters — the new caller benefits
    immediately from the release), and
  - explicitly via `coord_sweep_watchdog` for ops that want a polling
    tick independent of claim traffic.

New FFI + tools
---------------
  FFI:
    coord_progress(token, task)     — 0 OK, -1 bad token, -2 no claim,
                                       -3 not the holder
    coord_sweep_watchdog(token)     — released-count, -1 on bad token

  Adapter:
    coord_progress {token, task}
    coord_sweep_watchdog {token}
      → {released, ttl_apprentice_ms, ttl_journeyman_ms}

Durability
----------
  EventType.claim_progress = 17 — payload: claim_idx:u8 timestamp_ms:u64
  Replay sets claimed_at_ms from claim_progress events; claim_add alone
  restores a fresh TTL (old logs predate the field).

Audit
-----
Auto-releases emit an audit record (kind=3 AUTO_RELEASE) with the
claim index, holder, role, age_ms, and task name. DD-21's warn_drift
broadcast via Opus review is a separate P1 item.

Tests
-----
  watchdog: apprentice claim swept past 30s TTL
  watchdog: progress heartbeat keeps claim alive
  watchdog: journeyman gets 5min TTL, master never swept
  watchdog: progress rejected from non-holder
  watchdog: implicit sweep frees stale slot on contention

Tests rewind `claims[i].claimed_at_ms` directly (same-module private
access) to simulate elapsed time deterministically — no sleeps, no
flakiness.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

https://claude.ai/code/session_01DobLJY3jgoso4M3z7xcZi8
@hyperpolymath hyperpolymath enabled auto-merge April 20, 2026 11:34
@hyperpolymath
Copy link
Copy Markdown
Owner Author

@copilot resolve the merge conflicts in this pull request

@hyperpolymath
Copy link
Copy Markdown
Owner Author

Merged to main

auto-merge was automatically disabled April 20, 2026 12:44

Pull request was closed

@hyperpolymath hyperpolymath deleted the claude/resume-repos-migration-9O2U1 branch April 20, 2026 12:44
hyperpolymath added a commit that referenced this pull request Apr 21, 2026
Carries forward the coord-mcp work orphaned when PR #32 closed on
2026-04-20 without the full set merging (only the watchdog squash landed
as c9a291d). The six tools added by the 0.8.0 health-snapshot and PR #29
variant/capability commits were on the cartridge manifest but absent
from the MCP bridge's advertised tool list, so Glama could not see them.

What landed
-----------

MCP bridge tool surface now matches cartridge.json:

* Added: `coord_set_variant`, `coord_set_capabilities`,
`coord_get_peer_capabilities`, `coord_health`, `coord_progress`,
`coord_sweep_watchdog`.
* Renamed: `coord_promote_to_supervisor` -> `coord_promote_to_master`
(DD-32). Old name kept only as a dispatch alias for one release; not
re-advertised.

Glama AAA tier posture
----------------------

Every tool description rewritten to hit Glama's six TDQS dimensions:
Purpose Clarity, Usage Guidelines, Behavioral Transparency, Parameter
Semantics, Conciseness & Structure, Contextual Completeness. The
server-level score is 60% mean + 40% *min*, so a single thin description
tanks the number -- 32 one-liners (browser, github, gitlab, comms,
research) all lifted above the floor.

Input schemas tightened: `additionalProperties: false`, enum
constraints, `minimum`/`maximum`, `pattern` regexes where meaningful
(cartridge name, variant label).

Coherence tests
---------------

New `mcp-bridge/tests/dispatch_test.js` (6 tests, all green):

1. Every `coord_*` in `cartridge.json` is exposed by the bridge (drift =
invisible to Glama).
2. `coord_promote_to_master` is canonical; old name not advertised.
3. Every tool has a >=80 char description (AAA floor).
4. Every `inputSchema` is a typed object.
5. `required[]` names match declared properties.
6. Tool names are unique.

`npm test` now runs these (was an echo no-op).

Version + metadata
------------------

* Server version 0.3.1 -> 0.4.0 across main.js, version.js, and both
package.json files.
* Cartridge count description 96 -> 100.
* Offline menu: local-coord-mcp version 0.1.0 -> 0.9.0; summary total 24
-> 100 to reflect disk truth.
* README: new "Local-coord-mcp at a glance" + "Glama AAA posture"
sections documenting the server's Glama stance and how the coherence
tests lock it in.

Also adds `docs/handover/HAIKU-SCOUT-PASS.md` -- reusable Haiku
scouting-pass prompt template for the next coord-mcp review cycle.

Test plan
---------

* [x] `node --test mcp-bridge/tests/dispatch_test.js` -- 6/6 green
* [x] `node --check` on every modified JS file
* [x] MCP stdio handshake still responds (verified by live reload
picking up the 6 new tools + dropping the renamed one)
* [ ] Glama re-index picks up the expanded tool list with AAA scores

Context
-------

Branch `claude/enhance-vibe-aaa-standard-ATSCg`. Completes the
unfinished parts of vibe's PR #32 at the MCP bridge layer and lifts the
server posture to Glama AAA quality.

<!-- 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. -->

Signed-off-by: Jonathan D.A. Jewell <6759885+hyperpolymath@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants