Skip to content

fix(status): stop saying "not-provisioned" for every connector failure - #3

Merged
MGrin merged 1 commit into
mainfrom
fix/honest-connector-state
Aug 15, 2026
Merged

fix(status): stop saying "not-provisioned" for every connector failure#3
MGrin merged 1 commit into
mainfrom
fix/honest-connector-state

Conversation

@MGrin

@MGrin MGrin commented Aug 15, 2026

Copy link
Copy Markdown
Owner

connectorState was initialised to "not-provisioned" and printed verbatim, so any failure before the service measured anything reported as unprovisioned.

That is not a neutral default — it is a specific claim telling the reader to run bb cf-tunnel provision. On 2026-08-15 the real cause was cloudflared missing from launchd's PATH (fixed in #2), and both mgrin and an agent ran provision repeatedly against a tunnel that had been fully provisioned for weeks. A wrong instruction is worse than none, because it consumes the reader's next move.

Three changes

  1. Provisioning is read from stored state (is there a connector token?) rather than from a flag a failed service may never have set. A token present with the connector down is provisioned and broken — a different problem needing a different action from never set up.
  2. The initial value is unknown. Where the plugin cannot tell, it says so rather than guessing — the same rule checkout-drift.sh follows for a stale fetch.
  3. The service's error is captured and printed as an error: line, so the reason travels with the state. The reason was the whole answer here, and status had no way to show it.

Why the rule is a pure function

It lives in lib/connector-state.ts rather than inline, because the failure path cannot be exercised against a live tunnel without breaking it — extracting it is what makes it testable at all.

Four tests cover it, including the exact regression: provisioned + never measured must report unknown, never not-provisioned.

77 tests pass. Verified live: status still reports connected with no error line while cloudflared is up.

🤖 Generated with Claude Code

`connectorState` was initialised to "not-provisioned" and printed verbatim, so
any failure before the service measured anything reported as unprovisioned.
That is not a neutral default — it is a specific claim that tells the reader to
run `bb cf-tunnel provision`. On 2026-08-15 the real cause was cloudflared
missing from launchd's PATH, and both mgrin and an agent ran provision
repeatedly against a tunnel that had been fully provisioned for weeks. A wrong
instruction is worse than none, because it consumes the reader's next move.

Three changes:

  - Provisioning is now read from STORED STATE (is there a connector token?)
    rather than from a flag a failed service may never have set. A token present
    with the connector down is "provisioned and broken", which needs a different
    action from "never set up".
  - The initial value is "unknown". Where the plugin cannot tell, it says so
    instead of guessing — the same rule checkout-drift.sh follows for a stale
    fetch.
  - Whatever the service threw is captured and printed as an `error:` line, so
    the reason travels with the state. The reason was the whole answer here and
    status could not show it.

The rule lives in lib/connector-state.ts as two pure functions rather than
inline, because the failure path cannot be exercised against a live tunnel
without breaking it — extracting it is what makes it testable at all. Four tests
cover it, including the exact regression: provisioned + never measured must
report "unknown", never "not-provisioned".

77 tests pass. Verified live: status still reports connected with no error line
while cloudflared is up.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@MGrin
MGrin merged commit db7ef8c into main Aug 15, 2026
1 check passed
@MGrin
MGrin deleted the fix/honest-connector-state branch August 15, 2026 07:21
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