Repository navigation
Conversation
- Rewrote SKILL.md: canonical task/plan/log formats, 9-section taxonomy, idle parallelism, submodule support, Blocked Tasks, PR CI-failure handling - Added todo-template.md blank project template - Added todo_plans/ directory with per-task plan files - Added todo.log append-only action log - Added Blocked Tasks section to todo.md Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 task
This was referenced Jul 29, 2026
aphelps
pushed a commit
that referenced
this pull request
Aug 1, 2026
…CI never ran Six defects, two of which could strand the machine off its network. The watchdog built a /bin/sh -c string with subprocess.list2cmdline — the WINDOWS quoting rule. An SSID or password containing a space, quote, backtick or $ was corrupted or executed: `pa$$word` became the shell's PID, `a;id` ran id, and a single quote killed the watchdog at launch with unexpected-EOF while the handle still looked alive — i.e. the recovery path was silently absent exactly when someone's password contained an apostrophe. It also put the network PSK in a ps-visible argv for the whole timeout. Replaced with a detached python child that execs an argv list and takes the password on stdin. dog.terminate() ran before checking whether the restore had worked, so in the one scenario the watchdog exists for, the code disarmed it and then printed "the watchdog may still recover it" — false, and it had just removed the only remaining recovery path. Now only disarmed once we are demonstrably back. is_connected() accepted any IPv4 address, but a WLED SoftAP hands out 4.3.2.x — so "still on the device's AP" read as "back on home Wi-Fi", the watchdog was disarmed and the run exited 0 on a stranded host. Excludes the SoftAP subnet and link-local now. This was defect #1 from the plan's own critique of wled-ap-hop.sh, faithfully reproduced. The host's own networks were candidates. A real run would join the home network, find no WLED device, and then FORGET it — removing it from the preferred list on the way past. Verified: naming the target network as --ssid now drops it. forget() was skipped when the join failed, though a failed join can still have added the SSID to the preferred list. The guarding test never asserted plat.forgotten, so it passed against code doing the opposite of its name — the third such test in this repo, so the pattern is mine. The band check tested `!= 5`, which fails OPEN for an unknown band; now requires 2.4 positively. The Swift helper also inferred band from channel number, which misreads 6GHz (channels 1-233) — it now uses CoreWLAN's own channelBand. Finally: test-apjoin was never wired into `test:`. My earlier edit searched for a string containing test-sync, which only exists on another branch, so .replace() silently matched nothing and I reported "make test green" for a suite that never ran. The edit now asserts before substituting.
aphelps-claude-bot
added a commit
that referenced
this pull request
Aug 22, 2026
* add wled_apjoin: put WLED devices in AP mode onto the network Scans for candidate APs, joins each, identifies it, pushes credentials if it needs them, and restores this machine's network on every path. Discovery unions three sources because each misses what the others catch: a targeted probe for WLED-AP (a broadcast sweep was observed missing an AP that was plainly there), sweep hits matching WLED-* (catches WLED_AP_SSID_UNIQUE builds whose SSID suffix cannot be known in advance), and open 2.4GHz APs, which is the only way to find RENAMED devices — they are indistinguishable from strangers by name. Open APs are restricted to 2.4GHz. An ESP32 has no 5GHz radio, so a 5GHz open network cannot be a WLED device, and that single check keeps the tool away from most public hotspots — xfinitywifi is on channel 44 here. Credentials go via POST /json/cfg, never the /settings/wifi form: that handler reads every field unconditionally and missing ones arrive as "", so a credentials-only POST also empties apSSID (destroying AP-fallback recovery), forces apBehavior=0, clamps TX power and disables ESP-NOW while clearing linked_remotes. The push is gated on identity — brand == WLED AND an Espressif OUI on info.mac — because the target network's plaintext PSK crosses a link whose passphrase is published in WLED's own source, or absent entirely. Open-AP probing means associating to networks that are not ours; nothing is ever sent to one. Devices already on the CURRENT LAN are skipped; a device on a different network is re-pointed onto this one. That makes the pre-run LAN scan a correctness input, not just verification. Safety, since a hop takes this machine off its own network: restore runs in a finally that ignores further signals so a second Ctrl-C cannot abandon it half-done, it verifies the rejoin and retries once, and a detached watchdog (start_new_session, so it survives SIGINT to the process group and SIGKILL of this process) force-restores regardless. Every AP is forgotten after use — macOS stores the passphrase and adds the SSID to the preferred list, which the OS then auto-joins later. Scanning uses a small Swift CoreWLAN helper: airport is gone on macOS 26 and system_profiler redacts SSIDs. It reports withheld-SSID explicitly rather than returning an empty list, which would be indistinguishable from "no devices". 21 host tests against a fake platform, wired in as make test-apjoin. The three safety properties are mutation-verified: removing the identity gate, the forget() cleanup, or the 5GHz exclusion each turns tests red. * address self-review: shell injection, a disarmed watchdog, and tests CI never ran Six defects, two of which could strand the machine off its network. The watchdog built a /bin/sh -c string with subprocess.list2cmdline — the WINDOWS quoting rule. An SSID or password containing a space, quote, backtick or $ was corrupted or executed: `pa$$word` became the shell's PID, `a;id` ran id, and a single quote killed the watchdog at launch with unexpected-EOF while the handle still looked alive — i.e. the recovery path was silently absent exactly when someone's password contained an apostrophe. It also put the network PSK in a ps-visible argv for the whole timeout. Replaced with a detached python child that execs an argv list and takes the password on stdin. dog.terminate() ran before checking whether the restore had worked, so in the one scenario the watchdog exists for, the code disarmed it and then printed "the watchdog may still recover it" — false, and it had just removed the only remaining recovery path. Now only disarmed once we are demonstrably back. is_connected() accepted any IPv4 address, but a WLED SoftAP hands out 4.3.2.x — so "still on the device's AP" read as "back on home Wi-Fi", the watchdog was disarmed and the run exited 0 on a stranded host. Excludes the SoftAP subnet and link-local now. This was defect #1 from the plan's own critique of wled-ap-hop.sh, faithfully reproduced. The host's own networks were candidates. A real run would join the home network, find no WLED device, and then FORGET it — removing it from the preferred list on the way past. Verified: naming the target network as --ssid now drops it. forget() was skipped when the join failed, though a failed join can still have added the SSID to the preferred list. The guarding test never asserted plat.forgotten, so it passed against code doing the opposite of its name — the third such test in this repo, so the pattern is mine. The band check tested `!= 5`, which fails OPEN for an unknown band; now requires 2.4 positively. The Swift helper also inferred band from channel number, which misreads 6GHz (channels 1-233) — it now uses CoreWLAN's own channelBand. Finally: test-apjoin was never wired into `test:`. My earlier edit searched for a string containing test-sync, which only exists on another branch, so .replace() silently matched nothing and I reported "make test green" for a suite that never ran. The edit now asserts before substituting. * docs: add scripts/README.md covering wled_apjoin Review feedback on #32: the tool shipped with no user-facing docs. scripts/README.md covers what wled_apjoin does and how to run it: the prerequisites that are easy to get wrong (macOS-only, a 2.4GHz target network, the Location Services grant without which scanning always looks empty), the dry-run-first workflow, a full flag table, what each RESULT column value means, and how to recover by hand if a run leaves the machine off its network. Known limitations are stated rather than left to be discovered: two devices sharing an SSID are adopted one run at a time, and this is deliberately not something an ESP32 should run. Also states plainly that --password lands in `ps` and shell history, since that is still true and a reader should know before typing it. Two small doc fixes alongside it: `make test-apjoin` was missing from the Makefile's own usage header, and --yes's help said "do not confirm each device" while the implementation asks one prompt for the whole list. No behaviour change; 23 host tests still pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix four defects found by the first live run against real hardware Adopting two real devices onto a real network broke this in four distinct ways, none of which the host tests could have caught. Each fix ships with a regression test, and each of those tests was mutation-checked by reverting the fix and confirming it fails. 1. The Espressif OUI table was a guess, not the assignment. It held 34 prefixes collected from devices we happened to have seen. Both live devices are 2c:bc:bb, which was not among them, so a genuine WLED device was refused with "MAC is not Espressif" — the identity gate failing closed on real hardware, which is the same as not working. Replaced with all 331 prefixes IEEE has assigned to Espressif. 2. HTTP was attempted before DHCP. networksetup returns once the association is up, not once there is a lease, so the probe of 4.3.2.1 fired with no route and the device was reported `not-wled no /json/info response`. The same two devices gave opposite answers on consecutive runs, purely on timing. Now waits for an address first, and a missing lease is reported as join-failed rather than as a verdict on the device. 3. A single pass cannot adopt a flapping AP. A device in AP-fallback drops its SoftAP every time it retries its own connection, so the AP seen during the scan is routinely gone a second later — "Could not find network". Added --adopt-deadline: keep re-scanning and retrying, with device verdicts final and radio failures retryable, so a device is never re-pushed and never abandoned for being mid-retry. The deadline also covers the opening scan, since finding nothing at t=0 is the normal starting state. --safety-timeout is raised to match, out loud, so the watchdog cannot fire mid-adoption. 4. The device was rebooted before its config was saved. POST /json/cfg applies values and defers the flash write to a later main-loop pass, so an immediate /reset can discard the credentials. Of the two devices in the first successful run, one came back up still broadcasting its AP. Now reads the config back before rebooting, and checks `pskl` as well as the SSID — WLED returns the passphrase length, never the passphrase, and an SSID that saved without its PSK yields a device that looks configured and can never authenticate. Absent pskl means "cannot disprove". Result: WLED-TOUCH-BOX (2cbcbbd98960) adopted onto the target network and confirmed at 192.168.1.39. WLED-TOUCH-MATRIX still declines to associate after a confirmed push; that looks device-side and is still being chased. 30 host tests pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * add --inspect, and stop mistaking "never left" for "not a WLED device" Two more findings from chasing WLED-TOUCH-MATRIX, which accepted a confirmed credential push and then still refused to associate. --inspect joins a device, reports its identity and wifi/AP config, and pushes nothing. --dry-run answers "which APs would I touch?" without using the radio; this answers "why won't that device join?", which can only be learned from the device. A test asserts it never POSTs, never hits /reset, and still forgets the AP — it exists to be pointed at hardware someone is already unsure about, so read-only has to be a property, not an intention. It paid for itself immediately: the matrix is configured for SSID 'STARLINK' with pskl=0 — a network with no stored passphrase, which it can never authenticate against, so it falls back to its AP forever. Its ap.behav is 0, the same as the device that adopted cleanly, which rules out the SoftAP-channel-pinning theory I had been working from. The second finding is a hole in yesterday's DHCP fix. wait_for_address accepted ANY address, but networksetup can report success while leaving the host exactly where it was — so the check passed instantly on the home address, the run probed 4.3.2.1 from the wrong subnet, and the device was reported `not-wled no /json/info response`. That is the same lie the DHCP wait was added to remove, one layer up: a radio failure wearing a verdict about the device. wait_for_address now takes different_from and the address must actually change; failing that is reported as join-failed with the address we never left. Visible immediately in the next live run: six retries against the matrix, every one correctly attributed to the radio rather than to the device. 32 host tests pass. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * docs: bring scripts/README.md up to date with what the live test changed Five new options since the README was written, and two of them are the difference between the tool working and not: - A section on flapping APs and --adopt-deadline, because "join-failed Could not find network" against an AP you can plainly see is the single most confusing thing this tool does, and the fix is one flag. - A section on --inspect for diagnosing a device that takes the credentials and still never joins, with the real output from WLED-TOUCH-MATRIX and what it means: nw.ssid='STARLINK' nw.pskl=0 is a device configured for a network it has no passphrase for. Explains that pskl is a length and that 0 against a non-empty SSID is the signature of credentials that did not save. Also expanded the RESULT table: join-failed now covers three distinct failures and the detail string says which, and push-failed can now mean "the config never read back", in which case the device is deliberately not rebooted. Known limitations revised — the same-SSID case is now usually resolved across passes rather than needing a rerun, and repeated association failure against a short-lived AP is written down as a real outcome with what to do about it. A check that every --flag the parser defines appears in the README passes: 20 flags, none undocumented. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * retry the join in place: macOS scan results are cached Repeat sweeps come back in well under a second, which means CoreWLAN is serving a cache rather than sampling the radio. A candidate can therefore be an artifact of an AP that has already cycled off, and the join fails with "Could not find network" against an AP the scan just reported. One attempt per sighting loses that race over and over — six consecutive failures against WLED-TOUCH-MATRIX, an AP that was genuinely up much of that time. Retrying via the outer re-scan loop does not fix it: re-scanning costs seconds and re-reads the same cache. --join-retries (default 4, 4s apart) retries the association directly, which is both faster and actually samples the radio. A successful join breaks out immediately; the failure detail now says how many attempts were made. This is what finally got the matrix adopted: joined, pushed, and the config confirmed read back. 34 host tests pass, including one asserting the retries actually happen (mutation-checked by pinning the loop to a single iteration) and one asserting a successful join does not keep retrying. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * inspect the whole wifi config, and stop trusting a RAM read-back as "saved" Continued diagnosis of WLED-TOUCH-MATRIX, which takes a confirmed push and still will not join. --inspect now reports every nw.ins entry with its static-IP fields, plus filesystem usage, free heap and uptime. Reading only ins[0]'s ssid/pskl hid three different things that look identical from outside: a second configured network taking priority, a leftover static address (the device associates fine and is then unreachable on the wrong subnet), and whether the device is actually rebooting when told to. Two hypotheses died on the evidence, which is worth recording so they are not re-litigated: the matrix is addr=dhcp, not a stale static IP; and fs=24/983kB, so its filesystem is nowhere near full. The finding that matters: the config read-back proves less than it looks. GET /json/cfg serves the IN-MEMORY config, so it returns whatever was just pushed regardless of whether cfg.json was written, and WLED defers that write to a later main-loop pass. Confirming on the first poll and resetting immediately can therefore beat the write — the device accepts the push, reads it back, and reverts to its old network on the next real power cycle, which is exactly what was observed twice. --write-settle (default 6s) waits after the confirmation before rebooting. The previous "read it back before rebooting" fix was necessary but not sufficient; this is the other half. 35 host tests pass, including one asserting the settle happens between the confirmation and the reset rather than anywhere else. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * address re-review: per-MAC push finality, per-hop watchdog, persistent-scan-failure exit, 6GHz band label Co-Authored-By: Claude Fable 5 <[email protected]> * address re-review: grace shields the final push, and detach from the device AP between hops Co-Authored-By: Claude Fable 5 <[email protected]> * address re-review: detach gate keyed to the home address, not WLED's subnet Co-Authored-By: Claude Fable 5 <[email protected]> * address re-review: refresh the home-address reference after each successful detach Co-Authored-By: Claude Fable 5 <[email protected]> * address re-review: is_connected rejects ESP-IDF's softAP subnet, and the home refresh never latches a device lease Co-Authored-By: Claude Fable 5 <[email protected]> * address re-review: refuse a home LAN inside a device-AP subnet, and never latch link-local Co-Authored-By: Claude Fable 5 <[email protected]> * address re-review: a link-local launch address is not a home reference; name the subnet tuple once Co-Authored-By: Claude Fable 5 <[email protected]> * address re-review: no-reference fallback rejects link-local, and a blanked home reference can recover Co-Authored-By: Claude Fable 5 <[email protected]> * address re-review: the home reference is latched only from a lease behind a confirmed rejoin Co-Authored-By: Claude Fable 5 <[email protected]> * address re-review: a failed association neither confirms the detach nor latches the reference Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: aphelps-claude-bot <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SKILL.mdwith canonical task/plan/log formats, 9-section taxonomy, idle parallelism, submodule support, Blocked Tasks handling, and PR CI-failure recovery — all project-agnostictodo-template.md: reusable blank template with all sections and annotated example entriestodo_plans/directory for per-task plan files (linked fromtodo.mdentries, not embedded)todo.logfor append-only timestamped action/state-transition loggingtodo.mdTest plan
SKILL.mdand verify all 9 sections, formats, and workflow steps are presenttodo-template.mdand confirm all sections with example entries/todo-handlerand verify it correctly reads the task from Pending Tasks🤖 Generated with Claude Code