Skip to content

test(agent-registry): 25 structural tests for local registry skill (#1039) - #1159

Closed
bassilkhilo-ag2 wants to merge 1 commit into
sonichi:mainfrom
bassilkhilo-ag2:test/agent-registry-1039
Closed

bassilkhilo-ag2 wants to merge 1 commit into
sonichi:mainfrom
bassilkhilo-ag2:test/agent-registry-1039

Conversation

@bassilkhilo-ag2

Copy link
Copy Markdown
Collaborator

What

Structural tests covering the agent-registry skill added in PR #1039.

Background

PR #1039 introduced a local, dependency-free HTTP service that tracks running Claude Code instances. Agents register via a SessionStart hook, heartbeat while alive, and the registry ages out stale entries. Consumers (dashboard, Electron overlay) read the live list over a localhost API.

No tests shipped with the PR. This adds structural coverage for the critical invariants.

Tests (25 assertions)

registry-service.py (16)

# Assertion
1 stdlib only — no requests/flask/aiohttp
2 ThreadingHTTPServer from http.server
3 sqlite3 for persistence
4 Binds to 127.0.0.1
5 Does NOT bind to 0.0.0.0
6–10 All 5 endpoints: /register /heartbeat /deregister /agents /health
11 PORT_RANGE defined (port scan)
12 for port in range(...) iterates free-port scan
13 write_discovery() called at startup
14 agent-registry.json discovery file name
15 remove_discovery() in finally block
16 DB at <workspace>/data/agent-registry.db
17 STALE_SECS defined
18 PRUNE_SECS defined
19 All 8 expected schema columns present
20 ON CONFLICT upsert for idempotent re-registration
21 threading.Lock() guards DB operations
22 Atomic os.replace() for discovery write
23 SUTANDO_WORKSPACE env var respected
24 ~/.sutando/workspace default present

registry-client.py (5)

# Assertion
25 Reads agent-registry.json to find service
26 --autostart support
27 cmd_watch / def watch exists
28 start_new_session=True for service subprocess
29 signal.signal + SIGTERM handler
30 urllib (stdlib), not requests

session-start.sh (3)

# Assertion
31 Hook backgrounds registration (&)
32 Passes --autostart
33 Uses CLAUDE_PROJECT_DIR as --cwd

Run

python3 tests/agent-registry.test.py

🤖 Generated with Claude Code

@VasiliyRad VasiliyRad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two issues before approving:

  1. build_log.md must be removed from the PR. It's in .gitignore — this is mutable workspace state from the proactive loop, not something that should be tracked. Likely force-added by accident.

  2. src/health-check.py change is a production code modification (new _pid_script helper, enriched multi-PID warn format). The PR title/scope is test(agent-registry) — a functional health-check change doesn't belong here. Split it into its own PR (e.g. fix(health-check): show source paths in multi-bridge warn) or at minimum retitle to reflect both scopes.

Tests themselves look solid — structural grep assertions, meaningful invariants, no false-positive risk. Happy to approve once the two items above are addressed.

@bassilkhilo-ag2

Copy link
Copy Markdown
Collaborator Author

Status update (2026-05-26): The build_log.md and src/health-check.py entries in this diff are a housekeeping artifact — local main has 3 commits ahead of upstream main (two build_log.md chore commits + the health-check multi-PID fix from d9a384c), and this branch was branched from local main before the divergence was noticed.

The health-check change ships cleanly in PR #1157 (already APPROVED by @VasiliyRad). The build_log.md chore commits should never have been pushed and will be dropped.

A rebase onto upstream main (dropping build_log.md, letting health-check land via #1157) is ready — pending owner go-ahead to force-push. The actual test content here is unchanged and passes against current main.

…ill (sonichi#1039)

Covers: stdlib-only constraint, ThreadingHTTPServer binding, sqlite3
schema, 127.0.0.1-only bind, all 5 endpoints, port-range scan, atomic
discovery file write/remove, STALE_SECS/PRUNE_SECS, threading lock,
ON CONFLICT upsert, workspace resolution; client: discovery-based
location, --autostart, watch cmd, start_new_session=True, SIGTERM;
hook: backgrounded, --autostart, CLAUDE_PROJECT_DIR.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bassilkhilo-ag2
bassilkhilo-ag2 force-pushed the test/agent-registry-1039 branch from c82c296 to 31cf079 Compare May 27, 2026 02:58
@bassilkhilo-ag2

Copy link
Copy Markdown
Collaborator Author

Branch rebased onto origin/main — bundled junk (build_log.md, health-check.py, health-check-bridge-multi-pid.test.py) stripped. Diff is now clean: only the intended test file(s).

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