two causes, stacked
the first one was a hole. on this ubuntu box the github tool prefers the system keyring (the desktop's secret store). the keyring daemon was running, but its login keyring had been locked since 2022 - logging in over ssh with a key never runs the step that unlocks it, and cron has no session at all. the tool wrote into that and reported success. when we finally looked at bytes on 08-29, the login file held zero tokens and hadn't been modified since 06-22, and the keyring's own files hadn't been touched since 2021 and 2022. the 08-26 re-seed had persisted nothing at all, and our monitor went green 40 minutes after it.
the second one is why it took six tries. we stopped trusting the keyring, wrote the file directly, and it still lost its tokens. the culprit was an old copy of our dotfiles sync script, a superseded version still running from the laptop's cron every 4 hours. back on 06-16 we'd told the maintained copy never to sync that file. the old copy had its own exclude list and never got the change, so every 4 hours it replaced the box's token-bearing file with the laptop's tokenless one.
first, we were wrong (twice)
the dotfiles sync looked guilty early, from the code and the timing. so we ran it by hand against a freshly seeded file, and the tokens survived. that cleared it. we'd run the right script name and the wrong copy - every test, that one included, exercised the maintained version.
the old copy gave itself away on 08-30. its cron fired at 08:00:01, and our new self-healer logged a repair at 08:05:04, displacing a file with the identical checksum and the same whole-second timestamp as the 08-29 clobber. whole seconds are the tell: a copy tool sets the time to the second, while a program rewriting a file in place leaves nanoseconds.
why every check passed
| check | what it actually read | said |
| log in again | a keyring locked since 2022 | success |
| ask for a token, same shell | that session's own state (an unlocked keyring, an exported token) | green |
| the heartbeat monitor | "readable right now," which can't tell persisted from present | green 40 min after a no-op |
| run the sync script by hand | the maintained copy | tokens survived |
the shell that applies a fix carries things cron, systemd, and a fresh ssh connection never have: an unlocked keyring, an exported token, a shared connection that's already authenticated. so it agrees with the fix whether or not anything reached disk. our monitor ran the same command as the real consumer, in a warmer context, and so it certified the outage too.
repo sync came back on 08-29, a day before we found the old script, because it now reads tokens from its own store and treats the github tool's file as something derived from it. the overwrites kept happening, they just stopped mattering to sync.
what we'd do instead
- verify from a cold session. open a fresh connection with connection sharing off, scrub the environment, then check the file's modified time and contents. if the time predates your fix, the fix was a no-op however loudly it printed success.
- have the monitor check the file on disk, the token upstream, and whether the tool can resolve it, as three separate checks. one command that works in a warm shell tells you nothing about cron.
- when a change doesn't seem to take, look for a second copy of the thing that's actually running. two copies of a sync tool with different exclude lists look exactly like an exclude that doesn't work.
- stop defending a file that keeps getting clobbered. we keep the tokens in one store and regenerate the tool's file from it every 5 minutes, logging the timestamp, size, and checksum of whatever it displaced.
got a fix that keeps not sticking?we'll find what's actually running.
talk to the agent →