Skip to content

claude/fix hostname from dbjson 9a1f40de - #21

Merged
twistedmelonman merged 3 commits into
mainfrom
claude/fix-hostname-from-dbjson-9a1f40de
Jul 15, 2026
Merged

twistedmelonman merged 3 commits into
mainfrom
claude/fix-hostname-from-dbjson-9a1f40de

Conversation

@twistedmelonman

Copy link
Copy Markdown
Member
  • docs: design db.json hostname resolution for list-clients
  • fix(list-clients): resolve real hostnames from Synergy db.json

Claude Code Bot added 2 commits July 14, 2026 14:28
Root cause of the arich-mac lock failure: Synergy sanitizes the internal
hyphen out of the screen name before writing synergy.conf, so the conf
already reads arichmac-3181d4b4. The list-clients suffix-strip regex is
innocent. The real display name lives in the sibling db.json, joinable on
the last 8 hex of its id field. Resolve via the name field (not hostname,
which diverges and would break mimolette), with jq + fallback to today's
heuristic.
A client whose real name is arich-mac.local never locked: Synergy sanitizes
the hyphen out of the screen name before writing synergy.conf, so the conf
reads 'arichmac-3181d4b4' and list-clients emitted the unresolvable
'arichmac.local'. The suffix-strip regex was innocent — the hyphen was gone
upstream, in Synergy.

Recover the true display name from the sibling db.json, joining the conf's
8-hex instance suffix against the last 8 hex of each computers[].id. Use the
'name' field, not 'hostname' (they diverge; hostname can be the default
'Andrews-Mac-mini.local' and would break the working mimolette client).

Runtime-hardened for the LaunchAgent: kept bash-3.2 compatible (glob with
explicit character classes, no BASH_REMATCH or {8} interval, no assoc arrays)
since launchd's minimal PATH selects system bash 3.2, and resolve jq by
absolute path (probing Homebrew locations) since launchd's PATH excludes
Homebrew. Degrades to the old suffix-strip heuristic when jq or db.json is
absent, so no host is ever worse off than before. db.json path overridable
via LOCK_SYNC_DB.

Verified against the real conf and under a launchd-equivalent runtime
(minimal PATH + /bin/bash 3.2.57). Adds 7 bats cases; suite 40/40,
shellcheck clean.
@claude

claude Bot commented Jul 15, 2026

Copy link
Copy Markdown

The change adds db.json-based hostname resolution to bin/list-clients to fix a client whose Synergy screen name has its hyphen dropped. Key logic review:

  • Glob pattern for suffix detection (local hex='[0-9a-fA-F]' + eight $hex expansions in [[ pattern): correct — [[ expands character classes on the RHS of ==, so $hex becomes [0-9a-fA-F] in the pattern. Behaves correctly on bash 3.2.
  • Suffix extraction (${label##*-} / ${label%-*}): strips the right segment regardless of hyphens in the base name (e.g. arich-mac-3181d4b4 → suffix 3181d4b4, base arich-mac). Correct.
  • jq .id[-8:] join key: matches the last 8 chars of the full 64-char sha, which is what Synergy appends as the screen suffix. Verified against the test fixtures.
  • Fallback path: [[ -n "$suffix" && -n "$db_map" ]] guard means empty db_map (jq absent, db.json missing, or malformed JSON via || true) sends every label through the existing heuristic. Non-regression.
  • set -e + labels="$(awk...)" propagation: the awk exit 2 on unclosed section propagates through the command substitution assignment — script exits 2 as intended.
  • || true on jq invocation: correctly swallows jq failures so malformed JSON degrades silently rather than aborting.

No bugs, regressions, security issues, or data-loss risks found.

VERDICT: PASS

The "Fallback / anti-regression:" test cases restarted the ordered list
but continued numbering 5-7, tripping markdownlint MD029 (style 1/2/3).
Renumber the second list to 1-3.

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

claude Bot commented Jul 15, 2026

Copy link
Copy Markdown

The PR adds db.json-based hostname resolution to bin/list-clients so Synergy's sanitized screen names (e.g. arichmac-3181d4b4) map back to their real display names (e.g. arich-mac.local).

No blocking issues found. Key correctness points verified:

  • set -euo pipefail at line 2 ensures awk's exit 2 (unterminated-section guard) propagates through labels="$(awk ...)" — not swallowed.
  • 2>/dev/null || true on the jq call prevents a set -e abort when jq is absent or db.json is malformed; db_map stays empty and every screen takes the heuristic path.
  • stderr from awk inside $(...) flows through to the outer shell, so the "not closed" error message still surfaces.
  • The glob pattern *-$hex$hex...$hex (8 times) correctly identifies and extracts the 8-hex suffix without relying on {n} intervals or BASH_REMATCH, keeping bash 3.2 compatibility.

VERDICT: PASS

@claude

claude Bot commented Jul 15, 2026

Copy link
Copy Markdown

The PR adds db.json-based hostname resolution to bin/list-clients so Synergy's sanitized screen names (e.g. arichmac-3181d4b4) map back to their real display names (e.g. arich-mac.local).

No blocking issues found. Key correctness points verified:

  • set -euo pipefail at line 2 ensures awk's exit 2 (unterminated-section guard) propagates through labels="$(awk ...)" — not swallowed.
  • 2>/dev/null || true on the jq call prevents a set -e abort when jq is absent or db.json is malformed; db_map stays empty and every screen takes the heuristic path.
  • stderr from awk inside $(...) flows through to the outer shell, so the "not closed" error message still surfaces.
  • The glob pattern *-$hex$hex...$hex (8 times) correctly identifies and extracts the 8-hex suffix without relying on {n} intervals or BASH_REMATCH, keeping bash 3.2 compatibility.

VERDICT: PASS

@twistedmelonman
twistedmelonman merged commit 13eae99 into main Jul 15, 2026
4 checks passed
@twistedmelonman
twistedmelonman deleted the claude/fix-hostname-from-dbjson-9a1f40de branch July 15, 2026 15:22
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.

1 participant