chore: comment cleanup pass ahead of open-sourcing
Some checks failed
Build Linux Binaries / linux/amd64 (push) Has been cancelled
Build Linux Binaries / linux/arm64 (push) Has been cancelled

Removes leftover debug scaffolding (stray Console.WriteLine/NSLog traces,
dead nick_buf_ptr, a no-op --print-config flag now implemented for real),
fixes stale/misleading comments (channel passwords are no longer a "future
M5+" feature, a wrong cross-reference, a stale TlsContext::close() mention,
an incomplete BanRecord::subject_type doc, and a smoke test pointing at a
build/m1-dev preset that no longer exists), strips internal M1-M5 milestone
jargon from comments now that the roadmap is done, trims comments that just
restated the following line, and consolidates a few "why" explanations that
were duplicated 2-3 times in the same file.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-03 10:20:18 +01:00
parent bda37ec27b
commit bba605401d
50 changed files with 229 additions and 331 deletions

View File

@@ -1,9 +1,8 @@
/*
* vccli — headless test client.
*
* This is the primary way the protocol is exercised and verified from M1 onward (see
* AGENTS.md). Each milestone's exit criterion is demonstrated by driving two vccli
* instances against a real voicecat-server.
* This is the primary way the protocol is exercised and verified (see AGENTS.md): driving
* two vccli instances against a real voicecat-server.
*/
#include <atomic>
#include <chrono>
@@ -26,11 +25,11 @@ struct Stats {
std::atomic<bool> auth_done{false};
std::atomic<bool> auth_ok{false};
// Set right after vc_client_create, before vc_connect — lets on_event auto-confirm the
// M4 TOFU gate (VC_EVENT_SERVER_IDENTITY below). vccli has no interactive prompt, so it
// TOFU gate (VC_EVENT_SERVER_IDENTITY below). vccli has no interactive prompt, so it
// trusts-on-first-connect unconditionally (prints the fingerprint for visibility).
vc_client* client{nullptr};
// M5 async result tracking. Generic results are used by every moderation/admin/channel
// Async result tracking. Generic results are used by every moderation/admin/channel
// request; account-list is its own event. We count generic results so callers can wait
// for a new one even if several arrived earlier.
std::atomic<int> generic_result_count{0};
@@ -125,7 +124,6 @@ bool wait_until(std::atomic<bool>& flag, int timeout_ms) {
return true;
}
// Wait for a new generic result to arrive. Returns the vc_result from that result.
vc_result wait_generic_result(Stats& st, int baseline_count, int timeout_ms) {
auto deadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeout_ms);
while (st.generic_result_count.load() <= baseline_count) {
@@ -200,7 +198,7 @@ void print_usage() {
" --username U authenticate as registered user U\n"
" --password P password for --username\n"
" --channel ID channel to join after auth (default 1, Lobby)\n"
" --wait-ms N timeout for M5 async result events (default 5000)\n"
" --wait-ms N timeout for async result events (default 5000)\n"
"\n"
"Voice / devices:\n"
" --voice start a MIC stream and stay connected until Ctrl+C\n"
@@ -278,7 +276,7 @@ void run_stdin_commands(vc_client* c, std::atomic<bool>& stop) {
}
}
// Issue an M5 request that produces VC_EVENT_GENERIC_RESULT and wait for it.
// Issue a request that produces VC_EVENT_GENERIC_RESULT and wait for it.
// Returns the result code from the event.
using RequestFn = std::function<vc_result()>;
@@ -536,107 +534,107 @@ int main(int argc, char** argv) {
std::this_thread::sleep_for(std::chrono::milliseconds(300)); // let the relay land
}
// M5 moderation / admin requests (executed in a sensible order if multiple are given).
bool m5_error = false;
// Moderation / admin requests (executed in a sensible order if multiple are given).
bool mod_request_error = false;
if (self_mute || self_deafen) {
r = vc_set_self_mute(c, self_mute ? 1 : 0, self_deafen ? 1 : 0);
std::printf("vc_set_self_mute -> %d (%s)\n", r, vc_result_string(r));
if (r != VC_OK) m5_error = true;
if (r != VC_OK) mod_request_error = true;
}
if (!m5_error && do_kick) {
if (!mod_request_error && do_kick) {
r = run_generic_request(st, wait_ms,
[&]() { return vc_kick_user(c, kick_user_id, kick_reason.c_str()); },
"vc_kick_user");
if (r != VC_OK) m5_error = true;
if (r != VC_OK) mod_request_error = true;
}
if (!m5_error && do_ban) {
if (!mod_request_error && do_ban) {
r = run_generic_request(st, wait_ms,
[&]() { return vc_ban_user(c, ban_user_id, ban_reason.c_str(), ban_expires_ms); },
"vc_ban_user");
if (r != VC_OK) m5_error = true;
if (r != VC_OK) mod_request_error = true;
}
if (!m5_error && do_move) {
if (!mod_request_error && do_move) {
r = run_generic_request(st, wait_ms,
[&]() { return vc_move_user(c, move_user_id, move_channel_id); },
"vc_move_user");
if (r != VC_OK) m5_error = true;
if (r != VC_OK) mod_request_error = true;
}
if (!m5_error && do_server_mute_request) {
if (!mod_request_error && do_server_mute_request) {
r = run_generic_request(st, wait_ms,
[&]() { return vc_set_server_mute(c, server_mute_user_id, server_mute_muted, server_mute_deafened); },
"vc_set_server_mute");
if (r != VC_OK) m5_error = true;
if (r != VC_OK) mod_request_error = true;
}
if (!m5_error && do_set_permission) {
if (!mod_request_error && do_set_permission) {
r = run_generic_request(st, wait_ms,
[&]() { return vc_set_permission(c, perm_user_id, &perms); },
"vc_set_permission");
if (r != VC_OK) m5_error = true;
if (r != VC_OK) mod_request_error = true;
}
if (!m5_error && do_create_channel) {
if (!mod_request_error && do_create_channel) {
r = run_generic_request(st, wait_ms,
[&]() { return vc_create_channel(c, &channel_info); },
"vc_create_channel");
if (r != VC_OK) m5_error = true;
if (r != VC_OK) mod_request_error = true;
}
if (!m5_error && do_edit_channel) {
if (!mod_request_error && do_edit_channel) {
r = run_generic_request(st, wait_ms,
[&]() { return vc_edit_channel(c, &channel_info); },
"vc_edit_channel");
if (r != VC_OK) m5_error = true;
if (r != VC_OK) mod_request_error = true;
}
if (!m5_error && do_delete_channel) {
if (!mod_request_error && do_delete_channel) {
r = run_generic_request(st, wait_ms,
[&]() { return vc_delete_channel(c, delete_channel_id); },
"vc_delete_channel");
if (r != VC_OK) m5_error = true;
if (r != VC_OK) mod_request_error = true;
}
if (!m5_error && do_create_account) {
if (!mod_request_error && do_create_account) {
r = run_generic_request(st, wait_ms,
[&]() { return vc_create_account(c, acct_user.c_str(), acct_pass.c_str()); },
"vc_create_account");
if (r != VC_OK) m5_error = true;
if (r != VC_OK) mod_request_error = true;
}
if (!m5_error && do_reset_password) {
if (!mod_request_error && do_reset_password) {
r = run_generic_request(st, wait_ms,
[&]() { return vc_reset_password(c, acct_user.c_str(), acct_pass.c_str()); },
"vc_reset_password");
if (r != VC_OK) m5_error = true;
if (r != VC_OK) mod_request_error = true;
}
if (!m5_error && do_delete_account) {
if (!mod_request_error && do_delete_account) {
r = run_generic_request(st, wait_ms,
[&]() { return vc_delete_account(c, acct_user.c_str()); },
"vc_delete_account");
if (r != VC_OK) m5_error = true;
if (r != VC_OK) mod_request_error = true;
}
if (!m5_error && do_list_accounts) {
if (!mod_request_error && do_list_accounts) {
st.account_list_received.store(false);
r = vc_list_accounts(c);
std::printf("vc_list_accounts -> %d (%s)\n", r, vc_result_string(r));
if (r != VC_OK) {
m5_error = true;
mod_request_error = true;
} else {
if (!wait_until(st.account_list_received, wait_ms)) {
std::fprintf(stderr, "vc_list_accounts: timed out waiting for list event\n");
m5_error = true;
mod_request_error = true;
}
}
}
if (m5_error && !voice_mode) {
if (mod_request_error && !voice_mode) {
vc_disconnect(c);
vc_client_destroy(c);
return 1;
@@ -705,5 +703,5 @@ int main(int argc, char** argv) {
vc_disconnect(c);
vc_client_destroy(c);
std::printf("ok\n");
return m5_error ? 1 : 0;
return mod_request_error ? 1 : 0;
}