This repository was archived by the owner on Jul 24, 2026. It is now read-only.
feat(ding): --root flag + unset-root WARN (pin the state root against pty-restart env drop) - #85
Merged
Merged
Conversation
…state root st ding gains --root PATH (alias --st-root), overriding $ST_ROOT and the install default. Because it lives on the COMMAND LINE, it survives a pty restart (which reuses the stored command but can drop/replace env) — the failure mode where a daemon relying only on $ST_ROOT silently falls back to the default root (~/.local/state/smalltalk), watches the wrong inbox, and re-pokes stranded messages forever (phantom pokes) while never delivering the agent's real inbox. Also adds a startup WARN: when $ST_ROOT is unset (and no --root) AND more than one state root exists under ~/.local/state/, st ding emits a loud one-line stderr warning naming the roots — the exact ambiguity that otherwise takes a multi-round investigation to spot. Additive + back-compat: existing invocations unchanged; single-root setups never warn. Pairs with convoy writePtyToml emitting --root so pty-restart can't drop the root.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What
st dinggains--root PATH(alias--st-root): an explicit state-root override that wins over$ST_ROOTand the install default. Plus a startup WARN when$ST_ROOTis unset and more than one state root exists on disk.Why (the incident this closes)
A fleet of ding daemons was launched without
$ST_ROOTset, so they fell back to the install default~/.local/state/smalltalk— but the live network runs on~/.local/state/convoy. Where the old root had stranded messages, the daemon re-poked them forever ("phantom pokes") while never delivering the agent's real (convoy-root) inbox. The[id:]discriminator (#84) is what finally made these visible.Crucially,
pty restartreuses the stored command but can drop/replace env, so a daemon relying only on$ST_ROOTsilently reverts to the default root on every restart — env alone isn't durable. The fix must live where a restart can't drop it: the command line.The change
--root PATH/--st-root PATH→const root = rootArg ?? ctx.stRoot. Put it in the launch command and it survivespty restart.$ST_ROOT(fell back to default) andplausibleStateRoots()finds >1 root under~/.local/state/, emit one loud stderr line naming them. This one warning would have turned a 3-round diagnosis into an instant one.Division of labor (with convoy-claude)
writePtyToml'sdingCommandemits--root <net>so every sidecar pins its root; + the fleet re-launch of the 13 daemons still on unset-root. convoy is waiting on this flag to wire that.Back-compat
Fully additive. Existing
st dinginvocations are unchanged; single-root setups never warn.Blast radius
src/commands/ding.ts—cmdDingCliarg parse + root resolution +--help; new read-onlyplausibleStateRoots()helper.tests/unit/ding.test.ts— 6 new tests (flag parse,--st-rootalias, override reaches identity check, WARN fires on ambiguity, WARN suppressed by--rootand by$ST_ROOT).CHANGELOG.md.Verification
vitest run tests/unit/ding.test.ts→ 101 passed (95 + 6 new).tsc -p tsconfig.build.json --noEmit→ clean.st dingfrom source:--helpshows the flag;--root /custom/rootreachesmkdir '/custom/root/<id>/inbox'(override is load-bearing, not just parsed); the WARN fires naming both roots;--rootand$ST_ROOTeach suppress it.