Skip to content

Add the identity flags: --id, --manufacturer, --product-name - #29

Merged
chrisuthe merged 1 commit into
Sendspin:mainfrom
balloobbot:task/identity-flags
Aug 28, 2026
Merged

chrisuthe merged 1 commit into
Sendspin:mainfrom
balloobbot:task/identity-flags

Conversation

@balloobbot

@balloobbot balloobbot commented Aug 27, 2026 •

Copy link
Copy Markdown

Second gap from the daemon-parity audit: identity. The client id was the library's MAC-derived default with no way to choose one, and the client/hello device info was hardcoded.

Why the id matters

client_id is the stable identity a server files volume, group membership and pairing under — -n is only what it displays. Two players on one host derive the same MAC, so each server-side setting lands on whichever connected last; the dual-mono two-daemons-one-host pattern was impossible. The Python CLI has all three flags.

What it adds

  • --id <id> (config key id) sets SendspinClientConfig::client_id. The default stays empty on purpose: the library derives the MAC-based id only when nothing is set, and that remains the right identity for one fixed endpoint per host. The flag also feeds the stream hooks' SENDSPIN_CLIENT_ID — reserved in Run stream hooks on stream start and stop #28 but never set, because the derived id is not exposed by the library; the flag's value is the first honest one a hook can be handed.
  • --manufacturer / --product-name (config keys manufacturer / product-name) override the hello device info, for the integrator whose product embeds this player and should be listed as itself. Defaults stay sendspin-cpp-cli / sendspin-cli.
  • All three are refused empty, warned about on a subcommand run like every other daemon-only flag, and settable from the config file through the same apply_option() door as every other key.

Two doc corrections that came out of review

  • The dual-instance guidance in --help and the README named --id and --port but not --state-dir. state_store_path() is namespaced by neither, so two daemons on one host overwrite each other's volume, mute, delay and last-server state. The annotated example config and state_store.cpp already said so; these two now agree with them.
  • The example config's annotated hook-env list gained SENDSPIN_CLIENT_ID, which this change is what sets.

Testing

  • New parse tests (fields, defaults, empty-value refusal) and config-file coverage.
  • Full suite locally: 386/387. The one failure is ConfigMerge.AConfiguredControlSocketIsAbsolutizedUnderDaemonize, which asserts a socket path fits in sun_path and fails only because this checkout's directory is long enough to push the path to 107 bytes against a 103-byte limit — unrelated to this change and green on a shorter path.
  • Verified end to end against a real aiosendspin server: the connected client reports the --id value as its client_id, and the start hook exports SENDSPIN_CLIENT_ID=kitchen-left.

Docs updated: --help, README (flag list + dual-mono note, hooks table), wiki Configuration.md key table, wiki Controlling-the-Player.md, the annotated example config, and docs/ROADMAP.md (item 23; item 22's CLIENT_ID caveat resolved).

Rebased onto main now that #28 has merged, so this is the identity change alone. The one hook file it still touches is src/hooks.h, for the one-line client_id doc comment that #28 left pointing at a flag that did not exist yet.

Of Copilot's six review comments, three are addressed here (the two --state-dir ones and the example config's hook-env list) and two were already fixed on main by later commits on #28. The remaining two are #28's code rather than this change's, and are filed as #33 and #34.

Copilot AI 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.

Pull request overview

Adds configurable client identity and device metadata, alongside the stacked stream-hook functionality.

Changes:

  • Adds identity and device-information flags with config-file support.
  • Runs asynchronous start/stop hooks with SENDSPIN_* context.
  • Updates tests, build configuration, and documentation.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
CMakeLists.txt Builds hook implementation and tests.
src/cli.h Defines identity and hook options.
src/cli.cpp Parses and documents new options.
src/hooks.h Declares the hook environment and runner.
src/hooks.cpp Spawns, monitors, and reports hooks.
src/log.h Adds the hook log category.
src/main.cpp Applies identity and wires hooks.
src/player_listener.h Exposes stream lifecycle callbacks.
src/player_listener.cpp Emits lifecycle callbacks.
tests/cli_test.cpp Tests identity flags and defaults.
tests/config_file_test.cpp Tests identity configuration keys.
tests/hooks_test.cpp Tests hook parsing and execution.
README.md Documents identity and stream hooks.
packaging/sendspin-cli.conf.example Adds example identity and hook settings.
docs/wiki/Configuration.md Lists new configuration keys.
docs/wiki/Controlling-the-Player.md Documents stream-hook operation.
docs/ROADMAP.md Marks hooks and identity as shipped.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/main.cpp Outdated
Comment on lines +911 to +912
if (outbound) {
context.server_url = outbound->dialed_url();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Real, and out of this PR's scope — dialed_url_ and the on_stream_event block that reads it are #28's. Filed as #34. The docs already point a hook that must be certain at SENDSPIN_SERVER_ID, but as the issue says, that is a hedge rather than a fix: closing it properly needs sendspin-cpp to name the live connection's origin.

Comment thread src/hooks.cpp Outdated
Comment on lines +101 to +102
dup2(STDERR_FILENO, STDOUT_FILENO);
execve("/bin/sh", argv, envp.data());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Already fixed on main by 010959b ("Hand a hook nothing of the player's but the two output streams"), which closes every descriptor above stderr in the child and puts SIGPIPE back to SIG_DFL. This branch was stacked on #28's first commit only and so carried a stale copy; it is now rebased onto main and no longer touches src/hooks.cpp at all.

Comment thread src/hooks.cpp
Comment on lines +108 to +110
cli_log(LogLevel::DEBUG, "Running %s hook [%d]: %s", event, static_cast<int>(pid),
command.c_str());
this->running_.push_back({pid, event, command});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Real, and out of this PR's scope — the code is #28's, and this branch no longer touches src/hooks.cpp after the rebase onto main. Filed as #33, with the serialise-and-coalesce shape sketched there so the "nothing waits on a hook" property survives the fix.

Comment thread src/cli.cpp Outdated
std::fprintf(out, " player's volume, group and pairing under -- -n is only\n");
std::fprintf(out, " what it displays. Defaults to an id derived from the\n");
std::fprintf(out, " network interface MAC, which two players on one host\n");
std::fprintf(out, " would share: give each its own --id (and --port)\n");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed. --help now reads "give each its own --id (and its own --port and --state-dir)", which is what packaging/sendspin-cli.conf.example and the comment at src/state_store.cpp:234 already said — this makes the three agree.

Comment thread README.md Outdated
Comment on lines +1071 to +1072
each server-side setting lands on whichever connected last. A dual-mono pair needs
`--id` (and `--port`) per instance. Run `--help` for the current state of each

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed, the same way as the --help text. The README also now names --id in the four other passages that enumerate what a second player on one host needs (the state-file section here, and the wiki's Configuration, Troubleshooting and Raspberry Pi pages) — that list was complete until this PR, and --id is the member of it a server sees.

Comment thread packaging/sendspin-cli.conf.example Outdated
# Shell commands run when a stream starts and when it stops -- an amplifier relay, a
# light. `/bin/sh -c`, with the event's facts in SENDSPIN_* environment variables:
# SENDSPIN_EVENT (start|stop) always, and SENDSPIN_SERVER_ID, SENDSPIN_SERVER_NAME,
# SENDSPIN_SERVER_URL and SENDSPIN_CLIENT_NAME where known. The hook runs without

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fixed — the annotated hook-env list now names SENDSPIN_CLIENT_ID. --help was missing it too, for the same reason, and now names it again.

The client id was the library's MAC-derived default with no way to
choose one, and the client/hello device info was hardcoded. The id is
the half that bites: it is the stable identity a server files volume,
group membership and pairing under -- -n is only what it displays -- and
two players on one host derive the same MAC, so each server-side setting
lands on whichever connected last. The dual-mono two-daemons-one-host
pattern needs a flag; the Python CLI has all three.

--id sets SendspinClientConfig::client_id (config key `id`). The default
stays empty on purpose: the library derives the MAC-based id only when
nothing is set, and that remains the right identity for one fixed
endpoint per host. The flag also feeds the stream hooks'
SENDSPIN_CLIENT_ID, until now reserved but never set -- the derived id
is not exposed by the library, so the flag's value is the first honest
one a hook can be handed.

--manufacturer and --product-name override the hello device info, for
the integrator whose product embeds this player and should be listed as
itself. Defaults stay sendspin-cpp-cli / sendspin-cli.

All three are refused empty, warned about on a subcommand run like every
other daemon-only flag, and settable from the config file through the
same apply_option() door.

Verified against a real aiosendspin server: the connected client reports
the --id value as its client_id, and the start hook exports it as
SENDSPIN_CLIENT_ID.

The dual-instance guidance in --help and the README now names --state-dir
beside --id and --port. state_store_path() is namespaced by neither, so two
daemons on one host overwrite each other's volume, mute, delay and last
server; the annotated example config and state_store.cpp already said so and
these two did not. That example config's hook-env list gains
SENDSPIN_CLIENT_ID, which this change is what sets.

The four passages that already enumerated what a second player on one host
needs -- the README's state-file section, the wiki's Configuration,
Troubleshooting and Raspberry Pi pages -- name --id too. They listed --port,
--state-dir and a control socket, which was the whole list until this change;
--id is now the one of the four that a server sees.

--help names SENDSPIN_CLIENT_ID among the hook's variables again. It was
dropped because nothing set it and a flag's own help must not promise a
variable that cannot arrive; this is the flag that makes it arrive, and --help
was the last surface still silent about it.
@chrisuthe
chrisuthe force-pushed the task/identity-flags branch from 49780a8 to ee1edbe Compare August 28, 2026 02:19
@chrisuthe
chrisuthe merged commit 672b2f2 into Sendspin:main Aug 28, 2026
6 checks passed
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.

4 participants